I'm wondering how to use SEM to compare mediation effects across models. Specifically, I want to do a "moderated mediation" approach, where the size of the indirect effect depends on the moderator. The way I currently do this is with seemingly unrelated estimation (suest), but I want to know how to do it with SEM.
With SEM, I would normally do something like this—but from here, I don't know how to compare indirect effects.
I'm thinking I need to do something like this, but this produces "no observations."
Code:
eststo m1: reg y x if moderator==1 eststo m2: reg y x mediator if moderator==1 eststo m3: reg y x if moderator==2 eststo m4: reg y x mediator if moderator==2 suest m1 m2 m3 m4 test [m1]x - [m2]x = [m3]x - [m4]x // does the *change* in x's effect size differ significantly depending on the moderator?
Code:
sem (x m -> y) (x -> m) if moderator==1 nlcom _b[y:m]*_b[m:x] sem (x m -> y) (x -> m) if moderator==2 nlcom _b[y:m]*_b[m:x]
Code:
gen y1 = y if moderator==1 gen y2 = y if moderator==2 sem (x m -> y1) (x -> m) (x m -> y2) (x -> m) nlcom _b[y1:m]*_b[m:x] - _b[y2:m]*_b[m:x]
Comment