arviz.plot_compare

arviz.plot_compare(comp_df, insample_dev=True, plot_standard_error=True, plot_ic_diff=True, order_by_rank=True, figsize=None, textsize=None, labeller=None, plot_kwargs=None, ax=None, backend=None, backend_kwargs=None, show=None)[source]

Summary plot for model comparison.

This plot is in the style of the one used in the book Statistical Rethinking (Chapter 6) by Richard McElreath.

Parameters
comp_dfpd.DataFrame

Result of the az.compare() method

insample_devbool, optional

Plot in-sample deviance, that is the value of the information criteria without the penalization given by the effective number of parameters (pIC). Defaults to True

plot_standard_errorbool, optional

Plot the standard error of the information criteria estimate. Defaults to True

plot_ic_diffbool, optional
Plot standard error of the difference in information criteria between each model

and the top-ranked model. Defaults to True

order_by_rankbool

If True (default) ensure the best model is used as reference.

figsizetuple, optional

If None, size is (6, num of models) inches

textsize: float

Text size scaling factor for labels, titles and lines. If None it will be autoscaled based on figsize.

labellerlabeller instance, optional

Class providing the method model_name_to_str to generate the labels in the plot. Read the Label guide for more details and usage examples.

plot_kwargsdict, optional

Optional arguments for plot elements. Currently accepts ‘color_ic’, ‘marker_ic’, ‘color_insample_dev’, ‘marker_insample_dev’, ‘color_dse’, ‘marker_dse’, ‘ls_min_ic’ ‘color_ls_min_ic’, ‘fontsize’

ax: axes, optional

Matplotlib axes or bokeh figures.

backend: str, optional

Select plotting backend {“matplotlib”,”bokeh”}. Default “matplotlib”.

backend_kwargs: bool, optional

These are kwargs specific to the backend being used. For additional documentation check the plotting method of the backend.

showbool, optional

Call backend show function.

Returns
axesmatplotlib axes or bokeh figures

Notes

Defaults to comparing Leave-one-out (psis-loo) if present in comp_df column, otherwise compares Widely Applicable Information Criterion (WAIC)

Examples

Show default compare plot

>>> import arviz as az
>>> model_compare = az.compare({'Centered 8 schools': az.load_arviz_data('centered_eight'),
>>>                  'Non-centered 8 schools': az.load_arviz_data('non_centered_eight')})
>>> az.plot_compare(model_compare)
../../_images/arviz-plot_compare-1.png

Plot standard error and information criteria difference only

>>> az.plot_compare(model_compare, insample_dev=False)
../../_images/arviz-plot_compare-2.png