Skip to contents

This function simulates random covariance matrices from the multivariate normal distribution. The function ensures that the generated covariance matrices are positive semi-definite.

Usage

SimCovN(n, sigma, vcov_sigma_vech_l)

Arguments

n

Positive integer. Number of replications.

sigma

Numeric matrix. The covariance matrix (\(\boldsymbol{\Sigma}\)).

vcov_sigma_vech_l

Numeric matrix. Cholesky factorization (t(chol(vcov_sigma_vech))) of the sampling variance-covariance matrix of \(\mathrm{vech} \left( \boldsymbol{\Sigma} \right)\).

Value

Returns a list of random covariance matrices.

Author

Ivan Jacob Agaloos Pesigan

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,] 1.0341516 0.5525633 0.3122546
#> [2,] 0.5525633 1.0212208 0.4505202
#> [3,] 0.3122546 0.4505202 0.9660898
#> 
#> [[2]]
#>           [,1]      [,2]      [,3]
#> [1,] 0.9844408 0.5040074 0.3524940
#> [2,] 0.5040074 0.9503465 0.4363943
#> [3,] 0.3524940 0.4363943 1.0017958
#> 
#> [[3]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0465280 0.4654677 0.3180109
#> [2,] 0.4654677 1.0076686 0.4241276
#> [3,] 0.3180109 0.4241276 1.0374058
#> 
#> [[4]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0081898 0.4501561 0.3090518
#> [2,] 0.4501561 0.9157924 0.4430272
#> [3,] 0.3090518 0.4430272 1.0261038
#> 
#> [[5]]
#>           [,1]      [,2]      [,3]
#> [1,] 0.9966009 0.5150771 0.2968892
#> [2,] 0.5150771 0.9930506 0.4120861
#> [3,] 0.2968892 0.4120861 0.9552497
#> 
#> [[6]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0231097 0.5197943 0.3532249
#> [2,] 0.5197943 1.0764983 0.3744090
#> [3,] 0.3532249 0.3744090 0.9929289
#> 
#> [[7]]
#>           [,1]      [,2]      [,3]
#> [1,] 0.9712446 0.5167387 0.3047342
#> [2,] 0.5167387 1.0120590 0.3624400
#> [3,] 0.3047342 0.3624400 1.0500154
#> 
#> [[8]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0051078 0.5501585 0.2342611
#> [2,] 0.5501585 1.0533864 0.4082728
#> [3,] 0.2342611 0.4082728 1.0114660
#> 
#> [[9]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0356752 0.5111728 0.3519552
#> [2,] 0.5111728 0.9750850 0.4192515
#> [3,] 0.3519552 0.4192515 0.9656795
#> 
#> [[10]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0059596 0.5401671 0.2813792
#> [2,] 0.5401671 0.9880602 0.4346244
#> [3,] 0.2813792 0.4346244 0.9915865
#>