Skip to contents

These functions compute the Cholesky root elements of a covariance matrix and, conversely, build a covariance matrix from its Cholesky root elements.

Usage

cov_to_chol(cov, unique = TRUE)

chol_to_cov(chol)

unique_chol(chol)

Arguments

cov

[matrix()]
A covariance matrix.

unique

[logical(1)]
Ensure that the Cholesky decomposition is unique by restricting the diagonal elements to be positive?

chol

[numeric()]
Cholesky root elements.

Value

For cov_to_chol a numeric vector of Cholesky root elements.

For chol_to_cov a covariance matrix.

Examples

cov <- sample_covariance_matrix(4)
chol <- cov_to_chol(cov)
all.equal(cov, chol_to_cov(chol))
#> [1] TRUE