mem_plot: Marginal effects at the mean plots

Description Usage Arguments Details Value Examples

View source: R/memplot.R

Description

An intuitive way of interpreting coefficients in a model: take a typical case or sample, vary the variable of interest, and see how that changes the prediction. Works for categorical and continuous predictors.

Usage

1
2
mem_plot(model, variable, ci = 0.95, plt_range,
  collector = c("typical", "average"))

Arguments

model

a model object with a data slot and a predict() method

variable

a character of the variable of interest

ci

confidence interval range (default 95%)

plt_range

optional vector of length 2 indicating the range to plot over for the x-axis. Defaults to the range of the variable in the data.

collector

"typical" or "average" or an abbreviation thereof. See details.

Details

The 'typical' collector calculates the median values for numeric, and the most common class for categorical predictors. The 'average' collector returns the mean for numeric variables and the reference category for categorical variables.

Value

'ggplot' object with the MEM plot

Examples

1
2
3
mod <- glm(vs ~ drat + qsec, family = "binomial", data = mtcars)
mem_plot(mod, "qsec")
mem_plot(mod, "drat")

vankesteren/memplot documentation built on May 7, 2019, 4:55 p.m.