alishinski / lavaanPlot

R package for plotting lavaan path models with DiagrammeR
http://alexlishinski.com/lavaanPlot/
38 stars 4 forks source link

Duplicate path when using ":" operator with manifest variables #29

Open jorgesinval opened 3 years ago

jorgesinval commented 3 years ago
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:

image

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:

​M:X

image

alishinski commented 3 years ago

That's curious. Thanks for pointing this out, I will take a look at it.