| plot.mlm_jn | R Documentation |
Creates a ggplot2 figure showing the simple slope of pred across the
full range of modx, with shading indicating regions of significance.
A vertical dashed line marks each Johnson-Neyman boundary.
## S3 method for class 'mlm_jn'
plot(
x,
x_label = NULL,
y_label = NULL,
sig_color = "#2166AC",
nonsig_color = "#D6604D",
...
)
x |
An |
x_label |
Label for the x-axis. Defaults to the moderator name. |
y_label |
Label for the y-axis. Defaults to "Simple slope of pred". |
sig_color |
Fill colour for the significant region. Default |
nonsig_color |
Fill colour for the non-significant region. Default |
... |
Ignored. |
A ggplot object.
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")
plot(jn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.