GitHub

This R package implements a robust implementation of information-theoretic moderation analysis using multimodel inference based on Akaike's Information Criterion (AIC and AICc). The package allows researchers to compare alternative moderation models and avoid spurious moderation effects arising from nonlinear relationships.

library(ModLR)
set.seed(123)
n <- 400
x <- rnorm(n)
w1 <- rnorm(n)
w2 <- rnorm(n)
z <- 0.5 * x + sqrt(1 - 0.5^2) * rnorm(n)
b0 <- 0
b1 <- 0.3
b2 <- 0.3
b3 <- 0.8
y <- b0 + b1 * x + b2 * z + b3 * x * z + rnorm(n, sd = 1)
dat <- data.frame(w1, w2, x, z, y)
result <- moderated_regression(
  dat,
  iv = "x",
  moderator = "z",
  dv = "y",
  covariates = c("w1", "w2")
)
print(result)
simple_slopes(result)
plot_moderation(result)
johnson_neyman(result)
compare_models(result)
# note: by default, in moderated_regression() function, predictors are centered.
# otherwise, set `center=FALSE`
result <- moderated_regression(
  dat,
  iv = "x",
  moderator = "z",
  dv = "y",
  covariates = c("w1", "w2"),
  center = FALSE
)
print(result)

Read the original on github.com ↗