Simulate Diagonal Covariance Matrices from the Multivariate Normal Distribution
Source:R/RcppExports.R
SimCovDiagN.Rd
This 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()
,
LinSDECov()
,
LinSDEMean()
,
SSMCov()
,
SSMMean()
,
SimAlphaN()
,
SimBetaN()
,
SimCovN()
,
SimIotaN()
,
SimPhiN()
,
SimSSMFixed()
,
SimSSMIVary()
,
SimSSMLinGrowth()
,
SimSSMLinGrowthIVary()
,
SimSSMLinSDEFixed()
,
SimSSMLinSDEIVary()
,
SimSSMOUFixed()
,
SimSSMOUIVary()
,
SimSSMVARFixed()
,
SimSSMVARIVary()
,
TestPhi()
,
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.022052 0.0000000 0.0000000
#> [2,] 0.000000 0.9702043 0.0000000
#> [3,] 0.000000 0.0000000 0.9694815
#>
#> [[2]]
#> [,1] [,2] [,3]
#> [1,] 1.016651 0.0000000 0.0000000
#> [2,] 0.000000 0.9881213 0.0000000
#> [3,] 0.000000 0.0000000 0.9876752
#>
#> [[3]]
#> [,1] [,2] [,3]
#> [1,] 1.054342 0.0000000 0.0000000
#> [2,] 0.000000 0.9701998 0.0000000
#> [3,] 0.000000 0.0000000 0.9745409
#>
#> [[4]]
#> [,1] [,2] [,3]
#> [1,] 1.007864 0.0000000 0.0000000
#> [2,] 0.000000 0.9801459 0.0000000
#> [3,] 0.000000 0.0000000 0.9968695
#>
#> [[5]]
#> [,1] [,2] [,3]
#> [1,] 1.01571 0.0000000 0.000000
#> [2,] 0.00000 0.9716756 0.000000
#> [3,] 0.00000 0.0000000 1.009698
#>
#> [[6]]
#> [,1] [,2] [,3]
#> [1,] 0.990624 0.000000 0.000000
#> [2,] 0.000000 1.026254 0.000000
#> [3,] 0.000000 0.000000 1.007779
#>
#> [[7]]
#> [,1] [,2] [,3]
#> [1,] 0.9951546 0.000000 0.0000000
#> [2,] 0.0000000 1.014382 0.0000000
#> [3,] 0.0000000 0.000000 0.9798945
#>
#> [[8]]
#> [,1] [,2] [,3]
#> [1,] 0.9776931 0.000000 0.0000000
#> [2,] 0.0000000 1.024585 0.0000000
#> [3,] 0.0000000 0.000000 0.9880219
#>
#> [[9]]
#> [,1] [,2] [,3]
#> [1,] 1.016051 0.000000 0.000000
#> [2,] 0.000000 1.046304 0.000000
#> [3,] 0.000000 0.000000 1.019845
#>
#> [[10]]
#> [,1] [,2] [,3]
#> [1,] 0.9923103 0.0000000 0.0000000
#> [2,] 0.0000000 0.9663594 0.0000000
#> [3,] 0.0000000 0.0000000 0.9802058
#>