Get Percentiles of Posterior Distribution

Is there a way to return the 2.5 and 97.5 percentiles of the posterior distribution instead of the HDI used by default?


Hi, I’m not completely sure what you mean, I think it could be three different things, so I’ll answer all 3.

About az.summary

You can basically customize the columns of az.summary at will and replace any and all of the already present columns. Take a look for example at the last example in arviz.summary — ArviZ dev documentation. Note that you may be using pm.summary instead, and you can continue to do so, both functions are actually the same, pm.summary is an alias to az.summary which is why it has no docs in Stats — PyMC3 3.11.2 documentation and instead links to ArviZ.

About az.hdi

If using InferenceData, you can use idata.posterior.quantile((.025, .975), dim=("chain", "draw")) which will return a result in a very similar format to az.hdi(idata).

About credible interval shown in plots

This one is currently hardcoded to be the hdi, only it’s probability can be changed. It generally can be hidden too.

If you are using plot_forest which basically reports the hdi and doesn’t allow hiding it, you may be interested in using the vlines approach used (multiple times) in A Primer on Bayesian Methods for Multilevel Modeling — PyMC3 3.10.0 documentation to get a very similar looking result. As I commented above, the result of hdi and quantile is formatted in a very similar way, so the code should need minimal modification.

Ahh, so there’s no way to use the traditional credible interval in Arviz’s plots? Oh well. Thanks!

We haven’t added that yet, would you be interested in working on that? We’d be happy to help along all the contributing proces

Is this still open?