This function plots adjusted predictions (y-axis) against values of one or more predictors (x-axis and colors).

## Usage

plot_cap(
model,
condition = NULL,
type = "response",
vcov = NULL,
conf_level = 0.95,
transform_post = NULL,
draw = TRUE,
...
)

## Arguments

model

Model object

condition

String or vector of two strings. The first is a variable name to be displayed on the x-axis. The second is a variable whose values will be displayed in different colors. Other numeric variables are held at their means. Other categorical variables are held at their modes. Other numeric variables are held at their means.

type

string indicates the type (scale) of the predictions used to compute marginal effects or contrasts. 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 type is NULL, the default value is used. This default is the first model-related row in the marginaleffects:::type_dictionary dataframe.

vcov

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 vcov(model) variance-covariance matrix.

• String which indicates the kind of uncertainty estimates to return.

• Heteroskedasticity-consistent: "HC", "HC0", "HC1", "HC2", "HC3", "HC4", "HC4m", "HC5". See ?sandwich::vcovHC

• Heteroskedasticity and autocorrelation consistent: "HAC"

• Mixed-Models degrees of freedom: "satterthwaite", "kenward-roger"

• Other: "NeweyWest", "KernHAC", "OPG". See the sandwich package documentation.

• One-sided formula which indicates the name of cluster variables (e.g., ~unit_id). This formula is passed to the cluster argument of the sandwich::vcovCL function.

• Square covariance matrix

• Function which returns a covariance matrix (e.g., stats::vcov(model))

conf_level

numeric value between 0 and 1. Confidence level to use to build a confidence interval.

transform_post

(experimental) 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.

draw

TRUE returns a ggplot2 plot. FALSE returns a data.frame of 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 marginaleffects website). 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 ?marginaleffects documentation for a non-exhaustive list of available arguments.

## Value

A ggplot2 object

Other plot: plot.marginaleffects(), plot_cco(), plot_cme()

## Examples

mod <- lm(mpg ~ hp + wt, data = mtcars)
plot_cap(mod, condition = "wt")

mod <- lm(mpg ~ hp * wt * am, data = mtcars)
plot_cap(mod, condition = c("hp", "wt"))