plot_comparisons

plot_comparisons

Functions

Name Description
plot_comparisons Plot comparisons on the y-axis against values of one or more predictors (x-axis, colors/shapes, and facets).

plot_comparisons

plot_comparisons.plot_comparisons(
    model,
    condition=None,
    variables=None,
    newdata=None,
    comparison='difference',
    vcov=True,
    conf_level=0.95,
    by=False,
    wts=None,
    draw=True,
    hypothesis=None,
    equivalence=None,
    transform=None,
    eps=0.0001,
)

Plot comparisons on the y-axis against values of one or more predictors (x-axis, colors/shapes, and facets).

The by argument is used to plot marginal comparisons, that is, comparisons made on the original data, but averaged by subgroups. This is analogous to using the by argument in the comparisons() function.

The condition argument is used to plot conditional comparisons, that is, comparisons made on a user-specified grid. This is analogous to using the newdata argument and datagrid() function in a comparisons() call.

All unspecified variables are held at their mean or mode. This includes grouping variables in mixed-effects models, so analysts who fit such models may want to specify the groups of interest using the variables argument, or supply model-specific arguments to compute population-level estimates. See details below.

See the “Plots” vignette and website for tutorials and information on how to customize plots: - https://marginaleffects.com/articles/plot.html - https://marginaleffects.com

Parameters

Name Type Description Default
model object Model object. required
variables (str, list, dictionary) Name of the variable whose contrast we want to plot on the y-axis. Refer to the comparisons() documentation. None
condition (str, list, dictionary) Max length : 3. 1: x-axis. 2: color. 3: facets. list : Names of the predictors to display Numeric variables in position 1 is summarized by 100 numbers Numeric variables in positions 2 and 3 are summarized by Tukey’s five numbers dictionary : Keys correspond to predictors. Values are numeric vectors. - Series of lists of the same type as the original variable. - Numeric variables: - Series or list of numeric values. - String: “minmax”, “threenum”, “fivenum”. None
by (bool, str, list) Max length : 3. 1: x-axis. 2: color. 3: facets. Aggregate unit-level estimates (aka, marginalize, average over). False
newdata dataframe When newdata is NULL, the grid is determined by the condition argument. When newdata is not NULL, the argument behaves in the same way as in the predictions() function. None
wts None
transform Callable A function applied to unit-level adjusted predictions and confidence intervals just before the function returns results, by default None. None
draw True returns a matplotlib plot. False returns a dataframe of the underlying data. True