Learn R Programming

HAC (version 0.1-1)

emp.copula: Empirical copula

Description

The functions emp.copula and emp.copula.self compute the empirical copula for a given sample. The difference between these functions is, that emp.copula.self takes the sample itself as grid u, such that the grid has not to be specified manually.

Usage

emp.copula(u, x, proc = "M", sort = "none", na.rm = FALSE)
emp.copula.self(x, proc = "M", sort = "none", na.rm = FALSE)

Arguments

u
the grid for the computation of the empirical copula. It can be a scalar, a vector or a matrix. The number of columns has to be equal to the number of columns of the matrix x. The values of u should be within the interval $[0, 1]
x
denotes the matrix of variables, which are marginal distributions in practice. The values should be within the interval $[0, 1]$. The number of columns should correspond to the number of variables, whereas the number of rows should be equal to the number
proc
enables the user to choose between two different methods. Generally, it is advised to choose "M" (given by default), because it takes only $1/25$ of the computational time of method "A". However, in the case of large datasets it
sort
defines, whether the output is ordered. sort = "asc" refers to ascending values, which might be interesting for plotting and sort = "desc" refers to descending values.
na.rm
boolean. If na.rm = TRUE and a row of x or u contains a value bigger than 1, smaller than 0 or NA, the row is dropped and not used for the computation. Corresponding warnings appear.

Value

  • A vector containing the values of the empirical copula.

Details

The estimated copula follows the formula $$\widehat{C} \left(u_{1}, \dots, u_{d} \right) = n^{-1} \sum_{i=1}^{n} \prod_{j=1}^{d} \mathbf{I} \left{ \widehat{F}_{j} \left( X_{ij} \right) \leq u_{j} \right},$$ where $\widehat{F}_{j}$ denotes the empirical marginal distribution function of variable j. So it is no smoothing implemented yet.

See Also

pHAC

Examples

Run this code
v = seq(-4, 4, 0.005)
X = cbind(matrix(pt(v, 1), 1601, 1), matrix(pnorm(v), 1601, 1))

# both methods lead to the same result 
z = emp.copula.self(X, proc = "M") 
which(((emp.copula.self(X[1:100, ], proc = "M") - emp.copula.self(X[1:100, ],
proc = "A")) == 0) == "FALSE")
# integer(0)

# furthermore recognize the contour plot
out = outer(z, z)
contour(x = X[,1], y = X[,2], out, main = "Contour Plot", 
xlab = "Cauchy Margin", ylab = "Standard Normal Margin", 
labcex = 1, lwd = 1.5, nlevels = 15)

Run the code above in your browser using DataLab