[R] Converting variance covariance matrix to correlation matrix
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon May 19 09:02:09 CEST 2008
Arun Kumar Saha wrote:
> 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?
>
C <- cov2cor(A)
The other way around is ill-defined, but if d is the vector of variances,
d <- sqrt(diag(A))
A <- outer(d, d)*C.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list