interpret.plot_comparisons

interpret.plot_comparisons(
    model,
    idata,
    contrast,
    conditional=None,
    average_by=None,
    comparison_type='diff',
    sample_new_groups=False,
    use_hdi=True,
    prob=None,
    legend=True,
    transforms=None,
    ax=None,
    fig_kwargs=None,
    subplot_kwargs=None,
)

Plot Conditional Adjusted Comparisons

Parameters

model : bambi.Model

The model for which we want to plot the predictions.

idata : arviz.InferenceData

The InferenceData object that contains the samples from the posterior distribution of the model.

contrast : (str, dict, list)

The predictor name whose contrast we would like to compare.

conditional : (str, dict, list) = None

The covariates we would like to condition on. If dict, keys are the covariate names and values are the values to condition on.

average_by : str | list | None = None

The covariates we would like to average by. The passed covariate(s) will marginalize over the other covariates in the model. Defaults to None.

comparison_type : str = 'diff'

The type of comparison to plot. Defaults to ‘diff’.

sample_new_groups : bool = False

If the model contains group-level effects, and data is passed for unseen groups, whether to sample from the new groups. Defaults to False.

use_hdi : bool = True

Whether to compute the highest density interval (defaults to True) or the quantiles.

prob : float = None

The probability for the credibility intervals. Must be between 0 and 1. Defaults to 0.94. Changing the global variable az.rcParam["stats.ci_prob"] affects this default.

legend : bool = True

Whether to automatically include a legend in the plot. Defaults to True.

transforms : dict = None

Transformations that are applied to each of the variables being plotted. The keys are the name of the variables, and the values are functions to be applied. Defaults to None.

ax : matplotlib.axes._subplots.AxesSubplot = None

A matplotlib axes object or a sequence of them. If None, this function instantiates a new axes object. Defaults to None.

fig_kwargs : optional = None

Keyword arguments passed to the matplotlib figure function as a dict. For example, fig_kwargs=dict(figsize=(11, 8)), sharey=True would make the figure 11 inches wide by 8 inches high and would share the y-axis values.

subplot_kwargs : optional = None

Keyword arguments used to determine the covariates used for the horizontal, group, and panel axes. For example, subplot_kwargs=dict(main="x", group="y", panel="z") would plot the horizontal axis as x, the color (hue) as y, and the panel axis as z.

Returns

: (matplotlib.figure.Figure, matplotlib.axes._subplots.AxesSubplot)

A tuple with the figure and the axes.

Raises

: ValueError

If the number of contrast levels is greater than 2 and average_by is None. If conditional and average_by are both None. If length of conditional is greater than 3 and average_by is None. If average_by is True. If main covariate is not numeric or categoric.