jtools (version 0.4.5)

sim_slopes: Perform a simple slopes analysis

Description

sim_slopes() conducts a simple slopes analysis for the purposes of understanding two- and three-way interaction effects in linear regression.

Usage

sim_slopes(model, pred, modx, mod2 = NULL, modxvals = NULL,
  mod2vals = NULL, centered = NULL, standardize = FALSE,
  cond.int = FALSE, johnson_neyman = TRUE, jnplot = FALSE,
  jnalpha = 0.05, robust = FALSE, robust.type = "HC3", digits = 3,
  n.sd = 1)

Arguments

model

A regression model of type lm or svyglm. It should contain the interaction of interest.

pred

The predictor variable involved in the interaction.

modx

The moderator variable involved in the interaction.

mod2

Optional. The name of the second moderator variable involved in the interaction.

modxvals

For which values of the moderator should simple slopes analysis be performed? Default is NULL. If NULL, then the values will be the customary +/- 1 standard deviation from the mean as well as the mean itself. There is no specific limit on the number of variables provided. Factor variables are not particularly suited to simple slopes analysis, but you could have a numeric moderator with values of 0 and 1 and give c(0,1) to compare the slopes at the different conditions. Two-level factor variables are coerced to numeric 0/1 variables, but are not standardized/centered like they could be if your input data had a numeric 0/1 variable.

mod2vals

For which values of the second moderator should the plot be facetted by? That is, there will be a separate plot for each level of this moderator. Defaults are the same as modxvals.

centered

A vector of quoted variable names that are to be mean-centered. If NULL, all non-focal predictors are centered. If not NULL, only the user-specified predictors are centered. User can also use "none" or "all" arguments. The response variable is not centered unless specified directly.

standardize

Logical. Would you like to standardize the variables that are centered? Default is FALSE, but if TRUE it will standardize variables specified by the centered argument. Note that non-focal predictors are centered when centered = NULL, its default.

cond.int

Should conditional intercepts be printed in addition to the slopes? Default is FALSE.

johnson_neyman

Should the Johnson-Neyman interval be calculated? Default is TRUE. This can be performed separately with johnson_neyman.

jnplot

Should the Johnson-Neyman interval be plotted as well? Default is FALSE.

jnalpha

What should the alpha level be for the Johnson-Neyman interval? Default is .05, which corresponds to a 95% confidence interval.

robust

Logical. If TRUE, computes heteroskedasticity-robust standard errors.

robust.type

Type of heteroskedasticity-robust standard errors to use if robust=TRUE. See details of j_summ for more on options.

digits

How many significant digits after the decimal point should the output contain?

n.sd

How many standard deviations should be used if standardize = TRUE? Default is 1, but some prefer 2.

Value

slopes

A table of coefficients for the focal predictor at each value of the moderator

ints

A table of coefficients for the intercept at each value of the moderator

modxvals

The values of the moderator used in the analysis

mods

A list containing each regression model created to estimate the conditional coefficients.

jn

If johnson_neyman = TRUE, a list of `johnson_neyman` objects from johnson_neyman. These contain the values of the interval and the plots. If a 2-way interaction, the list will be of length 1. Otherwise, there will be 1 `johnson_neyman` object for each value of the 2nd moderator for 3-way interactions.

Details

This allows the user to perform a simple slopes analysis for the purpose of probing interaction effects in a linear regression. Two- and three-way interactions are supported, though one should be warned that three-way interactions are not easy to interpret in this way.

For more about Johnson-Neyman intervals, see johnson_neyman.

The function accepts a lm object and uses it to recompute models with the moderating variable set to the levels requested. svyglm objects are also accepted, though users should be cautioned against using simple slopes analysis with non-linear models (svyglm also estimates linear models).

Factor moderators are coerced to a 0/1 numeric variable and are not centered, even when requested in arguments. To avoid this, modify your data to change the factor to a binary numeric variable. Factors with more than 2 levels trigger an error.

References

Bauer, D. J., & Curran, P. J. (2005). Probing interactions in fixed and multilevel regression: Inferential and graphical techniques. Multivariate Behavioral Research, 40(3), 373-400. http://dx.doi.org/10.1207/s15327906mbr4003_5

Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation analyses for the behavioral sciences (3rd ed.). Mahwah, NJ: Lawrence Erlbaum Associates, Inc.

See Also

interact_plot accepts similar syntax and will plot the results with ggplot.

testSlopes performs a hypothesis test of differences and provides Johnson-Neyman intervals.

simpleSlope performs a similar analysis and can analyze a second moderator.

Other interaction tools: interact_plot, johnson_neyman, probe_interaction

Examples

Run this code
# NOT RUN {
# Using a fitted model as formula input
fiti <- lm(Income ~ Frost + Murder*Illiteracy,
  data=as.data.frame(state.x77))
sim_slopes(model=fiti, pred=Murder, modx=Illiteracy)

# With svyglm
library(survey)
data(api)
dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
regmodel <- svyglm(api00~ell*meals,design=dstrat)
sim_slopes(regmodel, pred = ell, modx = meals)

# 3-way with survey and factor input
regmodel <- svyglm(api00~ell*meals*sch.wide,design=dstrat)
sim_slopes(regmodel, pred = ell, modx = meals, mod2 = sch.wide)

# }

Run the code above in your browser using DataLab