# NOT RUN {
# Using a fitted lm model
states <- as.data.frame(state.x77)
states$HSGrad <- states$`HS Grad`
fit <- lm(Income ~ HSGrad + Murder*Illiteracy,
data = states)
interact_plot(model = fit, pred = Murder,
modx = Illiteracy)
# Using interval feature
fit <- lm(accel ~ mag*dist, data=attenu)
interact_plot(fit, pred = mag, modx = dist, interval = TRUE,
int.type = "confidence", int.width = .8)
# Using second moderator
fit <- lm(Income ~ HSGrad*Murder*Illiteracy,
data = states)
interact_plot(model = fit, pred = Murder,
modx = Illiteracy, mod2 = HSGrad)
# 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)
interact_plot(regmodel, pred = ell, modx = meals)
# With lme4
# }
# NOT RUN {
library(lme4)
data(VerbAgg)
mv <- glmer(r2 ~ Anger * mode + (1 | item), data = VerbAgg, family = binomial,
control = glmerControl("bobyqa"))
interact_plot(mv, pred = Anger, modx = mode)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab