Plot regression (predicted values) or probability lines (predicted probabilities) of significant interaction terms to better understand effects of moderations in regression models. This function accepts following fitted model classes:

• linear models (lm)

• generalized linear models (glm)

• linear mixed effects models (lmer)

• generalized linear mixed effects models (glmer)

• non-linear mixed effects models (nlmer)

• linear mixed effects models (lme, but only for type = "eff")

• generalized least squares models (gls, but only for type = "eff")

• panel data estimators (plm)

Note that beside interaction terms, also the single predictors of each interaction (main effects) must be included in the fitted model as well. Thus, lm(dep ~ pred1 * pred2) will work, but lm(dep ~ pred1:pred2) won't!

sjp.int(fit, type = c("eff", "cond"), int.term = NULL,
int.plot.index = NULL, mdrt.values = c("minmax", "meansd", "zeromax",
"quart", "all"), swap.pred = FALSE, plevel = 0.1, diff = FALSE,
title = NULL, axis.title = NULL, legend.title = NULL,
legend.labels = NULL, wrap.title = 50, wrap.legend.labels = 20,
wrap.legend.title = 20, geom.colors = "Set1", geom.size = NULL,
fill.color = "grey", fill.alpha = 0.3, show.values = FALSE,
show.ci = FALSE, jitter.ci = FALSE, p.kr = TRUE, grid.breaks = NULL,
xlim = NULL, ylim = NULL, y.offset = 0.07, digits = 2,
facet.grid = FALSE, prnt.plot = TRUE, ...)

## Arguments

fit A fitted (generalized) linear (mixed) model object, including interaction terms. Accepted model classes are linear models (lm) generalized linear models (glm) linear mixed effects models (lmer) generalized linear mixed effects models (glmer) non-linear mixed effects models (nlmer) linear mixed effects models (lme, but only for type = "eff") generalized least squares models (gls, but only for type = "eff") panel data estimators (plm) Interaction plot type. Use one of following values: type = "eff"(default) plots the overall moderation effect on the response value. See 'Details'. type = "cond"plots the mere change of the moderating effect on the response value (conditional effect). See 'Details'. Name of interaction term of fit (as character), which should be plotted when using type = "eff". By default, this argument will be ignored (i.e. int.term = NULL). See 'Details'. Numeric vector with index numbers that indicate which interaction terms should be plotted in case the fit has more than one interaction. By default, this value is NULL, hence all interactions are plotted. Indicates which values of the moderator variable should be used when plotting the interaction effects. "minmax"(default) minimum and maximum values (lower and upper bounds) of the moderator are used to plot the interaction between independent variable and moderator. "meansd"uses the mean value of the moderator as well as one standard deviation below and above mean value to plot the effect of the moderator on the independent variable (following the convention suggested by Cohen and Cohen and popularized by Aiken and West, i.e. using the mean, the value one standard deviation above, and the value one standard deviation below the mean as values of the moderator, see Grace-Martin K: 3 Tips to Make Interpreting Moderation Effects Easier). "zeromax"is similar to the "minmax" option, however, 0 is always used as minimum value for the moderator. This may be useful for predictors that don't have an empirical zero-value, but absence of moderation should be simulated by using 0 as minimum. "quart"calculates and uses the quartiles (lower, median and upper) of the moderator value. "all"uses all values of the moderator variable. Note that this option only applies to type = "eff", for numeric moderator values. Logical, if TRUE, the predictor on the x-axis and the moderator value in an interaction are swapped. For type = "eff", the first interaction term is used as moderator and the second term is plotted at the x-axis. For type = "cond", the interaction's predictor with less unique values is printed along the x-axis. Default is FALSE, so the second predictor in an interaction, respectively the predictor with more unique values is printed along the x-axis. Numeric, indicates at which p-value an interaction term is considered as significant, i.e. at which p-level an interaction term will be considered for plotting. Default is 0.1 (10 percent), hence, non-significant interactions are excluded by default. This argument does not apply to type = "eff". Logical, if FALSE (default), the minimum and maximum interaction effects of the moderating variable is shown (one line each). if TRUE, only the difference between minimum and maximum interaction effect is shown (single line). Only applies to type = "cond". Default title used for the plots. Should be a character vector of same length as interaction plots to be plotted. Default value is NULL, which means that each plot's title includes the dependent variable as well as the names of the interaction terms. Default title used for the x-axis. Should be a character vector of same length as interaction plots to be plotted. Default value is NULL, which means that each plot's x-axis uses the predictor's name as title. Title of the plot's legend. A character vector of same length as amount of interaction plots to be plotted (i.e. one vector element for each plot's legend title). Labels for the guide/legend. Either a character vector of same length as amount of legend labels of the plot, or a list of character vectors, if more than one interaction plot is plotted (i.e. one vector of legend labels for each interaction plot). Default is NULL, so the name of the predictor with min/max-effect is used as legend label. numeric, determines how many chars of the plot title are displayed in one line and when a line break is inserted. numeric, determines how many chars of the legend labels are displayed in one line and when a line break is inserted. numeric, determines how many chars of the legend's title are displayed in one line and when a line break is inserted. Vector of color values or name of a valid color brewer palette. If not a color brewer palette name, geom.colors must be of same length as moderator values used in the plot (see mdrt.values). See also 'Details' in sjp.grpfrq. size resp. width of the geoms (bar width, line thickness or point size, depending on plot type and function). Note that bar and bin widths mostly need smaller values than dot sizes. Fill color of the shaded area between the minimum and maximum lines. Default is "grey". Either set fill.color to NULL or use 0 for fill.alpha if you want to hide the shaded area. Alpha value (transparancy) of the shaded area between the minimum and maximum lines. Default is 0.4. Use either 0 or set fill.color to NULL if you want to hide the shaded area. Logical, whether values should be plotted or not. Logical, if TRUE), adds notches to the box plot, which are used to compare groups; if the notches of two boxes do not overlap, medians are considered to be significantly different. Logical, if TRUE and show.ci = TRUE and confidence bands are displayed as error bars, adds jittering to lines and error bars to avoid overlapping. logical, if TRUE, p-value estimation is based on conditional F-tests with Kenward-Roger approximation for the df. Caution: Computation may take very long time for large samples! numeric; sets the distance between breaks for the axis, i.e. at every grid.breaks'th position a major grid is being printed. Numeric vector of length two, defining lower and upper axis limits of the x scale. By default, this argument is set to NULL, i.e. the x-axis fits to the required range of the data. numeric vector of length two, defining lower and upper axis limits of the y scale. By default, this argument is set to NULL, i.e. the y-axis fits to the required range of the data. numeric, offset for text labels when their alignment is adjusted to the top/bottom of the geom (see hjust and vjust). Numeric, amount of digits after decimal point when rounding estimates and values. TRUE to arrange the lay out of of multiple plots in a grid of an integrated single plot. This argument calls facet_wrap or facet_grid to arrange plots. Use plot_grid to plot multiple plot-objects as an arranged grid with grid.arrange. logical, if TRUE (default), plots the results as graph. Use FALSE if you don't want to plot any graphs. In either case, the ggplot-object will be returned as value. Other arguments passed down to further functions. Currently, following arguments are supported: ?effects::effectAny arguments accepted by the effect resp. allEffects function, for type = "eff". widthThe width-argument for error bars. alphaThe alpha-argument for confidence bands. levelThe level-argument confidence bands.

