| mlm_probe | R Documentation |
Computes simple slopes of a focal predictor (pred) at selected values of a
moderator (modx) from a two-level mixed-effects model fitted with
lme4::lmer(). Returns estimates, standard errors, t-values, p-values,
and confidence intervals in a tidy data frame.
mlm_probe(
model,
pred,
modx,
modx.values = c("mean-sd", "quartiles", "tertiles", "custom"),
at = NULL,
conf.level = 0.95
)
model |
An |
pred |
Character scalar. Name of the focal predictor variable. |
modx |
Character scalar. Name of the moderator variable. |
modx.values |
Strategy for selecting moderator values. One of:
|
at |
Numeric vector of custom moderator values. Used when
|
conf.level |
Confidence level for intervals. Default |
An object of class mlm_probe (a list) with components:
slopes: a data frame with columns modx_value, slope, se, t,
df, p, ci_lower, ci_upper.
pred, modx: names of the predictor and moderator.
modx.values: the strategy used.
conf.level: the confidence level.
model: the original model (stored for downstream use).
set.seed(1)
dat <- data.frame(
y = rnorm(200), x = rnorm(200),
m = rep(rnorm(20), each = 10),
grp = factor(rep(1:20, each = 10))
)
dat$y <- dat$y + dat$x * dat$m
mod <- lme4::lmer(y ~ x * m + (1 | grp), data = dat,
control = lme4::lmerControl(optimizer = "bobyqa"))
mlm_probe(mod, pred = "x", modx = "m")
mlm_probe(mod, pred = "x", modx = "m", modx.values = "quartiles")
mlm_probe(mod, pred = "x", modx = "m", modx.values = "custom", at = c(-1, 0, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.