These functions compute the Cholesky root elements of a covariance matrix and, conversely, build a covariance matrix from its Cholesky root elements.
Arguments
- cov
[
matrix()]
A positive definite covariance matrix.It can also be the zero matrix, in which case the Cholesky root is defined as the zero matrix.
- unique
[
logical(1)]
Ensure that the Cholesky decomposition is unique by restricting the diagonal elements to be positive?- chol
[
numeric()]
Cholesky root elements, i.e., thep * (p + 1) / 2elements of the lower-triangular Cholesky root of a covariance matrix of dimensionp(column by column).
Value
For cov_to_chol a numeric vector of Cholesky root
elements.
For chol_to_cov a covariance matrix.
For unique_chol a numeric vector of Cholesky
root elements with a non-negative diagonal, which define the same covariance
matrix as chol.
See also
Other matrix helpers:
check_correlation_matrix(),
check_covariance_matrix(),
check_one_hot_matrix(),
check_transition_probability_matrix(),
diff_cov(),
insert_matrix_column(),
matrix_diagonal_indices(),
matrix_indices(),
sample_correlation_matrix(),
sample_covariance_matrix(),
sample_transition_probability_matrix(),
stationary_distribution()
Examples
cov <- sample_covariance_matrix(4)
chol <- cov_to_chol(cov)
all.equal(cov, chol_to_cov(chol))
#> [1] TRUE
