Hello, This is Elaine.
I am trying a path analysis using lavaan Package. There are three explanatory variables: X, Z, and M. The response variable is Y. A, b, and c have direct effects on Y. On the other hand, X and Z also have direct effects on M. In other words, X and Z have indirect effects on Y. I found the code example of lavaan package describes only one indirect effect as below. Please kindly advise how to modify it as two indirect effects. Thank you. Elaine > 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 <- ' # direct effect + Y ~ c*X + # mediator + M ~ a*X + Y ~ b*M + # indirect effect (a*b) + ab := a*b + # total effect + total := c + (a*b) + ' > fit <- sem(model, data=Data) > summary(fit) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.