Learn R Programming

copula (version 0.999-1)

Copula: Copula functions

Description

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

Usage

dCopula(u, copula, log=FALSE, ...)
pCopula(u, copula, ...)
rCopula(n, copula, ...)

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 (dCopula) and distribution function (pCopula) methods for Archimedean copulas now use the corresponding function slots of the Archimedean copula objects, such as copClayton, copGumbel, etc.

The distribution function of a t copula uses pmvt from package mvtnorm; similarly, the density (dCopula) calls dmvt from mvtnorm. The normalCopula methods use dmvnorm and pmvnorm from the same package.

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

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

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

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

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

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

See Also

the copula and acopula classes, the acopula families, acopula-families. Constructor functions such as ellipCopula, archmCopula, fgmCopula.

Examples

Run this code
norm.cop <- normalCopula(0.5)
norm.cop
x <- rCopula(100, norm.cop)
plot(x)
dCopula(x, norm.cop)
pCopula(x, norm.cop)
persp(norm.cop, dCopula)
contour(norm.cop, pCopula)

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

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

## Compare with the "nacopula" version :
fu1 <- dCopula(v, cl3)
fu2 <- copClayton@dacopula(v, theta = 2)
Fu1 <- pCopula(v, cl3)
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