arviz_plots.plot_ppc_interval

arviz_plots.plot_ppc_interval#

arviz_plots.plot_ppc_interval(dt, var_names=None, filter_vars=None, group='posterior_predictive', coords=None, sample_dims=None, point_estimate=None, ci_kind=None, ci_probs=None, plot_collection=None, backend=None, labeller=None, aes_by_visuals=None, visuals=None, stats=None, **pc_kwargs)[source]#

Plot posterior predictive intervals with observed data overlaid.

Displays observed data as a point and predicted data as a point estimate plus two credible intervals.

Parameters:
dtxarray.DataTree

Input data. It should contain the posterior_predictive and observed_data groups.

var_namesstr or list of str, optional

One or more variables to be plotted. Prefix the variables by ~ when you want to exclude them from the plot.

filter_vars{None, “like”, “regex”}, default=None

If None, interpret var_names as the real variables names. If “like”, interpret var_names as substrings of the real variables names. If “regex”, interpret var_names as regular expressions on the real variables names.

groupstr

Group to be plotted. Defaults to “posterior_predictive”. It could also be “prior_predictive”.

coordsdict, optional

Coordinates of var_names to be plotted.

sample_dimsstr or sequence of hashable, optional

Dimensions to reduce unless mapped to an aesthetic. Defaults to rcParams["data.sample_dims"]

point_estimate{“mean”, “median”, “mode”}, optional

Which point estimate to plot for the predictive distribution. Defaults to rcParam stats.point_estimate.

ci_kind{“hdi”, “eti”}, optional

Which credible interval to use. Defaults to rcParams["stats.ci_kind"].

ci_probs(float, float), optional

Indicates the probabilities for the inner (twig) and outer (trunk) credible intervals. Defaults to (0.5, rcParams["stats.ci_prob"]). It’s assumed that ci_probs[0] < ci_probs[1], otherwise they are sorted.

plot_collectionPlotCollection, optional
backend{“matplotlib”, “bokeh”, “plotly”, “none”}, optional
labellerlabeller, optional
aes_by_visualsmapping of {strsequence of str or False}, optional

Mapping of visuals to aesthetics that should use their mapping in plot_collection when plotted.

visualsmapping of {strmapping or bool}, optional

Valid keys are:

  • trunk, twig -> passed to ci_bound_y

  • observed_markers -> passed to point_y

  • prediction_markers -> passed to point_y

  • xlabel -> passed to labelled_x

  • ylabel -> passed to labelled_y

  • title -> passed to labelled_title defaults to False

statsmapping, optional

Valid keys are:

  • trunk, twig -> passed to eti or hdi

  • point_estimate -> passed to mean, median or mode

**pc_kwargs

Passed to arviz_plots.PlotCollection.grid

Returns:
PlotCollection

See also

plot_ppc_dist

Plot 1D marginals for the posterior/prior predictive and observed data.

plot_ppc_rootogram

Plot ppc rootogram for discrete (count) data

plot_forest

Plot forest plot for posterior/prior groups.

Examples

Plot posterior predictive intervals for the radon dataset, with custom styling.

>>> from arviz_base import load_arviz_data
>>> import arviz_plots as azp
>>> azp.style.use("arviz-variat")
>>> data = load_arviz_data("rugby")
>>> pc = azp.plot_ppc_interval(data)
../../_images/arviz_plots-plot_ppc_interval-1.png