Simulate Diagonal Covariance Matrices from the Multivariate Normal Distribution
Source:R/RcppExports.R
SimCovDiagN.RdThis function simulates random diagonal covariance matrices from the multivariate normal distribution. The function ensures that the generated covariance matrices are positive semi-definite.
Arguments
- n
Positive integer. Number of replications.
- sigma_diag
Numeric matrix. The covariance matrix (\(\boldsymbol{\Sigma}\)).
- vcov_sigma_diag_l
Numeric matrix. Cholesky factorization (
t(chol(vcov_sigma_vech))) of the sampling variance-covariance matrix of \(\mathrm{vech} \left( \boldsymbol{\Sigma} \right)\).
See also
Other Simulation of State Space Models Data Functions:
LinSDE2SSM(),
LinSDECovEta(),
LinSDECovY(),
LinSDEMeanEta(),
LinSDEMeanY(),
ProjectToHurwitz(),
ProjectToStability(),
SSMCovEta(),
SSMCovY(),
SSMInterceptEta(),
SSMInterceptY(),
SSMMeanEta(),
SSMMeanY(),
SimAlphaN(),
SimBetaN(),
SimBetaN2(),
SimBetaNCovariate(),
SimCovN(),
SimIotaN(),
SimNuN(),
SimPhiN(),
SimPhiN2(),
SimPhiNCovariate(),
SimSSMFixed(),
SimSSMIVary(),
SimSSMLinGrowth(),
SimSSMLinGrowthIVary(),
SimSSMLinSDEFixed(),
SimSSMLinSDEIVary(),
SimSSMOUFixed(),
SimSSMOUIVary(),
SimSSMVARFixed(),
SimSSMVARIVary(),
SpectralRadius(),
TestPhi(),
TestPhiHurwitz(),
TestStability(),
TestStationarity()
Examples
n <- 10
sigma_diag <- c(1, 1, 1)
vcov_sigma_diag_l <- t(chol(0.001 * diag(3)))
SimCovDiagN(
n = n,
sigma_diag = sigma_diag,
vcov_sigma_diag_l = vcov_sigma_diag_l
)
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 1.018961 0.000000 0.000000
#> [2,] 0.000000 1.034873 0.000000
#> [3,] 0.000000 0.000000 1.024973
#>
#> [[2]]
#> [,1] [,2] [,3]
#> [1,] 0.9286775 0.000000 0.0000000
#> [2,] 0.0000000 1.012595 0.0000000
#> [3,] 0.0000000 0.000000 0.9977968
#>
#> [[3]]
#> [,1] [,2] [,3]
#> [1,] 1.028824 0.0000000 0.000000
#> [2,] 0.000000 0.9096426 0.000000
#> [3,] 0.000000 0.0000000 1.021352
#>
#> [[4]]
#> [,1] [,2] [,3]
#> [1,] 0.9742215 0.0000000 0.000000
#> [2,] 0.0000000 0.9844067 0.000000
#> [3,] 0.0000000 0.0000000 1.028971
#>
#> [[5]]
#> [,1] [,2] [,3]
#> [1,] 1.023703 0.0000000 0.0000000
#> [2,] 0.000000 0.9572151 0.0000000
#> [3,] 0.000000 0.0000000 0.9597157
#>
#> [[6]]
#> [,1] [,2] [,3]
#> [1,] 0.9954098 0.0000000 0.000000
#> [2,] 0.0000000 0.9975186 0.000000
#> [3,] 0.0000000 0.0000000 1.023891
#>
#> [[7]]
#> [,1] [,2] [,3]
#> [1,] 0.9898989 0.00000 0.000000
#> [2,] 0.0000000 1.00651 0.000000
#> [3,] 0.0000000 0.00000 1.043984
#>
#> [[8]]
#> [,1] [,2] [,3]
#> [1,] 1.007064 0.0000000 0.0000000
#> [2,] 0.000000 0.9440822 0.0000000
#> [3,] 0.000000 0.0000000 0.9471224
#>
#> [[9]]
#> [,1] [,2] [,3]
#> [1,] 0.9638273 0.000000 0.00000
#> [2,] 0.0000000 1.017432 0.00000
#> [3,] 0.0000000 0.000000 1.02906
#>
#> [[10]]
#> [,1] [,2] [,3]
#> [1,] 0.9846425 0.0000000 0.00000
#> [2,] 0.0000000 0.9959778 0.00000
#> [3,] 0.0000000 0.0000000 1.02866
#>