Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

cor2cov

Back transform correlation matrix to variance-covariance matrix


Description

Compute a variance-covariance matrix from a correlation matrix and standard deviations.

Usage

cor2cov(V, sd = sqrt(diag(V)))

Arguments

V

a variance covariance matrix

sd

a vector of standard deviations - if ommitted, use the sqrt of the diagonal of V

Value

a variance-covariance matrix

Author(s)

S4M,

References

See Also

Examples

stopifnot(all.equal(
  cor2cov(cor(mtcars), sapply(mtcars, sd)), 
  cov(mtcars)
))

stackoverflow

Stack Overflow's Greatest Hits

v0.7.0
CC BY-SA 4.0
Authors
Neal Fultz <nfultz@gmail.com> and the StackOverflow.com community
Initial release
2020-01-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.