Perform PCA on data and return list of candidate covariance matrices

cov_pca(data, npc, subset = NULL)

Arguments

data

a mash data object

npc

the number of PCs to use

subset

indices of the subset of data to use (set to NULL for all data)

Value

Returns a list of covariance matrices: the npc rank-one covariance matrices based on the first npc PCs, and the rank npc covariance matrix. If flashier did not identify any factors,

NULL is returned.

Examples

data = mash_set_data(Bhat = cbind(c(1,2),c(3,4)), Shat = cbind(c(1,1),c(1,1)))
cov_pca(data,2)
#> $PCA_1
#>           [,1]      [,2]
#> [1,] 0.1636636 0.3699700
#> [2,] 0.3699700 0.8363364
#> 
#> $PCA_2
#>            [,1]       [,2]
#> [1,]  0.8363364 -0.3699700
#> [2,] -0.3699700  0.1636636
#> 
#> $tPCA
#>      [,1] [,2]
#> [1,]  2.5  5.5
#> [2,]  5.5 12.5
#>