Cholesky {statespacer} | R Documentation |
Construct a Valid Variance - Covariance Matrix
Description
Constructs a valid variance - covariance matrix by using the Cholesky LDL decomposition.
Usage
Cholesky(param = NULL, format = NULL, decompositions = TRUE)
Arguments
param |
Vector containing the parameters used to construct the variance - covariance matrix. |
format |
Matrix representing the format for the Loading matrix L and Diagonal matrix D. The lower triangular part of the format is used as the format for the Loading matrix L. The diagonal of the format is used as the format for the Diagonal matrix D. Must be a matrix. |
decompositions |
Boolean indicating whether the loading and diagonal matrix of the Cholesky decomposition, and the correlation matrix and standard deviations should be returned. |
Details
format
is used to specify which elements of the loading and diagonal
matrix should be non-zero. The elements of param
are then distributed
along the non-zero elements of the loading and diagonal matrix.
The parameters for the diagonal matrix are transformed using exp(2 * x)
.
Value
A valid variance - covariance matrix.
If decompositions = TRUE
then it returns a list containing:
-
cov_mat
: The variance - covariance matrix. -
loading_matrix
: The loading matrix of the Cholesky decomposition. -
diagonal_matrix
: The diagonal matrix of the Cholesky decomposition. -
correlation_matrix
: Matrix containing the correlations. -
stdev_matrix
: Matrix containing the standard deviations on the diagonal.
Author(s)
Dylan Beijers, dylanbeijers@gmail.com
Examples
format <- diag(1, 2, 2)
format[2, 1] <- 1
Cholesky(param = c(2, 4, 1), format = format, decompositions = TRUE)