Plot Conditional or Marginal PredictionsSource:
Plot predictions on the y-axis against values of one or more predictors (x-axis, colors/shapes, and facets).
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
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. Unspecified variables are held at their mean or mode.
See the "Plots" vignette and website for tutorials and information on how to customize plots:
plot_predictions( model, condition = NULL, by = NULL, type = NULL, vcov = NULL, conf_level = 0.95, transform = NULL, points = 0, rug = FALSE, gray = FALSE, draw = TRUE, ... )
Character vector (max length 3): Names of the predictors to display.
Named list (max length 3): List names correspond to predictors. List elements can be:
Function which returns a numeric vector or a set of unique categorical values
Shortcut strings for common reference values: "minmax", "quartile", "threenum"
1: x-axis. 2: color/shape. 3: facets.
Numeric variables in positions 2 and 3 are summarized by Tukey's five numbers
Character vector (max length 3): Names of the categorical predictors to marginalize across.
1: x-axis. 2: color. 3: facets.
string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model type, but will typically be a string such as: "response", "link", "probs", or "zero". When an unsupported string is entered, the model-specific list of acceptable values is returned in an error message. When
NULL, the default value is used. This default is the first model-related row in the
Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:
FALSE: Do not compute standard errors. This can speed up computation considerably.
TRUE: Unit-level standard errors using the default
String which indicates the kind of uncertainty estimates to return.
Heteroskedasticity and autocorrelation consistent:
Mixed-Models degrees of freedom: "satterthwaite", "kenward-roger"
"OPG". See the
One-sided formula which indicates the name of cluster variables (e.g.,
~unit_id). This formula is passed to the
clusterargument of the
Square covariance matrix
Function which returns a covariance matrix (e.g.,
numeric value between 0 and 1. Confidence level to use to build a confidence interval.
A function applied to unit-level adjusted predictions and confidence intervals just before the function returns results. For bayesian models, this function is applied to individual draws from the posterior distribution, before computing summaries.
Number between 0 and 1 which controls the transparency of raw data points. 0 (default) does not display any points.
TRUE displays tick marks on the axes to mark the distribution of raw data.
FALSE grayscale or color plot
data.frameof the underlying data.
Additional arguments are passed to the
predict()method supplied by the modeling package.These arguments are particularly useful for mixed-effects or bayesian models (see the online vignettes on the
marginaleffectswebsite). Available arguments can vary from model to model, depending on the range of supported arguments by each modeling package. See the "Model-Specific Arguments" section of the
?marginaleffectsdocumentation for a non-exhaustive list of available arguments.