This thread might help "log_likelihood" not found in InferenceData - #4 by karthur
What I’ve done is (probably too) simple:
After calling
idata = pm.sample()
I manually append the log_likelihood calculated using a modified copy of the usual function as I described above: compute_log_likelihood_for_potential
rvs_names = ['potential1'] # etc
idata.add_groups(
dict(
log_likelihood=compute_log_likelihood_for_potential(
idata=idata,
model=model,
var_names=rvs_names,
extend_inferencedata=False,
)
)
)
That’s pretty much it.
For later use in az.compare
, you’ll also want to make sure the log_likelihood variables have the same string name as the observed_data variables