C.n {copula} | R Documentation |
Given a random sample from a distribution with continuous margins and
copula C, the empirical copula is a natural nonparametric estimator of
C. The function C.n()
computes the empirical copula.
The function dCn()
approximates first-order partial derivatives
of the unknown copula.
C.n(u, U, offset=0, method=c("C", "R")) F.n(x, X, offset=0, method=c("C", "R")) dCn(u, U, j.ind=1:d, b=1/sqrt(nrow(U)), ...) Cn(x, w) ## <-- deprecated! use C.n(w, U=pobs(x)) instead!
u,x,w |
an (m, d)- |
U,X |
(and |
j.ind |
|
b |
|
offset |
used in scaling the result which is of the form
|
method |
|
... |
additional arguments passed to |
There are several asymptotically equivalent definitions of the empirical copula. Here, the empirical copula is simply defined as the empirical distribution function computed from the pseudo-observations, that is,
(1/n) sum(I_{U_i<=u}, i=1, .., n),
where U_i, i=1,..,n,
denote the pseudo-observations (rows in U
) and n the sample size.
The approximation for the jth partial derivative of the unknown copula C is implemented as, for example, in Rémillard and Scaillet (2009), and given by
hat(C.)[jn](u) = (C[n](u[1], .., u[j-1], min(u[j]+b, 1), u[j+1], .., u[d]) - C[n](u[1], .., u[j-1], max(u[j]-b, 0), u[j+1], .., u[d])) / (2b),
where b denotes the bandwidth and C[n] the empirical copula.
C.n()
and F.n()
a numeric vector of length
m
with the values
for C.n()
of the empirical copula of U
at u
, and
for F.n()
of the empirical CDF (cumulative distribution
function) of X
at x
.
dCn()
returns a (m, l)-matrix or an m-vector (for
l=1; here, l is the length of j.ind
), containing
the approximated first-order partial derivatives of the unknown
copula at u
.
The first version of our empirical copula implementation, Cn()
,
had its two arguments reversed compared to C.n()
, and is
deprecated now. You must swap the arguments, and possibly use
pobs
, i.e, instead of Cn(x, u)
, use
C.n(u, U=pobs(x))
!
Ivan Kojadinovic, Marius Hofert
Rüschendorf, L. (1976). Asymptotic distributions of multivariate rank order statistics, Annals of Statistics 4, 912–923.
Deheuvels, P. (1979). La fonction de dépendance empirique et ses propriétés: un test non paramétrique d'indépendance, Acad. Roy. Belg. Bull. Cl. Sci., 5th Ser. 65, 274–292.
Deheuvels, P. (1981). A non parametric test for independence, Publ. Inst. Statist. Univ. Paris 26, 29–50.
Rémillard, B. and Scaillet, O. (2009). Testing for equality between two copulas. Journal of Multivariate Analysis, 100(3), pages 377-386.
pobs()
for computing pseudo-observations,
pCopula()
for evaluating a copula.
n <- 100 d <- 3 family <- "Gumbel" theta <- 2 cop <- onacopulaL(family, list(theta=theta, 1:d)) set.seed(1) U <- rCopula(n, cop) ## random points were to evaluate the empirical copula u <- matrix(runif(n*d), n, d) ec <- C.n(u, U=U) ## compare with true distribution function mean(abs(pCopula(u, copula=cop)-ec)) # increase n to decrease this error ## compare the empirical copula and the true copula ## on the diagonal of the unit square Cn. <- function(x) C.n(do.call(cbind, rep(list(x), d)), U=U) curve(Cn., 0, 1, main=paste("Diagonal of a", family, "copula"), xlab="u", ylab=expression(italic(C)[n](italic(u),..,italic(u)))) pC <- function(x) pCopula(do.call(cbind, rep(list(x), d)), cop) curve(pC, lty=2, add=TRUE) legend("topleft", lty=1:2, bty="n", inset=0.02, legend=c(expression(italic(C)[n]), expression(italic(C)))) ## check the empirical copula with its Kendall distribution function plot( pK(C.n(U, U=U), cop=cop@copula, d=d) ) # must be uniform ## approximate partial derivatives w.r.t. the 2nd and 3rd component j.ind <- 2:3 der23 <- dCn(u, U=pobs(U), j.ind=j.ind) der23. <- copula:::dCdu(archmCopula(family, param=theta, dim=d), u=u)[,j.ind] summary(as.vector(abs(der23-der23.))) # approximation error summary ## For an example of using F.n(), see help(mvdc)% ./Mvdc.Rd