Learn R Programming

corpcor (version 1.3.0)

pcor.shrink: Shrinkage Estimates of Partial Correlation and Partial Covariance

Description

The functions pcor.shrink and pcov.shrink provide shrinkage estimates the matrix of partial correlations and partical covariance, respectively.

Usage

pcor.shrink(x, lambda, w, verbose=TRUE)
pcov.shrink(x, lambda, lambda.var, w, verbose=TRUE)

Arguments

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.shri
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
w
optional: weights for each data point - if not specified uniform weights are assumed (w = rep(1/n, n) with n = dim(x)[1]).
verbose
report progress while computing (default: TRUE)

Value

  • pcor.shrink returns the partical correlation matrix. pcov.shrink returns the partial covariance matrix.

Details

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 pcor.shrink(x) is numerically the same as cor2pcor(cor.shrink(x)). However, pcor.shrink is computationally *much* faster. For details about the shrinkage procedure (from Schaefer and Strimmer (2005)) please consult the help page of cov.shrink.

References

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/)

See Also

cov.shrink, cor2pcor

Examples

Run this code
# 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)

Run the code above in your browser using DataLab