This function plots the adjusted predictions of the outcome (y-axis) against values of one or more predictors.

plot_cap(
  model,
  condition,
  type = "response",
  conf.int = TRUE,
  conf.level = 0.95,
  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.

type

Type(s) of prediction as string or vector This can differ based on the model type, but will typically be a string such as: "response", "link", "probs", or "zero".

conf.int

Logical indicating whether or not to include a confidence interval.

conf.level

The confidence level to use for the confidence interval if conf.int=TRUE. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.

draw

TRUE returns a ggplot2 plot. FALSE returns a data.frame of the underlying data.

Value

A ggplot2 object

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