nutpie: Nutpie doesn't compute element-wise log-likelihood
The elemwise log-likelihood is not stored in the InferenceData that nutpie returns, even when asking for it. The following for instance doesn’t error out, but doesn’t add a log_likelihood group to the trace (whereas it does when using the default PyMC sampler):
y = np.array([28, 8, -3, 7, -1, 1, 18, 12])
sigma = np.array([15, 10, 16, 11, 9, 11, 10, 18])
J = len(y)
with pm.Model() as pooled:
mu = pm.Normal("mu", 0, sigma=10)
obs = pm.Normal("obs", mu, sigma=sigma, observed=y)
trace_p = pm.sample(nuts_sampler="nutpie", idata_kwargs={"log_likelihood": True}) # doesn't store
trace_p_ = pm.sample(idata_kwargs={"log_likelihood": True}) # does store
In PyMC it’s not that big of a deal (although it adds friction to the user workflow), as one can just do:
with pooled:
pm.compute_log_likelihood(trace_p)
But that may be a small issue for Bambi users, which are usually less advanced (cc @tomicapretto). They’d have to do pooled.compute_log_likelihood(trace_p), which takes much more time to compute
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (9 by maintainers)
No worries 😃
Ah yes, @aseyboldt that does work. Sorry, I did not see that in @AlexAndorra’s original post. I have always passed it through
idata_kwargsso I didn’t even think to compute it directly . Thanks!I am also struggling with this issue. I am using the nutpie sampler and I would like to perform some model comparison. Is this issue mentioned
I am more of a user and feeling like I’m in the same boat as @djlacombe in terms of having the right skills. Is the above issue regarding this function:
https://github.com/pymc-devs/nutpie/blob/3328f64c9c4fe415688e53867227bb1024409fd9/python/nutpie/compile_pymc.py#L447
I am not sure what it means to add as deterministic outside of the model declaration.
TBH I am not really sure where to begin with this issue but I would love to be able to perform model comparison sometime soon.
#74 is related.
Thanks for reminding me. Sounds like we should add the elemwise logp values as a deterministics (based on an argument to the compilation function). Then we can sort the results into the correct arviz section after sampling.