Skip to contents

[Stable]

Given the variances and desired correlations, generate a covariance matrix

Usage

get_covmat(cormat, var)

Arguments

cormat

A symmetric matrix with desired correlations.

var

A numeric vector with variances. It must have length equal to the number of elements in the diagonal of cormat.

Value

A (co)variance matrix

Author

Tiago Olivoto tiagoolivoto@gmail.com

Examples

# \donttest{
cormat <-
matrix(c(1,  0.9, -0.4,
         0.9,  1,  0.6,
        -0.4, 0.6, 1),
      nrow = 3,
      ncol = 3)
get_covmat(cormat, var =  c(16, 25, 9))
#>      V1 V2   V3
#> V1 16.0 18 -4.8
#> V2 18.0 25  9.0
#> V3 -4.8  9  9.0
# }