Learn R Programming

CovTools (version 0.5.0)

CovEst.adaptive: Covariance Estimation via Adaptive Thresholding

Description

Cai and Liu (2011) proposed an adaptive variant of Bickel and Levina (2008) - CovEst.hard. The idea of adaptive thresholding is to apply thresholding technique on correlation matrix in that it becomes adaptive in terms of each variable.

Usage

CovEst.adaptive(X, thr = 0.5, nCV = 10, parallel = FALSE)

Arguments

X

an \((n\times p)\) matrix where each row is an observation.

thr

user-defined threshold value. If it is a vector of regularization values, it automatically selects one that minimizes cross validation risk.

nCV

the number of repetitions for 2-fold random cross validations for each threshold value.

parallel

a logical; TRUE to use half of available cores, FALSE to do every computation sequentially.

Value

a named list containing:

S

a \((p\times p)\) covariance matrix estimate.

CV

a dataframe containing vector of tested threshold values(thr) and corresponding cross validation scores(CVscore).

References

cai_adaptive_2011CovTools

Examples

Run this code
# NOT RUN {
## generate data from multivariate normal with Identity covariance.
data <- mvtnorm::rmvnorm(10, sigma=diag(10))

## apply 4 different schemes
#  mthr is a vector of regularization parameters to be tested
mthr <- seq(from=0.01,to=0.99,length.out=10)

out1 <- CovEst.adaptive(data, thr=0.1)  # threshold value 0.1
out2 <- CovEst.adaptive(data, thr=0.5)  # threshold value 0.5
out3 <- CovEst.adaptive(data, thr=0.5)  # threshold value 0.9
out4 <- CovEst.adaptive(data, thr=mthr) # automatic threshold checking

## visualize 4 estimated matrices
par(mfrow=c(2,2), pty="s")
image(pracma::flipud(out1$S), col=gray((0:100)/100), main="thr=0.1")
image(pracma::flipud(out2$S), col=gray((0:100)/100), main="thr=0.5")
image(pracma::flipud(out3$S), col=gray((0:100)/100), main="thr=0.9")
image(pracma::flipud(out4$S), col=gray((0:100)/100), main="automatic")

# }

Run the code above in your browser using DataLab