Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from_cmdstanpy uses posterior in place of prior when both provided #1594

Closed
jburos opened this issue Mar 4, 2021 · 3 comments · Fixed by #1595 or #1598
Closed

from_cmdstanpy uses posterior in place of prior when both provided #1594

jburos opened this issue Mar 4, 2021 · 3 comments · Fixed by #1595 or #1598

Comments

@jburos
Copy link
Contributor

jburos commented Mar 4, 2021

Describe the bug
I'm seeing some odd behavior on a branch of arviz when using from_cmdstanpy. Basically, if I fit a model twice using cmdstanpy & construct the az.InferenceData object using both the prior & the posterior samples, I see that the posterior draws are in both the prior & posterior groups.

In other words, say I construct my arviz InferenceData object as follows:

idata = az.from_cmdstanpy(posterior_fit, 
    prior = prior_fit, 
    coords = dict(school=["A", "B", "C", "D", "E", "F", "G", "H"]), 
    dims = dict(
        theta=["school"],
        y=["school"],
        log_lik=["school"],
        y_hat=["school"],
        theta_tilde=["school"],
    ),
    posterior_predictive = ["y_hat"],
    prior_predictive = ['y_hat'],
    log_likelihood = ["log_lik"])

The draws for the prior & posterior are identical.

all(idata.prior == idata.posterior)
> True

Notably, this is not the case for the predicted quantities:

all(idata.prior_predictive == idata.posterior_predictive)
> False

To Reproduce
I have set up a reproducible example here: https://gist.github.com/jburos/b8839b7919455d6a0019d7ce33394c2f

Expected behavior
The prior draws should be saved in the prior group.

Additional context

I had installed arviz from the cmdstanpy branch, due to previous bugs. I was on commit d95e976, according to my Pipfile.lock.

My system:

In [3]: sys.version
Out[3]: '3.8.7 (default, Feb  3 2021, 06:31:03) \n[Clang 12.0.0 (clang-1200.0.32.29)]'
In [5]: arviz.__version__
Out[5]: '0.11.2'
@ahartikainen
Copy link
Contributor

Thanks for the info. There were couple of typos.

#1595

@jburos
Copy link
Contributor Author

jburos commented Mar 4, 2021

Linking to a comment on the PR, i'm still seeing this bug on a fit from the main branch. I'm on cmdstanpy v 0.9.68.

There is one more typo that needs to be resolved.

@OriolAbril OriolAbril reopened this Mar 4, 2021
@OriolAbril
Copy link
Member

Thanks for double checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants