standardize.cov {GeneTS} | R Documentation |
standardize.cov
takes a covariance matrix and turns it into
a correlation matrix by standardizing each entry with the product of the
corresponding standard deviations (so that all diagonal entries equal 1).
rebuild.cov
takes a correlation matrix and a vector with variances
and reconstructs the corresponding covariance matrix.
standardize.cov(m) rebuild.cov(r, v)
m |
covariance matrix |
r |
correlation matrix |
v |
variance vector |
A matrix (correlation or covariance matrix).
Korbinian Strimmer (http://www.stat.uni-muenchen.de/~strimmer/).
# load GeneTS library library(GeneTS) # first 10 genes from the caulobacter data set data(caulobacter) m <- caulobacter[,1:10] # covariance matrix m.cov <- cov(m) m.cov # variances m.var <- diag(m.cov) m.var # correlation matrix m.cor.1 <- cor(m) m.cor.1 # correlation matrix via covariance matrix m.cor.2 <- standardize.cov(m.cov) m.cor.2 zapsmall(m.cor.1) == zapsmall(m.cor.2) # reconstruct covariance matrix rebuild.cov(m.cor.1, m.var)