
probe_interaction
is a convenience function that allows users to call
both sim_slopes
and interact_plot
with a single
call.
probe_interaction(model, pred, modx, mod2 = NULL, ...)
A regression model of type lm
or svyglm
.
It should contain the interaction of interest.
The predictor variable involved in the interaction.
The moderator variable involved in the interaction.
Optional. The name of the second moderator variable involved in the interaction.
Other arguments accepted by sim_slopes
and
interact_plot
The sim_slopes
object created.
The ggplot
object created by interact_plot
.
This function simply merges the nearly-equivalent arguments needed to call
both sim_slopes
and interact_plot
without the
need for re-typing their common arguments. Note that each function is called
separately and they re-fit a separate model for each level of each moderator;
therefore, the runtime may be considerably longer than the original model
fit. For larger models, this is worth keeping in mind.
Sometimes, you may want different parameters when doing simple slopes analysis
compared to when plotting interaction effects. For instance, it is often
easier to interpret the regression output when variables are standardized;
but plots are often easier to understand when the variables are in their
original units of measure. probe_interaction
does not support
providing different arguments to each function. If that is needed, use
sim_slopes
and interact_plot
directly.
Other interaction tools: interact_plot
,
johnson_neyman
, sim_slopes
# NOT RUN {
# Using a fitted model as formula input
fiti <- lm(Income ~ Frost + Murder*Illiteracy,
data=as.data.frame(state.x77))
probe_interaction(model = fiti, pred = Murder, modx = Illiteracy,
modxvals = "plus-minus")
# 3-way interaction
fiti3 <- lm(Income ~ Frost*Murder*Illiteracy,
data=as.data.frame(state.x77))
probe_interaction(model = fiti3, pred = Murder, modx = Illiteracy,
mod2 = Frost, mod2vals = "plus-minus")
# With svyglm
library(survey)
data(api)
dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
regmodel <- svyglm(api00~ell*meals + sch.wide, design = dstrat)
probe_interaction(model = regmodel, pred = ell, modx = meals,
modxvals = "plus-minus", cond.int = TRUE) # conditional intercepts
# 3-way with survey and factor input
regmodel3 <- svyglm(api00~ell*meals*sch.wide, design = dstrat)
probe_interaction(model = regmodel3, pred = ell, modx = meals, mod2 = sch.wide)
# Can try different configurations of 1st vs 2nd mod
probe_interaction(model = regmodel3, pred = ell, modx = sch.wide, mod2 = meals)
# }
Run the code above in your browser using DataLab