Compute loglikelihood for fitted mash object on new data.

mash_compute_loglik(g, data, algorithm.version = c("Rcpp", "R"))

Arguments

g

A mash object or the fitted_g from a mash object.

data

A set of data on which to compute the loglikelihood.

algorithm.version

Indicate R or Rcpp version

Value

The log-likelihood for data computed using g.

Details

The log-likelihood for each element is \(p(Bhat_j | Shat_j,g,\alpha)\) where \(Bhat_j | B_j, Shat_j \sim N(B_j, Shat_j)\) and \(B_j/Shat_j^\alpha | Shat_j \sim g\).

Examples

simdata = simple_sims(50,5,1)
data = mash_set_data(simdata$Bhat, simdata$Shat)
m = mash(data, cov_canonical(data))
#>  - Computing 200 x 141 likelihood matrix.
#>  - Likelihood calculations took 0.01 seconds.
#>  - Fitting model with 141 mixture components.
#>  - Model fitting took 0.15 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
mash_compute_loglik(m,data)
#> [1] -1599.554