| cor2cov | R Documentation |
Derives covariance matrix from correlation matrix and standard deviation vector.
cor2cov(sd, R)
sd |
Numeric vector of standard deviations. |
R |
Numeric correlation matrix. |
Given correlation matrix R and standard deviation vector sd, performs the operation diag(sd) %*% R %*% diag(sd) to derive the corresponding covariance matrix. This is a counterpart to stats::cov2cor, which scales a covariance matrix into the corresponding correlation matrix.
Returns a numeric covariance matrix.
stats::cov2cor for scaling a covariance matrix into the corresponding correlation matrix.
# Define standard deviation vector.
sd<-c(9.655,1.157,1.128,2.925)
# Define correlation matrix.
R<-matrix(data=c(1.000,-0.80,0.64,-0.512,
-0.800,1.00,-0.80,0.640,
0.640,-0.80,1.00,-0.800,
-0.512,0.64,-0.80,1.000),
ncol=4,byrow=TRUE)
# Derive covariance matrix.
cor2cov(sd=sd,R=R)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.