probe_interaction.Rd
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, ...)
model  A regression model. The function is tested with 

pred  The name of the predictor variable involved
in the interaction. This can be a bare name or string. Note that it
is evaluated using 
modx  The name of the moderator variable involved
in the interaction. This can be a bare name or string. The same

mod2  Optional. The name of the second moderator
variable involved in the interaction. This can be a bare name or string.
The same 
...  Other arguments accepted by 
The sim_slopes
object created.
The ggplot
object created by
interact_plot
.
This function simply merges the nearlyequivalent arguments needed to call
both sim_slopes
and interact_plot
without the
need for retyping their common arguments. Note that each function is called
separately and they refit 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:
johnson_neyman()
,
sim_margins()
,
sim_slopes()
# 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, modx.values = "plusminus")#> Error in formula(model): object 'fiti' not found# 3way interaction fiti3 < lm(Income ~ Frost * Murder * Illiteracy, data=as.data.frame(state.x77)) probe_interaction(model = fiti3, pred = Murder, modx = Illiteracy, mod2 = Frost, mod2.values = "plusminus")#> Error in formula(model): object 'fiti3' not found# With svyglm if (requireNamespace("survey")) { 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, modx.values = "plusminus", cond.int = TRUE) # 3way 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) }#> Error in formula(model): object 'regmodel' not found