Simulate Covariance Matrices from the Multivariate Normal Distribution
Source:R/RcppExports.R
SimCovN.RdThis function simulates random covariance matrices from the multivariate normal distribution. The function ensures that the generated covariance matrices are positive semi-definite.
See also
Other Simulation of State Space Models Data Functions:
LinSDE2SSM(),
LinSDECovEta(),
LinSDECovY(),
LinSDEInterceptEta(),
LinSDEInterceptY(),
LinSDEMeanEta(),
LinSDEMeanY(),
ProjectToHurwitz(),
ProjectToStability(),
SSMCovEta(),
SSMCovY(),
SSMInterceptEta(),
SSMInterceptY(),
SSMMeanEta(),
SSMMeanY(),
SimAlphaN(),
SimBetaN(),
SimBetaN2(),
SimBetaNCovariate(),
SimCovDiagN(),
SimIotaN(),
SimMVN(),
SimMuN(),
SimNuN(),
SimPhiN(),
SimPhiN2(),
SimPhiNCovariate(),
SimSSMFixed(),
SimSSMIVary(),
SimSSMLinGrowth(),
SimSSMLinGrowthIVary(),
SimSSMLinSDEFixed(),
SimSSMLinSDEIVary(),
SimSSMOUFixed(),
SimSSMOUIVary(),
SimSSMVARFixed(),
SimSSMVARIVary(),
SpectralRadius(),
TestPhi(),
TestPhiHurwitz(),
TestStability(),
TestStationarity()
Examples
n <- 10
sigma <- matrix(
data = c(
1.0, 0.5, 0.3,
0.5, 1.0, 0.4,
0.3, 0.4, 1.0
),
nrow = 3
)
vcov_sigma_vech_l <- t(
chol(
0.001 * diag(3 * (3 + 1) / 2)
)
)
SimCovN(
n = n,
sigma = sigma,
vcov_sigma_vech_l = vcov_sigma_vech_l
)
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 0.9742215 0.4844067 0.3289707
#> [2,] 0.4844067 1.0065213 0.4237028
#> [3,] 0.3289707 0.4237028 0.9572151
#>
#> [[2]]
#> [,1] [,2] [,3]
#> [1,] 0.9597157 0.4643785 0.2954098
#> [2,] 0.4643785 0.9975186 0.4238913
#> [3,] 0.2954098 0.4238913 0.9484577
#>
#> [[3]]
#> [,1] [,2] [,3]
#> [1,] 0.9898989 0.5065099 0.3439838
#> [2,] 0.5065099 0.9841791 0.4070641
#> [3,] 0.3439838 0.4070641 0.9440822
#>
#> [[4]]
#> [,1] [,2] [,3]
#> [1,] 0.9471224 0.5097071 0.2638273
#> [2,] 0.5097071 1.0174320 0.4290599
#> [3,] 0.2638273 0.4290599 0.9734041
#>
#> [[5]]
#> [,1] [,2] [,3]
#> [1,] 0.9846425 0.4959778 0.3286602
#> [2,] 0.4959778 0.9919400 0.3803007
#> [3,] 0.3286602 0.3803007 1.0068224
#>
#> [[6]]
#> [,1] [,2] [,3]
#> [1,] 1.0009730 0.5796971 0.2974445
#> [2,] 0.5796971 1.0318089 0.4512592
#> [3,] 0.2974445 0.4512592 0.9680744
#>
#> [[7]]
#> [,1] [,2] [,3]
#> [1,] 1.0099154 0.4502194 0.2802876
#> [2,] 0.4502194 1.0110675 0.3887407
#> [3,] 0.2802876 0.3887407 0.9849274
#>
#> [[8]]
#> [,1] [,2] [,3]
#> [1,] 0.9747801 0.4793178 0.3656572
#> [2,] 0.4793178 0.9663087 0.3904455
#> [3,] 0.3656572 0.3904455 0.9793431
#>
#> [[9]]
#> [,1] [,2] [,3]
#> [1,] 0.9594177 0.5274351 0.3060267
#> [2,] 0.5274351 1.0358792 0.3990601
#> [3,] 0.3060267 0.3990601 0.9455439
#>
#> [[10]]
#> [,1] [,2] [,3]
#> [1,] 0.9357604 0.4534859 0.3150958
#> [2,] 0.4534859 1.0011291 0.3767855
#> [3,] 0.3150958 0.3767855 1.0697661
#>