data_med_mg | R Documentation |
A simple mediation model with two groups.
data_med_mg
A data frame with 100 rows and 5 variables:
Predictor. Numeric.
Mediator. Numeric.
Outcome variable. Numeric.
Control variable. Numeric.
Control variable. Numeric.
Group variable. Character. "Group A" or "Group B"
library(lavaan)
data(data_med_mg)
mod <-
"
m ~ c(a1, a2) * x + c1 + c2
y ~ c(b1, b2) * m + x + c1 + c2
a1b1 := a1 * b1
a2b2 := a2 * b2
abdiff := a2b2 - a1b1
"
fit <- sem(mod, data_med_mg, fixed.x = FALSE,
group = "group")
parameterEstimates(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.