r_copula: Sample from a copula

View source: R/mvdist.R

r_copulaR Documentation

Sample from a copula

Description

Draws uniforms on [0,1]^d from elliptical (Gaussian, t) or Archimedean (Clayton, Gumbel, Frank) copulas. Archimedean copulas in dimension d > 2 are sampled with the Marshall–Olkin frailty algorithm; the bivariate Frank copula also allows negative dependence (theta < 0), sampled by conditional inversion.

Usage

r_copula(
  n,
  family = c("gaussian", "t", "clayton", "gumbel", "frank", "independence"),
  dim = 2L,
  corr = NULL,
  df = 4,
  theta = NULL,
  seed = NULL
)

Arguments

n

Number of draws.

family

Copula family.

dim

Dimension (ignored when corr is given).

corr

Correlation matrix for elliptical copulas (default: exchangeable with rho = 0.5). It must have a unit diagonal; a covariance matrix is rejected (convert it with stats::cov2cor()).

df

Degrees of freedom for the t copula: a positive number; Inf gives the Gaussian copula.

theta

Archimedean parameter: Clayton theta > 0, Gumbel theta >= 1, Frank theta != 0 (⁠> 0⁠ when dim > 2).

seed

Optional random seed.

Value

An ⁠n x dim⁠ matrix of uniforms.

References

Marshall, A. W. and Olkin, I. (1988). Families of multivariate distributions. Journal of the American Statistical Association, 83(403), 834–841. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1988.10478671")}

Hofert, M. (2008). Sampling Archimedean copulas. Computational Statistics & Data Analysis, 52(12), 5163–5174. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.csda.2008.05.019")}

Examples

u <- r_copula(1000, "clayton", dim = 3, theta = 2, seed = 1)
cor(u, method = "kendall")   # theoretical tau = theta / (theta + 2) = 0.5

SynthesizerPlus documentation built on Oct. 16, 2026, 5:10 p.m.