Created
August 10, 2021 08:46
-
-
Save JakeJing/459703535bc54c05948ea9e9e8252359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# randomly generate a correlation matrix (R) | |
my_lkj_corr_rng(K = 2, eta = 1.4) | |
# [,1] [,2] | |
#[1,] 1.0000000 -0.8743114 | |
#[2,] -0.8743114 1.0000000 | |
# randomly generate a Cholesky factor (L) | |
(L_chol = my_lkj_corr_chol_rng(K = 2, eta = 1.4)) | |
# [,1] [,2] | |
#[1,] 1.00000000 0.000000 | |
#[2,] 0.09454103 0.995521 | |
# triangular matrix multiplication (L*L^T) | |
# L_chol %*% t(L_chol) | |
my_multiply_lower_tri_self_transpose(L_chol) | |
# [,1] [,2] | |
#[1,] 1.00000000 0.09454103 | |
#[2,] 0.09454103 1.00000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment