Skip to contents

Get full covariance/correlation matrix from eclairs decomposition

Usage

getCov(ecl, lambda, ...)

getCor(ecl, lambda, ...)

# S4 method for class 'eclairs'
getCov(ecl, lambda, ...)

# S4 method for class 'eclairs'
getCor(ecl, lambda, ...)

Arguments

ecl

eclairs decomposition

lambda

shrinkage parameter for the convex combination.

...

other arguments

Value

p x p covariance/correlation matrix

Details

The full matrix is computationally expensive to compute and uses a lot of memory for large p. So it is better to use decorrelate or mult_eclairs to perform projections in \(O(np)\) time.

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_", seq(n))
colnames(Y) <- paste0("gene_", seq(p))

# eclairs decomposition
ecl <- eclairs(Y)

# extract covariance implied by eclairs decomposition
getCov(ecl)[1:3, 1:3]
#>          gene_1   gene_2   gene_3
#> gene_1 4.897772 4.333904 3.887720
#> gene_2 4.333904 4.916274 4.257193
#> gene_3 3.887720 4.257193 4.927556