Title: | Sparse covariance estimation based on thresholding |
---|---|
Description: | A sparse covariance estimator based on different thresholding operators. |
Authors: | Chenxin Jiang [aut, cre] |
Maintainer: | Chenxin Jiang <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-11-07 04:42:11 UTC |
Source: | https://github.com/chexjiang/sparsecov |
This function construct a covariance matrix with a block diagonal structure.
block.true.cov(p, block.size = 3)
block.true.cov(p, block.size = 3)
p |
The number of variants. |
block.size |
The block size. |
A covariance matrix with a block diagonal structure.
data.true.cov <- block.true.cov(30) data.true.cov[1:9,1:9]
data.true.cov <- block.true.cov(30) data.true.cov[1:9,1:9]
This function select the optimal thresholding level delta
est_delta( data, method = c("cv", "qiu"), operator = c("hard", "soft", "scad", "al") )
est_delta( data, method = c("cv", "qiu"), operator = c("hard", "soft", "scad", "al") )
data |
The data matrix. |
method |
The choice of method to select the optimal threshold level. |
operator |
The choice of thresholding operator. |
The optimal threshold level.
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) ## select the optimal thresholding level delta delta <- est_delta(data, method='cv', operator='scad') delta
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) ## select the optimal thresholding level delta delta <- est_delta(data, method='cv', operator='scad') delta
This function computes the thresholding sparse covariance/correlation estimator with the optimal threshold level.
est_sparseCov( data, method = c("cv", "qiu"), operator = c("hard", "soft", "scad", "al"), corr = TRUE )
est_sparseCov( data, method = c("cv", "qiu"), operator = c("hard", "soft", "scad", "al"), corr = TRUE )
data |
The data matrix. |
method |
The choice of method to select the optimal threshold level. |
operator |
The choice of the thresholding operator. |
corr |
The indicator of computing correlation or covariance matrix. |
The thresholding sparse covariance/correlation estimator.
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) ## compute the thresholding sparse covariance/correlation estimator s <- est_sparseCov(data, method='cv', operator='scad', corr=FALSE) s[1:9, 1:9]
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) ## compute the thresholding sparse covariance/correlation estimator s <- est_sparseCov(data, method='cv', operator='scad', corr=FALSE) s[1:9, 1:9]
This function samples MVN based on a given covariance matrix
sampleMVN(n, Sigma, sparse = TRUE, n_cores = 1, fastmvn = FALSE)
sampleMVN(n, Sigma, sparse = TRUE, n_cores = 1, fastmvn = FALSE)
n |
The sample size. |
Sigma |
The covariance matrix. |
sparse |
The indicator of sparse sampling or not. |
n_cores |
The number of cores used. |
fastmvn |
The indicator of fast sampling or not. |
The data matrix sampled from the covariance matrix.
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) data[1:10, 1:10]
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) data[1:10, 1:10]
This function computes the thresholding sparse covariance estimator for a given threshold level.
thresh_op(z, operator, delta, n)
thresh_op(z, operator, delta, n)
z |
The sample covariance matrix. |
operator |
The choice of the thresholding operator. |
delta |
The thresholding level. |
n |
The sample size of data matrix. |
The thresholding sparse covariance estimator for a given threshold level.
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) ## compute the sample covariance z <- Rfast::cova(data) *(n-1)/n ## get the sparse covariance matrix estimator for a given threshold level s <- thresh_op(z, operator='soft', delta=1, n=n) s[1:9,1:9]
## generate data from a block diagonal covariance matrix structure n <- 50 p <- 30 data.true.cov <- block.true.cov(p) data <- sampleMVN(n, data.true.cov, sparse=TRUE) ## compute the sample covariance z <- Rfast::cova(data) *(n-1)/n ## get the sparse covariance matrix estimator for a given threshold level s <- thresh_op(z, operator='soft', delta=1, n=n) s[1:9,1:9]