I am using the PYMC toolbox in python in order to carry out a model selection problem using MCMC. What I would like to have for each model is the marginal log-likelihood (i.e. model evidence).

The question: After I've run my sampler on the model, like

mc = MCMC(myModel)

does the following command return the marginal log-likelihood?


Thanks very much in advance!

  • $\begingroup$ So, it is clear now that the answer to the above is a definite no: lop does not return the marginal log-likelihood. However, I am skeptical as to whether it does really return the log-posterior for the current sample. $\endgroup$ – ngiann Jan 15 '15 at 8:22

No, this returns the log-posterior for the current values of the model parameters. You need to integrate this value over all model parameters to calculate the evidence. Here is a start on a way, and here is a possibly missing) blog on a different way.

  • 1
    $\begingroup$ The first link seems to describe the harmonic mean estimator, which has poor convergence, see radfordneal.wordpress.com/2008/08/17/… $\endgroup$ – Juho Kokkala Jan 13 '15 at 18:33
  • $\begingroup$ Thanks for the answers. The negative answer above is already useful. Though I cannot imagine what a "log-posterior for the current values" means. I know that this is also mentioned in the documentation. I am experienced in Bayesian statistics but have never used MCMC, I try to use variational methods instead when possible. $\endgroup$ – ngiann Jan 14 '15 at 14:25
  • $\begingroup$ So the myModel.logp function returns an approximation to the true log(p(theta|data)) for the last sample theta saved in myModel? $\endgroup$ – ngiann Jan 14 '15 at 19:33
  • $\begingroup$ that is my understanding $\endgroup$ – Abraham D Flaxman Jan 15 '15 at 20:05
  • $\begingroup$ Thanks for your answer Abraham. In danger of breaking etiquette and asking a separate question: how can I calculate the average over all samples and not just the last sample? (I will edit my question above accordingly later.) $\endgroup$ – ngiann Jan 21 '15 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.