get_covmat: Generate a covariance matrix

Description Usage Arguments Value Author(s) Examples

View source: R/get_covmat.R

Description

[Stable]

Given the variances and desired correlations, generate a covariance matrix

Usage

1
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(s)

Tiago Olivoto tiagoolivoto@gmail.com

Examples

1
2
3
4
5
6
7
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))

metan documentation built on Nov. 10, 2021, 9:11 a.m.