Skip to contents

This function approximates the model's marginal likelihood.


mml(x, S = 0, ncores = parallel::detectCores() - 1, recompute = FALSE)



An object of class RprobitB_fit.


The number of prior samples for the prior arithmetic mean estimate. Per default, S = 0. In this case, only the posterior samples are used for the approximation via the posterior harmonic mean estimator, see the details section.


Computation of the prior arithmetic mean estimate is parallelized, set the number of cores.


Set to TRUE to recompute the likelihood.


The object x, including the object mml, which is the model's approximated marginal likelihood value.


The model's marginal likelihood \(p(y\mid M)\) for a model \(M\) and data \(y\) is required for the computation of Bayes factors. In general, the term has no closed form and must be approximated numerically.

This function uses the posterior Gibbs samples to approximate the model's marginal likelihood via the posterior harmonic mean estimator. To check the convergence, call plot(x$mml), where x is the output of this function. If the estimation does not seem to have converged, you can improve the approximation by combining the value with the prior arithmetic mean estimator. The final approximation of the model's marginal likelihood than is a weighted sum of the posterior harmonic mean estimate and the prior arithmetic mean estimate, where the weights are determined by the sample sizes.