Last data update: 2014.03.03

R: Empirical copula
 emp.copula R Documentation

## Empirical copula

### Description

`emp.copula` and `emp.copula.self` compute the empirical copula for a given sample. The difference between these functions is, that `emp.copula.self` does not require a matrix `u`, at which the function is evaluated.

### Usage

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

### Arguments

 `u` a matrix, at which the function is evaluated. According to the dimension of the data matrix `x`, it can be a scalar, a vector or a matrix. The entries of `u` should be within the interval [0, 1]. `x` denotes the matrix of marginal distributions, if `margins = NULL`. The number of columns should be equal the dimension d, whereas the number of rows should be equal to the number of observations n, with n > d. `proc` enables the user to choose between two different methods. It is recommended to use the default method, `"M"`, because it takes only a small fraction of the computational time of method `"A"`. However, method `"M"` is sensitive with respect to the size of the working memory and therefore, non-applicable for very large datasets. `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. `margins` specifies the margins. The data matrix is assumed to contain the values of the marginal distributions by default, i.e. `margins = NULL`. If raw data are used, the margins can be determined nonparametrically, `"edf"`, or in parametric way, e.g. `"norm"`. See `estimate.copula` for a detailed explanation. `na.rm` boolean. If `na.rm = TRUE`, missing values, `NA`, contained in `x` and `u` are removed. `...` arguments to be passed to `na.omit`.

### Details

The estimated copula follows the formula

widehat{C} ≤ft(u_{1}, …, u_{d} ight) = n^{-1} ∑_{i=1}^{n} ∏_{j=1}^{d} mathbf{I} ≤ft{ widehat{F}_{j} ≤ft( X_{ij} ight) ≤q u_{j} ight},

where widehat{F}_{j} denotes the empirical marginal distribution function of variable X_{j}.

### Value

A vector containing the values of the empirical copula.

### References

Okhrin, O. and Ristig, A. 2014, Hierarchical Archimedean Copulae: The `HAC` Package", Journal of Statistical Software, 58(4), 1-20, http://www.jstatsoft.org/v58/i04/.

`pHAC`

### Examples

```v = seq(-4, 4, 0.05)
X = cbind(matrix(pt(v, 1), 161, 1), matrix(pnorm(v), 161, 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)

# 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)
```

### Results

```
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HAC)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HAC/emp.copula.Rd_%03d_medium.png", width=480, height=480)
> ### Name: emp.copula
> ### Title: Empirical copula
> ### Aliases: emp.copula emp.copula.self
>
> ### ** Examples
>
> v = seq(-4, 4, 0.05)
> X = cbind(matrix(pt(v, 1), 161, 1), matrix(pnorm(v), 161, 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)
> # integer(0)
>
> # 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)
>
>
>
>
>
> dev.off()
null device
1
>

```