Perform "extreme deconvolution" (Bovy et al) on a subset of the data

cov_ed(data, Ulist_init, subset = NULL, algorithm = c("bovy", "teem"), ...)

Arguments

data

a mash data object

Ulist_init

a named list of covariance matrices to use to initialize ED; default is to use matrices from PCs

subset

a subset of data to be used when ED is run (set to NULL for all the data)

algorithm

algorithm to run ED

...

other arguments to be passed to ED algorith, see extreme_deconvolution for algorithm 'bovy', or teem_wrapper for algorithm 'teem'

Details

Runs the extreme deconvolution algorithm from Bovy et al (Annals of Applied Statistics) to estimate data-driven covariance matrices. It can be initialized with, for example running cov_pca with, say, 5 PCs.

Examples

data = mash_set_data(Bhat = cbind(c(1,2),c(3,4)), Shat = cbind(c(1,1),c(1,1)))
U_pca = cov_pca(data,2)
U_x = apply(data$Bhat, 2, function(x) x - mean(x))
U_xx = t(U_x) %*% U_x / nrow(U_x)
cov_ed(data,c(U_pca, list(xx = U_xx)))
#> $ED_PCA_1
#>          [,1]      [,2]
#> [1,] 2.987439  5.154809
#> [2,] 5.154809 12.359820
#> 
#> $ED_PCA_2
#>             [,1]        [,2]
#> [1,]  0.71223188 -0.00226719
#> [2,] -0.00226719  0.70810972
#> 
#> $ED_tPCA
#>          [,1]      [,2]
#> [1,] 2.989069  5.154337
#> [2,] 5.154337 12.359898
#> 
#> $ED_xx
#>          [,1]     [,2]
#> [1,] 6.611478 5.904371
#> [2,] 5.904371 6.611478
#>