I am doing a longitudinal mediation analysis in Stata with one IV (categorical), 3 MV (continuous) and one DV (continuous). The 3 MVs are correlated. Now, in a simple mediating model like the following, the indirect effect is b2*b3 and the direct effect is b4 and the total effect is (b2*b3)+b4 which should be equal to b1 (the model without the mediator).
Y = b1 X
M = b2 X
Y = b3 M + b4 X
In my analysis, there are four equations as follows
M1 = b21 X + controls
M2 = b22 X + controls
M3 = b23 X + controls
Y = b31 M1 + b32 M2 + b33 M3 + b4 X + controls
The controls are the same for all the equations. I am using gsem ito do the analysis. I assume same random effects for all the X --> M equations and a different random effect for M-->Y equation (with shared covariance) and account for correlation between mediators. My command:
gsem (y <- M1 M2 M3 X controls M1[level]) (M1 M2 M3 <- X controls M2[level]), cov(e.M1*e.M2 e.M1*e.M3 e.M2*e.M3)
Now, I calculate indirect effect as (b21*b31 + b22*b32 + b23* b33). Total effect is indirect effect plus b4.
Have I done this correctly?
Should the total effect be equal to
b1calculated using this command?
mixed Y X controls || level:
Any references would be helpful.