Learn R Programming

nlshrink (version 1.0.1)

linshrink_cov: Linear-shrinkage estimator of population covariance matrix.

Description

The linear shrinkage estimator of the population covariance matrix is computed by shrinking the sample covariance matrix towards the identity matrix based on a shrinkage factor. Note that the eigenvalues of the population covariance matrix estimate are not the same as the linear shrinkage estimates of population eigenvalues. Details in referenced publication.

Usage

linshrink_cov(X, k = 0)

Arguments

X
A data matrix.
k
(Optional) Non-negative integer less than ncol(X). If k == 0 (default), X is assumed to contain 1 class, which will be centered. If k >= 1, X is assumed to contain k classes, each of which has already been centered.

Value

Population covariance matrix estimate. A square positive semi-definite matrix of dimension ncol(X).

References

  • Ledoit, O. and Wolf, M. (2004). A well-conditioned estimator for large-dimensional covariance matrices. Journal of Multivariate Analysis, 88(2)

Examples

Run this code
linshrink_cov(X = matrix(rnorm(1e4, mean = 5), nrow = 100, ncol = 100)) # 1 class; will be centered
linshrink_cov(X = matrix(rnorm(1e4), nrow = 100, ncol = 100), k = 1) # 1 class; no centering

Run the code above in your browser using DataLab