TuringLang / MCMCChains.jl

Types and utility functions for summarizing Markov chain Monte Carlo simulations
https://turinglang.org/MCMCChains.jl/
Other
268 stars 28 forks source link

Computed log pointwise predictive density #243

Closed pkroenert closed 4 years ago

pkroenert commented 4 years ago

Hi there, I would like to compute the WAIC information criterion for a fitted Bayesian model.

However, in doing so one has to evaluate the computed log pointwise predictive density, as defined in Eq.(3) in: https://arxiv.org/pdf/1507.04544.pdf

Specifically I don't know how to compute the term:

p(y_i, \theta^s),

which should be the likelihood with the sampled parameter values from the posterior.

How do I compute that with the returned chains from a NUTS() sampling?

Thanks for your help!!!

devmotion commented 4 years ago

Hi!

So it seems you want to compute the elementwise log-likelihoods? In that case probably you should use elementwise_loglikelihoods which @torfjelde just added to DynamicPPL. He also added an example to the ArviZ docs that shows how this function can be used to compute LOO.

pkroenert commented 4 years ago

Thank you very much @devmotion for this fast response and for the links! I will check these out and leave a reply once I see if this works.

torfjelde commented 4 years ago

Following the above example you can also just use ArviZ.waic directly instead of implementing your own, if you'd like :+1:

Also, @devmotion I believe I misremembered when I said I thought "elementwise likelihood` was being used in the literature; I was thinking of "pointwise likelihood" :confused:

devmotion commented 4 years ago

Also, @devmotion I believe I misremembered when I said I thought "elementwise likelihood` was being used in the literature; I was thinking of "pointwise likelihood" confused

We can just rename it to pointwise_loglikelihoods and deprecate elementwise_loglikelihoods :slightly_smiling_face:

torfjelde commented 4 years ago

We can just rename it to pointwise_loglikelihoods and deprecate elementwise_loglikelihoods

Honestly, that sounds like a good idea to me :+1:

torfjelde commented 4 years ago

This can be closed, right?

pkroenert commented 4 years ago

Yes, thanks again!