R-vine copulas
rvine_copula.Rdrvine_copula() is a regular vine copula given by its R-vine matrix in
vinecopulib's convention (rvinecopulib's rvine_matrix, pyvinecopulib's
Vinecop.matrix): d x d, the order on the antidiagonal
M[d - j + 1, j], and above it in column j row t the variable that
tree t's edge j joins to it, given the variables above it in the
column; 0 below the antidiagonal and in the rows of trees not kept. R's
VineCopula package stores the same vine flipped upside down and left to
right. rvine_structure() gives a vine's matrix and pair copulas, a C-
or D-vine's as an R-vine. copula_log_density() and copula_sample()
take an R-vine.
Arguments
- matrix
The R-vine matrix.
- pairs
A list of trees, tree
ta list of itsd - tpair copulas (pair_copula()) by column, each with first argument the column's antidiagonal variable. Fewer trees truncate the vine.- copula
A vine copula.
Value
rvine_copula(): a copula; rvine_structure(): a list with
matrix and pairs.
Examples
g <- pair_copula("gaussian", 0.5)
m <- matrix(c(2, 3, 1, 3, 2, 0, 3, 0, 0), 3)
v <- rvine_copula(m, list(list(g, g), list(g)))
copula_log_density(v, c(0.2, 0.7, 0.4))
#> [1] 0.004322008
rvine_structure(vine_copula("d", 1:3, list(list(g, g), list(g))))$matrix
#> [,1] [,2] [,3]
#> [1,] 2 3 3
#> [2,] 3 2 0
#> [3,] 1 0 0