interpret.plot_slopes

interpret.plot_slopes(
    model,
    idata,
    wrt,
    conditional=None,
    average_by=None,
    eps=0.0001,
    slope='dydx',
    target='mean',
    use_hdi=True,
    prob=az.rcParams['stats.ci_prob'],
    transforms=None,
    sample_new_groups=None,
    fig_kwargs=None,
    subplot_kwargs=None,
)

Plot conditional adjusted slopes.

Parameters

model : Model

The fitted Bambi model.

idata : DataTree

DataTree object containing the posterior samples.

wrt : str or dict

The predictor variable to compute the slope with respect to.

conditional : str, list[str], dict[str, ndarray or list or int or float], or None = None

Variables to condition on for slopes.

average_by : str or list or bool or None = None

Variables to average slopes over.

eps : float = 0.0001

Perturbation size for finite differencing. Default is 1e-4.

slope : Callable[[DataArray, DataArray, DataArray], DataArray] or str = 'dydx'

Slope function or string name. Built-in options: “dydx” (unit/unit), “eyex” (percent/percent), “eydx” (unit/percent), “dyex” (percent/unit). Default is “dydx”.

target : str = 'mean'

Which quantity to extract. "mean" (default) for the posterior of the parent parameter (e.g. "mu"). Pass the response variable name (e.g. "mpg") for posterior predictive samples. Pass a distributional component name (e.g. "sigma") for the posterior of that component.

use_hdi : bool = True

Whether to use highest density interval. Default is True.

prob : float or list[float] = az.rcParams['stats.ci_prob']

Probability or list of probabilities for credible intervals. Default is from arviz rcParams. When a list is provided, nested bands with decreasing opacity are drawn.

transforms : dict or None = None

Dictionary of transformations to apply to predictions before differencing.

sample_new_groups : bool or None = None

Deprecated. Explicit boolean values emit a FutureWarning because new groups will be handled automatically in a future version. The default None preserves the current False behavior during this transition.

fig_kwargs : dict or None = None

Additional keyword arguments for figure customization.

subplot_kwargs : Mapping[str, str] or None = None

Overrides default plotting sequence (main, group, panel).

Returns

: Plot

A seaborn.objects.Plot. In Jupyter notebooks, the plot automatically displays. In scripts, call .show() to display. The returned Plot object can be customized before displaying using method chaining (e.g., .label(), .theme()). In a future version this function will return a matplotlib.figure.Figure.

Raises

ValueError

If more than 3 conditional variables are provided without averaging.