## Value

(Insisibily) returns the ggplot-objects with the complete plot-list (plot.list) as well as the data frames that were used for setting up the ggplot-objects (data.list).

## Details

type = "eff"

plots the overall effects (marginal effects) of the interaction, with all remaining covariates set to the mean. Effects are calculated using the effect- function from the effects-package. You can pass further arguments down to allEffects for flexible function call via the ...-argument.

type = "cond"

plots the effective change or impact (conditional effect) on a dependent variable of a moderation effect, as described by Grace-Martin, i.e. the difference of the moderation effect on the dependent variable in presence and absence of the moderating effect (simple slope plot or conditional effect, see Hayes 2012). All remaining predictors are set to zero (i.e. ignored and not adjusted for). Hence, this plot type may be used especially for binary or dummy coded moderator values (see also Esarey and Summer 2015). This type does not show the overall effect (marginal mean, i.e. adjusted for all other predictors and covariates) of interactions on the result of Y. Use type = "eff" for effect displays similar to the effect-function from the effects-package.

The argument int.term only applies to type = "eff" and can be used to select a specific interaction term of the model that should be plotted. The function then calls effect(int.term, fit) to compute effects for this specific interaction term only. This approach is recommended, when the fitted model contains many observations and/or variables, which may slow down the effect-computation dramatically. In such cases, consider computing effects for selected interaction terms only with int.terms. See 'Examples'.

## Note

Note that beside interaction terms, also the single predictors of each interaction (main effects) must be included in the fitted model as well. Thus, lm(dep ~ pred1 * pred2) will work, but lm(dep ~ pred1:pred2) won't!

For type = "eff", predictors of interactions that are introduced first into the model are used as grouping variable, while the latter predictor is printed along the x-axis (i.e. lm(y~a+b+a:b) means that "a" is used as grouping variable and "b" is plotted along the x-axis).