This is a simple wrapper for the interplot package in R (by Frederick Solt and Yue Hu) that creates clean marginal effects plots with a reference line at the median of the moderating variable. This facilitates better interpretation of marginal effects plots. Currently interplot.medline supports least squares, logit, and probit models.

Install by typing devtools::install_github("tpepinsky/interplot.medline") in your R command line.

The function interplot.medline takes as its arguments a fitted lm or glm object, the name of the variable for which the marginal effects should be calculated, and the name of the moderator. This preserves the same syntax as interplot. It is possible to adjust the width of the confidence intervals using the optional argument ci (default is .95). No other options are supported.

> data(mtcars)
> fit <- lm(mpg ~ wt*cyl)
> interplot.medline(m=fit, var1="cyl", var2="wt")

The output is a ggplot object, which you may further format to your liking.