Learn R Programming

copula (version 0.99-4)

Copula: Copula distribution functions

Description

Density, distribution function, and random generation for a copula object.

Usage

dcopula(copula, u, log=FALSE, ...)
pcopula(copula, u, ...)
rcopula(copula, n, ...)

Arguments

copula
an Robject of class "Copula", (i.e., "copula" or "nacopula").
u
a vector of the copula dimension or a matrix with number of columns being equal to the copula dimension, giving the coordinates of the points where the density or distribution function needs to be evaluated.
log
logical indicating if the $\log(f(\cdot))$ should be returned instead of $f(\cdot)$.
n
(for rcopula():) number of observations to be generated.
...
further optional arguments for some methods, e.g., method.

Value

  • "dcopula" gives the density, "pcopula" gives the distribution function, and "rcopula" generates random variates.

Details

The density function of an Archimedean copula was obtained by differentiating the distribution function symbolically using Mathematica and then processed by deriv to give algorithmic expressions. The maximum dimension implemented is 10 for Clayton and Gumbel, and 6 for Frank.

The distribution function of a t copula uses pmvt from package mvtnorm. The density function of a t copula uses the dmst from package sn.

The random number generator for an Archimedean copula uses the conditional approach for the bivariate case and the Marshal-Olkin (1988) approach for dimension greater than 2.

References

E.W. Frees and E.A. Valdez (1998). Understanding relationships using copulas. North American Actuarial Journal 2, 1--25.

C. Genest and A.-C. Favre (2007). Everything you always wanted to know about copula modeling but were afraid to ask. Journal of Hydrologic Engineering 12, 347--368.

H. Joe (1997). Multivariate Models and Dependence Concepts. Chapman and Hall, London.

A.W. Marshal and I. Olkin (1988). Families of multivariate distributions. Journal of the American Statistical Association 83, 834--841.

R.B. Nelsen (2006). An introduction to Copulas. Springer, New York.

See Also

the copula and acopula classes, ellipCopula, archmCopula, fgmCopula.

Examples

Run this code
norm.cop <- normalCopula(0.5)
norm.cop
x <- rcopula(norm.cop, 100)
plot(x)
dcopula(norm.cop, x)
pcopula(norm.cop, x)
persp(norm.cop, dcopula)
contour(norm.cop, pcopula)

## a 3-dimensional normal copula
u <- rcopula(normalCopula(0.5, dim = 3), 1000)
if(require("scatterplot3d"))
  scatterplot3d(u)

## a 3-dimensional clayton copula
cl3 <- claytonCopula(2, dim = 3)
v <- rcopula(cl3, 1000)
pairs(v)
if(require("scatterplot3d"))
  scatterplot3d(v)

## Compare with the "nacopula" version :
fu1 <- dcopula(cl3, v)
fu2 <- copClayton@dacopula(v, theta = 2)
Fu1 <- pcopula(cl3, v)
Fu2 <- pnacopula(onacopula("Clayton", C(2.0, 1:3)), v)
## The density and cumulative values are the same:
stopifnot(all.equal(fu1, fu2, tol= 1e-14),
          all.equal(Fu1, Fu2, tol= 1e-15))

Run the code above in your browser using DataLab