Best way to multiple a term to the log-likelihood

Hi,
I want to calculate the WBIC, which requires multiplying the log-likelihood of the model with a constant. In Stan, it is very easy to do this. For PyMC, I can think of a way by defining a custom distribution with a modified log-likelihood for every distribution needed in the likelihood.
This can be tedious if the likelihood requires many distributions. Does anyone know an easier way to multiplying the log-likelihood with a constant? Or is there any plan for implementing such a feature as in Stan?

Welcome!

If you call pm.sample() with idata_kwargs={"log_likelihood": True}), then the log likelihoods are just sitting in the returned inferenceData object. Does that help?

1 Like

Thanks! I should have written that I want to generate MCMC samples from a posterior in which the log-likelihood is multiplied by a constant, i.e., a tempered version of the original likelihood function.
After looking back at my model, the cost of implementing a custom distribution for each distribution needed in the likelihood is not that much. So I think I will go with that method.

It’s not clear to me what exactly you are looking to do. But if you simply want to “adjust” the likelihood, you can check out pm.Potential() and see if that helps at all/

The custom sampler is the right approach. Potential doesn’t allow for a temperature parameter that changes over draws