"log_likelihood" not found in InferenceData

Log likelihood values can only be stored automatically for those variables that have been defined with the observed kwarg. You are using pm.Potential which can be used for blackbox likelihood terms but can also be used for any other goal with nothing to do with observed values such as breaking symmetry or imposing extra prior constraints on the parameters.

This is also the reason why you don’t see any warning. Potential terms are not interpreted as observed variables (not they can be by design) and so the issue is not that auto conversion fails but instead that it’s not triggered at all.

If you wish to have pointwise log likelihood data retrieved automatically, you should instead use pm.DensityDist for example, which might require to reformat your log likelihood function. After all, it needs to be somewhat compatible to a distribution and take an observed kwarg. Using a random variable as observed - #5 by OriolAbril covers multiple working ways of calling DensityDist. In your case you do have “proper” observed data, so anything that allows for DensityDist(..., observed=data) should work and trigger the converter to store log likelihood values automatically.

1 Like