copula {nvmix} | R Documentation |
Evaluate the density / distribution function of normal variance mixture copulas (including Student t and normal copula) and generate vectors of random variates from normal variance mixture copulas.
dnvmixcop(u, qmix, scale = diag(d), factor = NULL, control = list(), verbose = FALSE, log = FALSE, ...) pnvmixcop(u, qmix, scale = diag(d), control = list(), verbose = FALSE, ...) rnvmixcop(n, qmix, scale = diag(2), factor = NULL, method = c("PRNG", "sobol", "ghalton"), skip = 0, control = list(), verbose = FALSE, ...)
u |
(n, d)- |
n |
sample size n (positive integer). |
qmix |
specification of the mixing variable W via a quantile
function; see McNeil et al. (2015, Chapter 6). This argument is required for
|
scale |
scale matrix (a covariance matrix entering the
distribution as a parameter) of dimension (d, d) (defaults to
d = 2);
this equals the covariance matrix of a random vector following
the specified normal variance mixture distribution divided by
the expecation of the mixing variable W if and only if the
former exists.
Note that |
factor |
(d, k)- |
method |
If |
skip |
|
control |
|
verbose |
|
log |
|
... |
additional arguments (for example, parameters) passed to the
underlying mixing distribution when |
... to come ...
... to come ...
Erik Hintz, Marius Hofert and Christiane Lemieux
McNeil, A. J., Frey, R. and Embrechts, P. (2015). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.
set.seed(42) # for reproducibility ## Generate a random correlation matrix in d dimensions d <- 2 # dimension rho <- runif(1, min = -1, max = 1) P <- matrix(rho, nrow = d, ncol = d) # build the correlation matrix P diag(P) <- 1 ## Generate two random evaluation points: u <- matrix(runif(2*d), ncol = d) ## We illustrate using a t-copula df = 2.1 ## Define quantile function which is inverse-gamma here: qmix. <- function(u) 1/qgamma(1-u, shape = df/2, rate = df/2) ### Example for dnvmixcop() #################################################### ## If qmix = "inverse.gamma", dnvmix() calls qt and dt: d1 <- dnvmixcop(u, qmix = "inverse.gamma", scale = P, df = df) ## Use qmix. to force the algorithm to use a rqmc procedure: d2 <- dnvmixcop(u, qmix = qmix., scale = P) stopifnot(all.equal(d1, d2, tol = 5e-4, check.attributes = FALSE)) ### Example for pnvmixcop() #################################################### ## Same logic as above: p1 <- pnvmixcop(u, qmix = "inverse.gamma", scale = P, df = df) p2 <- pnvmixcop(u, qmix = qmix., scale = P) stopifnot(all.equal(p1, p2, tol = 5e-4, check.attributes = FALSE)) ### Examples for rnvmixcop() ################################################### ## Draw random variates and compare n <- 100 set.seed(1) X <- rnvmixcop(n, qmix = "inverse.gamma", df = df, scale = P) # providing scale set.seed(1) X. <- rnvmixcop(n, qmix = "inverse.gamma", df = df, factor = t(chol(P))) # providing the factor stopifnot(all.equal(X, X.))