set.seed(1234)
X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)
model <- 'Y ~ c*X
M ~ a*X
Y ~ b*M+M:X'
fit <- sem(model, data = Data)
summary(fit)
lavaanPlot::lavaanPlot(model = fit)
The result:
However, if another approach is used (creating a variable with the product of M*X) it works. I believe that the reason behind this issue is due to the operator : in the object fit:
The result:
However, if another approach is used (creating a variable with the product of M*X) it works. I believe that the reason behind this issue is due to the operator
:
in the objectfit
:M:X