interplot.mlm
is a method to calculate conditional coefficient estimates from the results of multilevel (mixed-effects) regression models with interaction terms.
# S3 method for lmerMod
interplot(
m,
var1,
var2,
plot = TRUE,
steps = NULL,
ci = 0.95,
adjCI = FALSE,
hist = FALSE,
var2_dt = NA,
predPro = FALSE,
var2_vals = NULL,
point = FALSE,
sims = 5000,
xmin = NA,
xmax = NA,
ercolor = NA,
esize = 0.5,
ralpha = 0.5,
rfill = "grey70",
stats_cp = "none",
txt_caption = NULL,
facet_labs = NULL,
...
)
A model object including an interaction term, or, alternately, a data frame recording conditional coefficients.
The name (as a string) of the variable of interest in the interaction term; its conditional coefficient estimates will be plotted.
The name (as a string) of the other variable in the interaction term.
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.
Desired length of the sequence. A non-negative number, which for seq and seq.int will be rounded up if fractional. The default is 100 or the unique categories in the var2
(when it is less than 100. Also see unique
).
A numeric value defining the confidence intervals. The default value is 95% (0.95).
Not working for `lmer` outputs yet.
A logical value indicating if there is a histogram of `var2` added at the bottom of the conditional effect plot.
A numerical value indicating the frequency distribution 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.
A logical value with default of `FALSE`. When the `m` is an object of class `glmerMod` and the argument is set to `TRUE`, the function will plot predicted probabilities at the values given by `var2_vals`.
A numerical value indicating the values the predicted probabilities are estimated, when `predPro` is `TRUE`.
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.
Number of independent simulation draws used to calculate upper and lower bounds of coefficient estimates: lower values run faster; higher values produce smoother curves.
A numerical value indicating the minimum value shown of x shown in the graph. Rarely used.
A numerical value indicating the maximum value shown of x shown in the graph. Rarely used.
A character value indicating the outline color of the whisker or ribbon.
A numerical value indicating the size of the whisker or ribbon.
A numerical value indicating the transparency of the ribbon.
A character value indicating the filling color of the ribbon.
A character value indicating what statistics to present as the plot note. Three options are available: "none", "ci", and "ks". The default is "none". See the Details for more information.
A character string to add a note for the plot, a value will sending to ggplot2::labs(caption = txt_caption))
.
An optional character vector of facet labels to be used when plotting an interaction with a factor variable.
Other ggplot aesthetics arguments for points in the dot-whisker plot or lines in the line-ribbon plots. Not currently used.
The function returns a ggplot
object.
interplot.mlm
is a S3 method from the interplot
. It works on mixed-effects objects with class lmerMod
and glmerMod
.
Because the output function is based on ggplot
, any additional arguments and layers supported by ggplot2
can be added with the +
.
interplot
visualizes the conditional effect based on simulated marginal effects. The simulation provides a probabilistic distribution of moderation effect of the conditioning variable (var2
) at every preset values (including the minimum and maximum values) of the conditioned variable (var1
), denoted as Emin and Emax. This output allows the function to further examine the conditional effect statistically in two ways. One is to examine if the distribution of \(Emax - Emin\) covers zero. The other is to directly compare Emin and Emax through statistical tools for distributional comparisons. Users can choose either method by setting the argument stats_cp
to "ci" or "ks".
"ci" provides the confidence interval of the difference of \(Emax - Emin\). An interval including 0 suggests no statistical difference before and after the conditional effect is applied, and vise versa.
"ks" presents the result of a two-sample Kolmogorov-Smirnov test of the simulated distributions of Emin and Emax. The output includes a D statistics and a p-value of the null hypothesis that the two distributions come from the same distribution at the 0.05 level.
See an illustration in the package vignette.