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,] 0.9453100 0.4995039 0.2295634
#> [2,] 0.4995039 0.9846987 0.4474894
#> [3,] 0.2295634 0.4474894 0.9983945
#> 
#> [[2]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0595277 0.5006539 0.3065987
#> [2,] 0.5006539 0.9467486 0.4189609
#> [3,] 0.3065987 0.4189609 1.0348725
#> 
#> [[3]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0249734 0.5172577 0.2286775
#> [2,] 0.5172577 1.0125949 0.3977968
#> [3,] 0.2286775 0.3977968 0.9706371
#> 
#> [[4]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0288240 0.4096426 0.3213520
#> [2,] 0.4096426 1.0645402 0.3742215
#> [3,] 0.3213520 0.3742215 0.9844067
#> 
#> [[5]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0289707 0.5065213 0.3237028
#> [2,] 0.5065213 0.9572151 0.3597157
#> [3,] 0.3237028 0.3597157 0.9643785
#> 
#> [[6]]
#>           [,1]      [,2]      [,3]
#> [1,] 0.9954098 0.4975186 0.3238913
#> [2,] 0.4975186 0.9484577 0.3898989
#> [3,] 0.3238913 0.3898989 1.0065099
#> 
#> [[7]]
#>           [,1]      [,2]      [,3]
#> [1,] 1.0439838 0.4841791 0.3070641
#> [2,] 0.4841791 0.9440822 0.3471224
#> [3,] 0.3070641 0.3471224 1.0097071
#> 
#> [[8]]
#>           [,1]      [,2]      [,3]
#> [1,] 0.9638273 0.5174320 0.3290599
#> [2,] 0.5174320 0.9734041 0.3846425
#> [3,] 0.3290599 0.3846425 0.9959778
#> 
#> [[9]]
#>           [,1]     [,2]      [,3]
#> [1,] 1.0286602 0.491940 0.2803007
#> [2,] 0.4919400 1.006822 0.4009730
#> [3,] 0.2803007 0.400973 1.0796971
#> 
#> [[10]]
#>           [,1]      [,2]      [,3]
#> [1,] 0.9974445 0.5318089 0.3512592
#> [2,] 0.5318089 0.9680744 0.4099154
#> [3,] 0.3512592 0.4099154 0.9502194
#>