tau <- 0.5
(theta <- copGumbel@tauInv(tau)) # 2
d <- 20
(cop <- onacopulaL("Gumbel", list(theta,1:d)))
## compute Kendall distribution function
u <- seq(0,1, length.out = 255)
Ku <- K(u, cop=cop@copula, d=d) # exact
Ku.MC <- K(u, cop=cop@copula, d=d, n.MC=1000) # via Monte Carlo
## build sample from K
set.seed(1)
n <- 200
U <- rnacopula(n, cop)
W <- pnacopula(cop, u=U)
## 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)
Run the code above in your browser using DataLab