Skip to contents

Estimate covariance/correlation with low rank and shrinkage from the correlation matrix

Usage

eclairs_corMat(C, n, k = min(n, nrow(C)), lambda = NULL)

Arguments

C

sample correlation matrix between features

n

number of samples used to estimate the sample correlation matrix

k

the rank of the low rank component. Defaults to min of sample size and feature number, min(n, p).

lambda

shrinkage parameter. If not specified, it is estimated from the data.

Value

eclairs object storing:

U:

orthonormal matrix with k columns representing the low rank component

dSq:

eigen-values so that \(U diag(d^2) U^T\) is the low rank component

lambda:

shrinkage parameter \(\lambda\) for the scaled diagonal component

sigma:

standard deviations of input columns

nu:

diagonal value, \(\nu\), of target matrix in shrinkage

n:

number of samples (i.e. rows) in the original data

p:

number of features (i.e. columns) in the original data

k:

rank of low rank component

rownames:

sample names from the original matrix

colnames:

features names from the original matrix

method:

method used for decomposition

call:

the function call

Examples

library(Rfast)

n <- 800 # number of samples
p <- 200 # number of features

# create correlation matrix
Sigma <- autocorr.mat(p, .9)

# draw data from correlation matrix Sigma
Y <- rmvnorm(n, rep(0, p), sigma = Sigma * 5.1, seed = 1)
rownames(Y) <- paste0("sample_", 1:n)
colnames(Y) <- paste0("gene_", 1:p)

# eclairs decomposition
eclairs(Y, compute = "correlation")
#>        Estimate correlation with low rank and shrinkage
#> 
#>   Original data dims: 800 x 200 
#>   Low rank component: 200 
#>   lambda:             0.0265 
#>   nu:                 1 
#>   Avg corr (EB):      0.0832 
#>   Avg corrSq (EB):    0.0402 
#>   logLik:             -117651 

# eclairs decomposition from correlation matrix
eclairs_corMat(cor(Y), n = n)
#>        Estimate correlation with low rank and shrinkage
#> 
#>   Original data dims: 800 x 200 
#>   Low rank component: 200 
#>   lambda:             0.0265 
#>   nu:                 1 
#>   Avg corr (EB):      0.0832 
#>   Avg corrSq (EB):    0.0402 
#>   logLik:             -117651