Complex path model indirect effct

202 views
Skip to first unread message

Piyush Shah

unread,
Apr 9, 2017, 6:12:45 AM4/9/17
to lavaan



I wanted to do calculate the direct and all indirect effects for a path analytic model. The path diagram has been given below. I am not sure of the code to use in [R]. There are examples of simple indirect effects and mediation models using coefficients a,b,etc and then using the := symbol. But I am not sure how to use that in this slightly more complex model. Here we would have an indirect impact of V1 and V2 on V5, but no direct effect. How will that be coded? 

Terrence Jorgensen

unread,
Apr 10, 2017, 4:16:08 AM4/10/17
to lavaan

I wanted to do calculate the direct and all indirect effects for a path analytic model... using the := symbol. But I am not sure how to use that in this slightly more complex model. How will that be coded? 


The same way, using the := operator.  In the case of the 3-path indirect effect of V2 on V5 via V3 and V4, for example, you would define that indirect effect as the product of those 3 path coefficients.


In more complex models, if you are unsure whether you have calculated all indirect effects, you can use matrix algebra after the model is fit.  

fit <- sem(mySyntax, myData)
Beta <- lavInspect(fit, "est")$beta # matrix of path coefficients
# view effects of each order
Beta # direct effects
Beta %*% Beta # indirect effects involving 2 path coefficents
Beta %*% Beta %*% Beta # indirect effects involving 3 path coefficients
Beta %*% Beta %*% Beta %*% Beta # indirect effects involving 4 path coefficients
## There are none involving 4, so there can't be any higher-order indirect effects

To interpret any nonzero (in)direct path in the matrices above, the variable represented in the row is the outcome, and the variable represented in the column is the predictor.  To view the "total" indirect effect, simply sum all the matrices of indirect effects:

Beta %*% Beta + Beta %*% Beta %*% Beta # + Beta %*% Beta %*% Beta %*% Beta ... if necessary

Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Piyush Shah

unread,
Apr 10, 2017, 10:15:46 AM4/10/17
to lav...@googlegroups.com
Thanks a lot Terrence. 

Thanks 
Piyush 

--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/YOBedJJTmzo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+unsubscribe@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages