Learn R Programming

rpsychi (version 0.3)

r2cov: Convert correlation matrix into covariance matrix

Description

r2cov converts correlation matrix and sample/unbiased standard deviation into sample/unbiased covariance matrix.

Usage

r2cov(sd, R)

Arguments

sd
a numeric vector contains the sample/unbiased standard deviations
R
a matrix or data frame contains the correlation matrix

Value

  • Return a matrix containing the sample/unbiased covariance matrix.

encoding

UTF-8

Details

This function converts correlation matrix and sample/unbiased standard deviation into sample/unbiased covariance matrix using the following equation: $S = D^{1/2} R D^{1/2}$, where $S$ is a sample/unbiased covariance matrix, $R$ is a correlation matrix, and $D^{1/2}$ is a square matrix with sd on the main diagonal and 0's elsewhere. The length of sd should be equal to the number of rows and columns in R.

References

Toyoda H (1998) Introduction to structural equation modeling (in Japanese) Tokyo: Asakura Publishing.

See Also

svar, ssd, svar, ssd2sd, lower2R

Examples

Run this code
##data(iris) 
x <- iris[,1:4] 
cov(x)
r2cov(sd(x), cor(x)) 

##Toyoda (1998) p.34 
r2cov(sd = sqrt(c(.862, 1.089, 0.606)), 
      R = lower2R(c(.505, -0.077, -.233)))

Run the code above in your browser using DataLab