check the following:
# covariance matrix
V <- var(matrix(rnorm(10*4), 10, 4))
cov2cor(V)
# correlation matrix
R <- cov2cor(V)
# vector of std. dev.
sds <- rnorm(4)^2
R * sds * rep(sds, each = nrow(R))
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Arun Kumar Saha" <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Sent: Monday, May 19, 2008 8:32 AM
Subject: [R] Converting variance covariance matrix to correlation
matrix
Suppose I have a Variance-covariance matrix A. Is there any fast way
to
calculate correlation matrix from 'A' and vice-versa without
emplying any
'for' loop?
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.