mlm_summary: Summary table for a multilevel moderation effect

View source: R/mlm_summary.R

mlm_summaryR Documentation

Summary table for a multilevel moderation effect

Description

Returns a consolidated summary of the moderation effect: the focal interaction coefficient, simple slopes at selected moderator values, and (optionally) the Johnson—Neyman interval. Designed for quick reporting and results sections.

Usage

mlm_summary(
  model,
  pred,
  modx,
  modx.values = c("mean-sd", "quartiles", "tertiles", "custom"),
  at = NULL,
  conf.level = 0.95,
  jn = TRUE,
  alpha = 0.05
)

Arguments

model

An lmerMod object with a two-way interaction between pred and modx.

pred

Character scalar. Focal predictor name.

modx

Character scalar. Moderator name.

modx.values

Moderator value strategy. See mlm_probe().

at

Optional numeric vector of custom moderator values.

conf.level

Confidence level. Default 0.95.

jn

Logical. Include Johnson-Neyman region? Default TRUE.

alpha

Alpha for JN interval. Default 0.05.

Value

An object of class mlm_summary (a list) with components:

  • interaction: one-row data frame for the interaction term.

  • simple_slopes: data frame from mlm_probe().

  • jn: output of mlm_jn() (or NULL if jn = FALSE).

  • Other metadata.

Examples

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_summary(mod, pred = "x", modx = "m")


mlmoderator documentation built on April 4, 2026, 1:07 a.m.