probe_interaction | R Documentation |
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 |
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.
simslopes |
The |
interactplot |
The |
Jacob Long jacob.long@sc.edu
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 = "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, mod2.values = "plus-minus")
# 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 = "plus-minus", cond.int = TRUE)
# 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.