data_med_complicated_mg {manymome} | R Documentation |
A mediation model with two predictors, two pathways, and two groups.
data_med_complicated_mg
A data frame with 300 rows and 5 variables:
Predictor 1. Numeric.
Predictor 2. Numeric.
Mediator 1 in Path 1. Numeric.
Mediator 2 in Path 1. Numeric.
Mediator in Path 2. Numeric.
Outcome variable 1. Numeric.
Outcome variable 2. Numeric.
Control variable. Numeric.
Control variable. Numeric.
Group variable. Character. 'Group A' or 'Group B'
library(lavaan)
data(data_med_complicated_mg)
dat <- data_med_complicated_mg
mod <-
"
m11 ~ x1 + x2 + c1 + c2
m12 ~ m11 + c1 + c2
m2 ~ x1 + x2 + c1 + c2
y1 ~ m11 + m12 + x1 + x2 + c1 + c2
y2 ~ m2 + x1 + x2 + c1 + c2
"
fit <- sem(mod, dat, group = "group")
summary(fit)