View source: R/cvine_cholesky.R
| cvine_cholesky | R Documentation |
Constructs the lower‑triangular Cholesky factor \mathbf{L} of a
d \times d correlation matrix using the C‑vine method described in
Lewandowski, Kurowicka & Joe (2009). The factor satisfies
\mathbf{R} = \mathbf{L}\mathbf{L}^\top with \mathrm{diag}(\mathbf{R}) = 1.
cvine_cholesky(v, d, eta = 1)
v |
Numeric vector of unconstrained reals, one for each C‑vine edge.
The length must be |
d |
Integer, dimension of the target correlation matrix ( |
eta |
Positive numeric shape parameter for the LKJ‑C‑vine prior
(default |
The algorithm proceeds in three steps:
Each element of v is mapped to the unit interval via the
logistic (sigmoid) function, then transformed to a partial correlation
on (-1, 1) using the quantile function of a symmetric Beta
distribution with shape \phi_k = \eta + (d - k - 2)/2
(for level k, 0‑indexed).
The table of partial correlations is converted to unconditional correlations using the Yule–Kendall recursion (vine recursion).
For each new row j (starting from j = 2), the algorithm
solves a triangular system to obtain the first j-1 entries of the
row, and sets the diagonal entry to maintain unit row norm.
The resulting \mathbf{L} can be used directly to construct the correlation
matrix (tcrossprod(L)), or to build a covariance matrix by scaling
with standard deviations.
A d \times d lower‑triangular matrix \mathbf{L} with
positive diagonal entries such that \mathbf{L}\mathbf{L}^\top is a
valid correlation matrix (unit diagonal, positive definite). For d = 1,
returns a 1 \times 1 matrix with entry 1.
Lewandowski, D., Kurowicka, D., & Joe, H. (2009). Generating random correlation matrices based on vines and extended onion method. *Journal of Multivariate Analysis*, 100(9), 1989–2001. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jmva.2009.04.008")}
# For a 2x2 correlation matrix, we need one parameter
v <- 0.5
L <- cvine_cholesky(v, d = 2, eta = 1)
R <- tcrossprod(L)
print(R)
# For 3 dimensions, we need 3 parameters (d*(d-1)/2 = 3)
v <- c(0.1, -0.2, 0.8)
L <- cvine_cholesky(v, d = 3)
R <- tcrossprod(L)
all.equal(diag(R), rep(1, 3)) # Should be TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.