Learn R Programming

copula (version 0.999-14)

K: Kendall Distribution Function for Archimedean Copulas

Description

The distribution function of the Kendall distribution of an Archimedean copula is defined as $$K(u) = P(C(U_1,U_2,\dots,U_d) \le u),$$ where $u in [0,1]$, and the $d$-dimensional $(U[1],U[2],\dots,U[d])$ is distributed according to the copula $C$. Note that the random variable $C(U[1],U[2],...,U[d])$ is known as probability integral transform. Its distribution function $K$ is equal to the identity if $d = 1$, but is non-trivial for $d >= 2$.

Kn() computes the empirical Kendall distribution function, pK(), qK(), dK(), and rK() provide the distribution function, quantile function, density, and random number generator, respectively, for the Kendall distribution of an Archimedean copula.

Usage

Kn(u, x) pK(u, cop, d, n.MC=0, log.p=FALSE) qK(u, cop, d, n.MC=0, method=c("default", "simple", "sort", "discrete", "monoH.FC"), u.grid, ...) dK(u, cop, d, n.MC=0, log.p=FALSE) rK(n, cop, d)

Arguments

u
evaluation point(s) (have to be in $[0,1]$).
x
data (in the $d$-dimensional space) based on which the Kendall distribution function is estimated.
cop
acopula with specified parameter, or (currently for rK only) a outer_nacopula.
d
dimension (not used when cop is an outer_nacopula).
n.MC
integer, if positive, a Monte Carlo approach is applied with sample size equal to n.MC to evaluate the generator derivatives involved; otherwise (n.MC=0) the exact formula is used based on the generator derivatives as found by Hofert et al. (2011b).
log.p
logical; if TRUE, probabilities $p$ are given as $log(p)$.
method
string for the method to compute the quantile function of $K$. Currently, one of
"default"
The default method. Currently chooses method="monoH.FC" with u.grid=0:128/128.

"simple"
Straightforward root finding based on uniroot.

"sort"
Root finding based on uniroot but first sorting u.

"discrete"
First, $K$ is evaluated at the given grid points u.grid (which should contain 0 and 1). Based on these probabilities, quantiles are computed with findInterval.

"monoH.FC"
First, $K$ is evaluated at the given grid points u.grid. A monotone spline is then used to approximate $K$. Based on this approximation, quantiles are computed with uniroot.

u.grid
(for method="discrete":) the grid on which $K$ is evaluated, a numeric vector.
...
additional arguments passed to uniroot (for method="default", method="simple", method="sort", and method="monoH.FC") or findInterval (for method="discrete").
n
sample size for rK.

Value

distribution function, its quantile function, density, and random number generator.

Details

For a completely monotone Archimedean generator $psi$, $$K(u)=\sum_{k=0}^{d-1} \frac{\psi^{(k)}(\psi^{-1}(u))}{k!} (-\psi^{-1}(u))^k,\ u\in[0,1];$$ see Barbe et al. (1996). The corresponding density is $$\frac{(-1)^d\psi^{(d)}(\psi^{-1}(u))}{(d-1)!} (-(\psi^{-1})'(u))(\psi^{-1}(u))^{d-1}$$

The empirical Kendall distribution function is computed as in Genest, G. Nešlehová, Ziegel (2011).

References

Barbe, P., Genest, C., Ghoudi, K., and Rémillard, B. (1996), On Kendall's Process, Journal of Multivariate Analysis 58, 197--229.

Hofert, M., Mächler, M., and McNeil, A. J. (2012). Likelihood inference for Archimedean copulas in high dimensions under known margins. Journal of Multivariate Analysis 110, 133--150.

Genest, C., G. Nešlehová, J., and Ziegel, J. (2011). Inference in multivariate Archimedean copula models. TEST 20, 223--256.

See Also

htrafo or emde (where K is used).

Examples

Run this code
tau <- 0.5
(theta <- copGumbel@iTau(tau)) # 2
d <- 20
(cop <- onacopulaL("Gumbel", list(theta,1:d)))

## basic check empirical Kendall distribution function
set.seed(271)
n <- 1000
U <- rCopula(n, cop)
X <- qnorm(U)
K.sample <- pCopula(U, copula=cop)
u <- seq(0, 1, length.out=256)
edfK <- ecdf(K.sample)
plot(u, edfK(u), type="l", ylim=c(0,1),
     xlab=expression(italic(u)), ylab=expression(K[n](italic(u)))) # simulated
K.n <- Kn(u, x=X)
lines(u, K.n, col="royalblue3") # Kn
## difference at 0
edfK(0) # edf of K at 0
K.n[1] # K_n(0); this is > 0 since K.n is the edf of a discrete distribution
## => therefore, Kn(K.sample, x=X) is not uniform
plot(Kn(K.sample, x=X), ylim=c(0,1))
## Note: Kn(0) -> 0 for n -> Inf

## compute Kendall distribution function
u <- seq(0,1, length.out = 255)
Ku    <- pK(u, cop=cop@copula, d=d) # exact
Ku.MC <- pK(u, cop=cop@copula, d=d, n.MC=1000) # via Monte Carlo

## build sample from K
set.seed(1)
n <- 200
W <- rK(n, cop)

## plot empirical distribution function based on W
## and the corresponding theoretical Kendall distribution function
## (exact and via Monte Carlo)
plot(ecdf(W), col="blue", xlim=c(0,1), verticals=TRUE,
     main = expression("Empirical"~ F[n]( C(U) ) ~
                       "and its Kendall distribution"~ K(u)),
     do.points=FALSE, asp=1)
abline(0,1, lty=2); abline(h=0:1, v=0:1, lty=3, col="gray")
lines(u, Ku.MC, col="red")
lines(u, Ku, col="black")
legend(.2,.6, expression(F[n],K(u), K[MC](u)),
       col=c("blue","red","black"), lty=1, bty="n",
       xjust = 0.25, yjust = 0.5)


### testing qK
uexpr <- quote( 0:63/63 );  u <- eval(uexpr)
d <- 10
cop <- onacopulaL("Gumbel", list(theta = 2, 1:d))

system.time(Ku1 <- qK(u, cop=cop@copula, d=d, method="simple"))
system.time(Ku2 <- qK(u, cop=cop@copula, d=d, method="sort"))
system.time(Ku3 <- qK(u, cop=cop@copula, d=d, method="discrete",
                      u.grid=0:1e4/1e4))
system.time(Ku4 <- qK(u, cop=cop@copula, d=d, method="monoH.FC",
                      u.grid=0:5e2/5e2))

cols <- adjustcolor(c("gray80", "light blue", "royal blue", "purple3"), 0.6)
matplot(u, cbind(Ku1,Ku2,Ku3,Ku4), type="l", lwd=2*4:1, lty = 1:4, col= cols,
        xlab=substitute(u == U, list(U=uexpr)), ylab=expression({K^{-1}}(u)))
legend("topleft", col=cols, lwd=2*4:1, lty=1:4, bty="n", inset=.03,
       legend= paste0("method= ",
             sQuote(c("simple", "sort", "discrete", "monoH.FC"))))

Run the code above in your browser using DataLab