Learn R Programming

interplot (version 0.1.2.1)

interplot.default: Plot Conditional Coefficients in (Generalized) Linear Models with Interaction Terms

Description

interplot.default is a method to calculate conditional coefficient estimates from the results of (generalized) linear regression models with interaction terms.

Usage

"interplot"(m, var1, var2, plot = TRUE, hist = FALSE, var2_dt = NA, point = FALSE, sims = 5000, xmin = NA, xmax = NA, ercolor = NA, esize = 0.5, ralpha = 0.5, rfill = "grey70", ...)

Arguments

m
A model object including an interaction term, or, alternately, a data frame recording conditional coefficients.
var1
The name (as a string) of the variable of interest in the interaction term; its conditional coefficient estimates will be plotted.
var2
The name (as a string) of the other variable in the interaction term.
plot
A logical value indicating whether the output is a plot or a dataframe including the conditional coefficient estimates of var1, their upper and lower bounds, and the corresponding values of var2.
hist
A logical value indicating if there is a histogram of `var2` added at the bottom of the conditional effect plot.
var2_dt
A numerical value indicating the frequency distibution of `var2`. It is only used when `hist == TRUE`. When the object is a model, the default is the distribution of `var2` of the model.
point
A logical value determining the format of plot. By default, the function produces a line plot when var2 takes on ten or more distinct values and a point (dot-and-whisker) plot otherwise; option TRUE forces a point plot.
sims
Number of independent simulation draws used to calculate upper and lower bounds of coefficient estimates: lower values run faster; higher values produce smoother curves.
xmin
A numerical value indicating the minimum value shown of x shown in the graph. Rarely used.
xmax
A numerical value indicating the maximum value shown of x shown in the graph. Rarely used.
ercolor
A character value indicating the outline color of the whisker or ribbon.
esize
A numerical value indicating the size of the whisker or ribbon.
ralpha
A numerical value indicating the transparency of the ribbon.
rfill
A character value indicating the filling color of the ribbon.
...
Other ggplot aesthetics arguments for points in the dot-whisker plot or lines in the line-ribbon plots. Not currently used.

Value

The function returns a ggplot object.

Details

interplot.default is a S3 method from the interplot. It works on two classes of objects:
  • Ordinary linear models (object class: lm);
  • Generalized linear models (object class: glm).

Because the output function is based on ggplot, any additional arguments and layers supported by ggplot2 can be added with the +.