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

Description Usage Arguments Value References Examples

View source: R/nlshrink_cov.R

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

1
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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)

nlshrink documentation built on May 1, 2019, 8:42 p.m.