Skip to contents

Shrinkage of the covariance matrix according to Schäfer and Strimmer (2005).

Usage

shrink_estim(x, mse = TRUE)

Arguments

x

A numeric matrix containing the in-sample residuals or validation errors.

mse

If TRUE (default), the residuals used to compute the covariance matrix are not mean-corrected.

Value

A shrunk covariance matrix.

References

Schäfer, J.L. and Strimmer, K. (2005), A shrinkage approach to large-scale covariance matrix estimation and implications for functional genomics, Statistical Applications in Genetics and Molecular Biology, 4, 1. doi:10.2202/1544-6115.1175

Examples

set.seed(123)
# Simulated in-sample residuals: 50 observations of a 4-variate process
res <- matrix(rnorm(50 * 4), nrow = 50, ncol = 4)
# Schafer-Strimmer shrunk covariance matrix
shr <- shrink_estim(res)
# Shrinkage intensity selected by the procedure
attr(shr, "lambda")
#> [1] 1