Title: | Sparse Covariance Estimation Based on Thresholding |
Version: | 0.0.1 |
Description: | A sparse covariance estimator based on different thresholding operators. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
Imports: | Matrix, methods, mvnfast, Rfast, sparseMVN, stats |
URL: | https://github.com/chexjiang/sparseCov |
NeedsCompilation: | no |
Packaged: | 2024-04-10 11:43:58 UTC; chenxinjiang |
Author: | Chenxin Jiang [aut, cre] |
Maintainer: | Chenxin Jiang <cflorajiang@g.ucla.edu> |
Repository: | CRAN |
Date/Publication: | 2024-04-10 16:50:02 UTC |
This function construct a covariance matrix with a block diagonal structure.
Description
This function construct a covariance matrix with a block diagonal structure.
Usage
block.true.cov(p, block.size = 3)
Arguments
p |
The number of variants. |
block.size |
The block size. |
Value
A covariance matrix with a block diagonal structure.
Examples
data.true.cov <- block.true.cov(30)
data.true.cov[1:9,1:9]
This function select the optimal thresholding level delta
Description
This function select the optimal thresholding level delta
Usage
est_delta(
data,
method = c("cv", "qiu"),
operator = c("hard", "soft", "scad", "al")
)
Arguments
data |
The data matrix. |
method |
The choice of method to select the optimal threshold level. |
operator |
The choice of thresholding operator. |
Value
The optimal threshold level.
Examples
## 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')
This function computes the thresholding sparse covariance/correlation estimator with the optimal threshold level.
Description
This function computes the thresholding sparse covariance/correlation estimator with the optimal threshold level.
Usage
est_sparseCov(
data,
method = c("cv", "qiu"),
operator = c("hard", "soft", "scad", "al"),
corr = TRUE
)
Arguments
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. |
Value
The thresholding sparse covariance/correlation estimator.
Examples
## 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)
This function samples MVN based on a given covariance matrix
Description
This function samples MVN based on a given covariance matrix
Usage
sampleMVN(n, Sigma, sparse = TRUE, n_cores = 1, fastmvn = FALSE)
Arguments
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. |
Value
The data matrix sampled from the covariance matrix.
Examples
## 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.
Description
This function computes the thresholding sparse covariance estimator for a given threshold level.
Usage
thresh_op(z, operator, delta, n)
Arguments
z |
The sample covariance matrix. |
operator |
The choice of the thresholding operator. |
delta |
The thresholding level. |
n |
The sample size of data matrix. |
Value
The thresholding sparse covariance estimator for a given threshold level.
Examples
## 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]