cor2cov {JWileymisc} | R Documentation |
Convert a correlation matrix and standard deviations to a covariance matrix
Description
This is a simple function designed to convert a correlation matrix
(standardized covariance matrix) back to a covariance matrix.
It is the opposite of cov2cor
.
Usage
cor2cov(V, sigma)
Arguments
V |
an n x n correlation matrix. Should be numeric, square, and symmetric. |
sigma |
an n length vector of the standard deviations. The length of the vector must match the number of columns in the correlation matrix. |
Value
an n x n covariance matrix
See Also
Examples
# using a built in dataset
cor2cov(cor(longley), sapply(longley, sd))
# should match the above covariance matarix
cov(longley)
all.equal(cov(longley), cor2cov(cor(longley), sapply(longley, sd)))
[Package JWileymisc version 1.4.1 Index]