question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plot_density function doesn't work for predictive prior unless credible interval is specified as 1

See original GitHub issue

Describe the bug When attempt to plot prior predictive distributions using plot_density function, plots show nothin unless credible interval is defined as 1

To Reproduce az.plot_density(prior,credible_interval=1) image

az.plot_density(prior) image

Expected behavior Expected that the plot should only contain the 0.89 credible interval, instead of blank plots

Additional context arviz 0.7.0 pymc3 3.8 matplotlib 3.2.1

also using %matplotlib inline

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aloctavodiacommented, Apr 13, 2020

Thanks for the example. Now I can confirm the issue. I will work on this and keep you posted. In the meantime you can do this:

data = az.from_pymc3(posterior_1, prior=prior, posterior_predictive=posterior_pred_1)

data will be an ArviZ’s InferenceData object

you can then pass it to arviz functions, for example.

az.summary(data)

or az.plot_density(data.prior) or equivalently az.plot_density(data, group=prior) the default group is posterior thus az.plot_density(data) will give you a plot of the posterior.

One tip, you can globally set a few arviz parameters using az.rcParams, so for example you can add az.rcParams["stats.credible_interval"] = 0.89 at the beginning, and then all plots and summaries will use this value instead of the default one (0.94).

My guess about statistical rethinking is because the credible interval of .89 is used by the book even when the most common default value is 0.95. ArviZ and Statistical rethinking both uses non common values to remind user of the arbitrary nature of any default value.

Your report was very good. You clearly stated the problem and the excepted outcome. A reproducible (simple) example always helps.

0reactions
aloctavodiacommented, Nov 16, 2020

Closing as the recommended workflow is to generate the idata object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HW2 Solutions 36-724: Applied Bayesian and Computational ...
a Prior Predictive Distribution. Let p(θ)=1 for ... The posterior of θ given y is ... xa is not integrable on the interval...
Read more >
M538 Mid - RPubs
The prior predictive distribution isn't informative and doesn't agree with the data observed. This is because it hasn't taken into account the observed...
Read more >
Introduction to Bayesian Methods | - Govind G Nair
Introduction. This post will cover the following topics. Differences between Bayesian and Frequentist Approaches; A Simple Bayesian Analysis ...
Read more >
How To Interpret Two Bayesian Credible Intervals
Your particular credible interval is constructed by finding the quantiles such that the tails of the posterior distribution are equiprobable, ...
Read more >
Chapter 2 Bayesian Inference
Conduct a posterior predictive check to examine the fit between the model and the data, i.e., whether the chosen model with the estimated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found