123123
123123

Reputation: 63

Convert a correlation matrix to a covariance matrix in R?

Suppose I have a correlation matrix

A <- matrix(c(1,0.3,-0.5,0.3,1,0.5,-0.5,0.5,1),nrow=3,ncol=3)
> A
     [,1] [,2] [,3]
[1,]  1.0  0.3 -0.5
[2,]  0.3  1.0  0.5
[3,] -0.5  0.5  1.0

is it possible to convert this to a variance covariance matrix in rstudio?

Upvotes: 0

Views: 937

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 269371

If A is an n x n correlation matrix then the covariance matrix is

diag(s) %*% A %*% diag(s)

where s is the n-vector of standard deviations.

Upvotes: 4

Related Questions