| mlm_jn | R Documentation |
Computes the Johnson—Neyman (JN) interval: the region(s) of the moderator
(modx) where the simple slope of pred transitions between statistical
significance and non-significance. Useful for identifying exactly at which
moderator values an effect becomes significant.
mlm_jn(model, pred, modx, alpha = 0.05, modx.range = NULL, grid = 200L)
model |
An |
pred |
Character scalar. Focal predictor name. |
modx |
Character scalar. Moderator name. |
alpha |
Significance level. Default |
modx.range |
Numeric vector of length 2 giving the range over which to
evaluate the slope. Defaults to the observed range of |
grid |
Integer. Number of points at which to evaluate the slope across
the moderator range. Default |
An object of class mlm_jn with components:
jn_bounds: numeric vector of moderator values where the slope crosses
the significance threshold. NA if no finite region exists.
slopes_df: data frame of slope estimates and significance across the
grid.
pred, modx, alpha, modx.range.
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"))
jn <- mlm_jn(mod, pred = "x", modx = "m")
print(jn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.