interpret.comparisons

interpret.comparisons(
    model,
    idata,
    contrast,
    conditional=None,
    average_by=None,
    comparison_type='diff',
    use_hdi=True,
    prob=None,
    transforms=None,
    sample_new_groups=False,
)

Compute 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)

The predictor name whose contrast we would like to compare.

conditional : (str, list, dict) = 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 | bool | None = None

The covariates we would like to average by. The passed covariate(s) will marginalize over the other covariates in the model. If True, it averages over all covariates in the model to obtain the average estimate. Defaults to None.

comparison_type : str = 'diff'

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

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.rcParams["stats.hdi_prob"] affects this default.

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.

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.

Returns

: pd.DataFrame

A dataframe with the comparison values, highest density interval, contrast name, contrast value, and conditional values.

Raises

: ValueError

If wrt is a dict and length of contrast is greater than 1. If wrt is a dict and length of contrast is greater than 2 and conditional is None. If conditional is None and contrast is categorical with > 2 values. If conditional is a list and the length is greater than 3. If comparison_type is not ‘diff’ or ‘ratio’. If prob is not > 0 and < 1.