Constructs a valid variance - covariance matrix by using the Cholesky LDL decomposition.
Cholesky(param = NULL, format = NULL, decompositions = TRUE)
Vector containing the parameters used to construct the variance - covariance matrix.
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.
Boolean indicating whether the loading and diagonal matrix of the Cholesky decomposition, and the correlation matrix and standard deviations should be returned.
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.
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)
.
format <- diag(1, 2, 2)
format[2, 1] <- 1
Cholesky(param = c(2, 4, 1), format = format, decompositions = TRUE)
#> $cov_mat
#> [,1] [,2]
#> [1,] 54.59815 54.59815
#> [2,] 54.59815 3035.55614
#>
#> $loading_matrix
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 1 1
#>
#> $diagonal_matrix
#> [,1] [,2]
#> [1,] 54.59815 0.000
#> [2,] 0.00000 2980.958
#>
#> $correlation_matrix
#> [,1] [,2]
#> [1,] 1.0000000 0.1341127
#> [2,] 0.1341127 1.0000000
#>
#> $stdev_matrix
#> [,1] [,2]
#> [1,] 7.389056 0.00000
#> [2,] 0.000000 55.09588
#>