CovEst.hard | R Documentation |
Bickel and Levina (2008) proposed a sparse covariance estimation technique to apply thresholding on off-diagonal elements of
the sample covariance matrix. The entry of sample covariance matrix S_{i,j}=0
if |S_{i,j}|<=\tau
where \tau
is
a thresholding value (thr
). If thr
is rather a vector of regularization parameters, it applies
cross-validation scheme to select an optimal value.
CovEst.hard(X, thr = sqrt(log(ncol(X))/nrow(X)), nCV = 10, parallel = FALSE)
X |
an |
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; |
a named list containing:
a (p\times p)
covariance matrix estimate.
a dataframe containing vector of tested threshold values(thr
) and corresponding cross validation scores(CVscore
).
bickel_covariance_2008CovTools
## generate data from multivariate normal with Identity covariance.
pdim <- 5
data <- matrix(rnorm(10*pdim), ncol=pdim)
## apply 4 different schemes
# mthr is a vector of regularization parameters to be tested
mthr <- exp(seq(from=log(0.1),to=log(10),length.out=10))
out1 <- CovEst.hard(data, thr=0.1) # threshold value 0.1
out2 <- CovEst.hard(data, thr=1) # threshold value 1
out3 <- CovEst.hard(data, thr=10) # threshold value 10
out4 <- CovEst.hard(data, thr=mthr) # automatic threshold checking
## visualize 4 estimated matrices
gcol <- gray((0:100)/100)
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,2), pty="s")
image(out1$S[,pdim:1], col=gcol, main="thr=0.1")
image(out2$S[,pdim:1], col=gcol, main="thr=1")
image(out3$S[,pdim:1], col=gcol, main="thr=10")
image(out4$S[,pdim:1], col=gcol, main="automatic")
par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.