invcov.shrink {corpcor} | R Documentation |
The functions invcov.shrink
and invcor.shrink
implement an
algorithm to efficiently compute
the inverses of shrinkage estimates of covariance (cov.shrink
)
and correlation (cor.shrink
).
invcov.shrink(x, lambda, lambda.var, w, protect=0, verbose=TRUE) invcor.shrink(x, lambda, w, protect=0, verbose=TRUE)
x |
a data matrix |
lambda |
the correlation shrinkage intensity (range 0-1).
If lambda is not specified (the default) it is estimated
using an analytic formula from Schaefer and Strimmer (2005)
- see cor.shrink .
For lambda=0 the empirical correlations are recovered. |
lambda.var |
the variance shrinkage intensity (range 0-1).
If lambda.var is not specified (the default) it is estimated
using an analytic formula from Schaefer and Strimmer (2005)
- see var.shrink .
For lambda.var=0 the empirical variances are recovered. |
w |
optional: weights for each data point - if not specified uniform weights are assumed
(w = rep(1/n, n) with n = nrow(x) ). |
protect |
the fraction of correlation components protected against excessive individual component risk (default: 0, no protection by limiting translation) |
verbose |
output status while computing (default: TRUE) |
The trick that allows the fast computation of the inverses of the shrinkage covariance and correlation matrices is the Woodbury matrix identity - see, e.g., http://en.wikipedia.org/wiki/Woodbury_matrix_identity. The key insight from this identity is that for inverting the covariance/correlation shrinkage estimator obtained from a n x p matrix you only need to invert a matrix of the size of the rank of the data matrix (which in "small n, large p" setting may mean substantial savings in computations).
Note: at the moment the algorithmic savings are only available if protect=0
.
invcov.shrink
returns the inverse of the output from cov.shrink
.
invcor.shrink
returns the inverse of the output from cor.shrink
.
Juliane Schaefer (http://www.stat.math.ethz.ch/~schaefer/) and Korbinian Strimmer (http://strimmerlab.org).
Schaefer, J., and K. Strimmer. 2005. A shrinkage approach to large-scale covariance estimation and implications for functional genomics. Statist. Appl. Genet. Mol. Biol.4:32. (http://www.bepress.com/sagmb/vol4/iss1/art32/)
cov.shrink
, pcor.shrink
, cor2pcor
## Not run: # load corpcor library library("corpcor") # generate data matrix p <- 2000 n <- 10 X <- matrix(rnorm(n*p), nrow = n, ncol = p) lambda <- 0.23 # some arbitrary lambda # slow system.time( W1 <- solve(cov.shrink(X, lambda)) ) # very fast system.time( W2 <- invcov.shrink(X, lambda) ) # no difference sum((W1-W2)^2) ## End(Not run)