Learn R Programming

corpcor (version 1.5.6)

powcor.shrink: Fast Computation of the Power of the Shrinkage Correlation Matrix

Description

The function powcor.shrink efficiently computes the alpha-th power of the shrinkage correlation matrix produced by cor.shrink.

For instance, this function may be used for fast computation of the (inverse) square root of the shrinkage correlation matrix (needed, e.g., for decorrelation).

Usage

powcor.shrink(x, alpha, lambda, w, collapse=FALSE, verbose=TRUE)

Arguments

x
a data matrix
alpha
exponent
lambda
the correlation shrinkage intensity (range 0-1). If lambda is not specified (the default) it is estimated using an analytic formula from Sch"afer and Strimmer (2005) - see cor.shri
w
optional: weights for each data point - if not specified uniform weights are assumed (w = rep(1/n, n) with n = nrow(x)).
collapse
return vector instead of matrix if estimated or specified lambda equals 1.
verbose
output status while computing (default: TRUE)

Value

  • powcor.shrink returns a matrix containing the output from cor.shrink taken to the power alpha.

Details

This function employs a special matrix identity to speed up the computation of the matrix power of the shrinkage correlation matrix (see Zuber and Strimmer 2009 for details).

Apart from a scaling factor the shrinkage correlation matrix computed by cor.shrink takes on the form

$$Z = I_p + V M V^T ,$$

where V M V^T is a multiple of the empirical correlation matrix. Crucially, Z is a matrix of size p times p whereas M is a potentially much smaller matrix of size m times m, where m is the rank of the empirical correlation matrix.

In order to calculate the alpha-th power of Z the function uses the identity

$$Z^\alpha = I_p - V (I_m -(I_m + M)^\alpha) V^T$$

requiring only the computation of the alpha-th power of the m by m matrix $I_m + M$. This trick enables substantial computational savings especially when the number of observations is much smaller than the number of variables. Note that the above identity is related but not identical to the Woodbury matrix identity for inversion of a matrix. For $alpha=-1$ the above identity reduces to

$$Z^{-1} = I_p - V (I_m -(I_m + M)^{-1}) V^T ,$$

whereas the Woodbury matrix identity equals

$$Z^{-1} = I_p - V (I_m + M^{-1})^{-1} V^T .$$

References

Zuber, V., and K. Strimmer. 2009. Gene ranking and biomarker discovery under correlation. Bioinformatics 25:2700-2707. (http://arxiv.org/abs/0902.0751)

See Also

invcor.shrink, cor.shrink, mpower.

Examples

Run this code
# load corpcor library
library("corpcor")

# generate data matrix
p = 500
n = 10
X = matrix(rnorm(n*p), nrow = n, ncol = p)

lambda = 0.23  # some arbitrary lambda

### computing the inverse ###
# slow
system.time(
  (W1 = solve(cor.shrink(X, lambda=lambda)))
)

# very fast
system.time(
  (W2 = powcor.shrink(X, alpha=-1, lambda=lambda))
)

# no difference
sum((W1-W2)^2)

### computing the square root ###

system.time(
  (W1 = mpower(cor.shrink(X, lambda=lambda), alpha=0.5))
)

# very fast
system.time(
  (W2 = powcor.shrink(X, alpha=0.5, lambda=lambda))
)

# no difference
sum((W1-W2)^2)


### computing an arbitrary power (alpha=1.23) ###

system.time(
  (W1 = mpower(cor.shrink(X, lambda=lambda), alpha=1.23))
)

# very fast
system.time(
  (W2 = powcor.shrink(X, alpha=1.23, lambda=lambda))
)

# no difference
sum((W1-W2)^2)

Run the code above in your browser using DataLab