plot_predictions

plot_predictions

Functions

Name Description
plot_predictions Plot predictions on the y-axis against values of one or more predictors (x-axis, colors, and facets).

plot_predictions

plot_predictions.plot_predictions(
    model,
    condition=None,
    by=False,
    newdata=None,
    vcov=True,
    conf_level=0.95,
    transform=None,
    draw=True,
    wts=None,
)

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

The by argument is used to plot marginal predictions, that is, predictions made on the original data, but averaged by subgroups. This is analogous to using the by argument in the predictions() function. The condition argument is used to plot conditional predictions, that is, predictions made on a user-specified grid. This is analogous to using the newdata argument and datagrid() function in a predictions() 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
condition (str, list, dictionary) Max length : 4. 1: x-axis. 2: color. 3: facet (wrap if no fourth variable, otherwise cols of grid). 4: facet (rows of grid). 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. Names of the categorical predictors to marginalize across. 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