data_med_mod_b | R Documentation |
A simple mediation model with b-path moderated.
data_med_mod_b
A data frame with 100 rows and 6 variables:
Predictor. Numeric.
Moderator. Numeric.
Mediator. Numeric.
Outcome variable. Numeric.
Control variable. Numeric.
Control variable. Numeric.
library(lavaan)
data(data_med_mod_b)
data_med_mod_b$mw <-
data_med_mod_b$m *
data_med_mod_b$w
mod <-
"
m ~ a * x + w + c1 + c2
y ~ b * m + x + d * mw + c1 + c2
w ~~ v_w * w
w ~ m_w * 1
ab := a * b
ab_lo := a * (b + d * (m_w - sqrt(v_w)))
ab_hi := a * (b + d * (m_w + sqrt(v_w)))
"
fit <- sem(mod, data_med_mod_b,
meanstructure = TRUE, fixed.x = FALSE)
parameterEstimates(fit)[c(1, 5, 7, 10, 11, 30:32), ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.