Learn R Programming

nlshrink (version 1.0.1)

nlshrink_cov: Non-linear shrinkage estimator of population covariance matrix.

Description

nlshrink_cov calls tau_estimate to estimate the population eigenvalues. Note that the eigenvalues of the estimated population covariance matrix are not the same as the non-linear shrinkage estimates of the population eigenvalues. Theoretical and implementation details in references.

Usage

nlshrink_cov(X, k = 0, method = "nlminb", control = list())

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.
method
(Optional) The optimization routine called in tau_estimate. Choices are nlminb (default) and nloptr.
control
(Optional) A list of control parameters. Must correspond to the selected optimization method. See nlminb, nloptr for details.

Value

A numeric positive semi-definite matrix of dimension ncol(X).

References

  • Ledoit, O. and Wolf, M. (2015). Spectrum estimation: a unified framework for covariance matrix estimation and PCA in large dimensions. Journal of Multivariate Analysis, 139(2)
  • Ledoit, O. and Wolf, M. (2016). Numerical Implementation of the QuEST function. arXiv:1601.05870 [stat.CO]

Examples

Run this code
# generate matrix of uniform random variates
X <- matrix(sapply(1:20, function(b) runif(50, max=b)), nrow = 50, ncol = 20)
Sigma <- diag((1:20)^2/12) # true population covariance matrix
nlshrink_X <- nlshrink_cov(X, k=0) # compute non-linear shrinkage estimate
linshrink_X <- linshrink_cov(X, k=0) # compute linear shrinkage estimate
S <- cov(X) # sample covariance matrix

# compare accuracy of estimators (sum of squared elementwise Euclidean distance)
sum((S-Sigma)^2)
sum((nlshrink_X - Sigma)^2)
sum((linshrink_X - Sigma)^2)

Run the code above in your browser using DataLab