# NOT RUN {
# 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
# slow
system.time(
(W1 = solve(cov.shrink(X, lambda)))
)
# very fast
system.time(
(W2 = invcov.shrink(X, lambda))
)
# no difference
sum((W1-W2)^2)
# }
Run the code above in your browser using DataLab