pcor.shrink {corpcor} | R Documentation |
The functions pcor.shrink
and pcov.shrink
provide shrinkage estimates
the matrix of partial correlations and partical covariance, respectively.
pcor.shrink(x, lambda, w, verbose=TRUE) pcov.shrink(x, lambda, lambda.var, w, 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) ). |
verbose |
report progress while computing (default: TRUE) |
The partial covariance is simply the inverse of the covariance matrix, with the sign of the off-diagonal elements reversed. The partial correlation matrix is the standardized partial covariance matrix.
Note that using pcor.shrink(x)
much faster than
cor2pcor(cor.shrink(x))
.
For details about the shrinkage procedure consult Schaefer and Strimmer (2005)
and the help page of cov.shrink
.
pcor.shrink
returns the partical correlation matrix.
pcov.shrink
returns the partial covariance matrix.
Juliane Schaefer (http://www.stat.math.ethz.ch/~schaefer/) and Korbinian Strimmer (http://www.statistik.lmu.de/~strimmer/).
Schaefer, J., and Strimmer, K. (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/)
# load corpcor library library("corpcor") # generate data matrix p <- 50 n <- 10 X <- matrix(rnorm(n*p), nrow = n, ncol = p) # partial covariance pco <- pcov.shrink(X) # partial correlations (fast and recommend way) pcr1 <- pcor.shrink(X) # other possibilites to estimate partial correlations pcr2 <- cor2pcor( cor.shrink(X) ) pcr3 <- cov2cor( pco ) # standarize partial covariance # all the same sum((pcr1 - pcr2)^2) sum((pcr2 - pcr3)^2) sum((pcr3 - pcr1)^2)