Skip to content

Nutpie doesn't compute element-wise log-likelihood #150

@AlexAndorra

Description

@AlexAndorra

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions