**differences**(between groups like race/ethnicity RE, 'health disparities' HDs)

**in changes**, here for two waves of data (‘pre’ and ‘post’). I am just pointing to the cool solution, and mention other software capacities. Before the latent change score (LCS) model though, a note on

*group comparisons, period*. Someone said somewhere (can’t find it anymore) that now he doesn’t need to ever run an anova test in his remaining professional life; that’s what I am aiming for too. So:

*!!! This is to run in Stata multiple group comparisons of means instead of anova

* Here YYY is your outcome; raceetn3 is the 3 group grouping variable

sem ( <- YYY), group(raceetn) ginvariant(none) means(YYY ) var(YYY) method(mlmv) coeflegend nocapslatent

* all 3 Wald test

test (_b[/mean(YYY)#1.raceetn3] = _b[/mean(YYY)#2.raceetn3] ) ///

(_b[/mean(YYY)#2.raceetn3] = _b[/mean(YYY)#3.raceetn3] )

* pairwise Wald test 1 vs 2

test (_b[/mean(YYY)#1.raceetn3] = _b[/mean(YYY)#2.raceetn3] )

* pairwise Wald test 2 vs 3

test (_b[/mean(YYY)#2.raceetn3] = _b[/mean(YYY)#3.raceetn3] )

* pairwise Wald test 1 vs 3

test (_b[/mean(YYY)#1.raceetn3] = _b[/mean(YYY)#2.raceetn3] )

I am showing

**2 options for LCS:**
1. This allows one to quickly assess whether means are equal (across the 3 groups, or more) or 2 at a time; I am showing an example for comparing Males (M) only: 'if Gender=="M" '. The BIGGEST advantage here is that even when there is attrition, i.e. fewer cases at 'post', this model estimates changes '

**for the full sample**'!
* Here YYY is your outcome; raceetn3 is the 3 group grouping variable

sem (L21 -> YYY_t2@1) (YYY_t1@1 _cons@0 -> YYY_t2) if Gender=="M" , ///

group(raceetn) ginvariant(none) means(L21 ) var(e.YYY_t2@0 L21 ) method(mlmv) latent (L21) coeflegend

* all 3 Wald test

test (_b[/mean(L21)#1.raceetn3] = _b[/mean(L21)#2.raceetn3] ) ///

(_b[/mean(L21)#2.raceetn3] = _b[/mean(L21)#3.raceetn3] )

* pairwise Wald test 1 vs 2

test (_b[/mean(L21)#1.raceetn3] = _b[/mean(L21)#2.raceetn3] )

* pairwise Wald test 2 vs 3

test (_b[/mean(L21)#2.raceetn3] = _b[/mean(L21)#3.raceetn3] )

* pairwise Wald test 1 vs 3

test (_b[/mean(L21)#1.raceetn3] = _b[/mean(L21)#2.raceetn3] )

2. This allows one to also see the means set equal (all of them, or 2 at a time)

* One can also test the M2 model (no equality constraints) then the M1 model (with equality constraints) and compare them using likelihood ratio test; here the UCLA post is illuminating as usual.

*note one has now pre YYY_t1 and post YYY_t2

sem (L21 -> YYY_t2@1) (YYY_t1@1 _cons@0 -> YYY_t2) if Gender=="M" , ///

group(raceetn3) ginvariant(none) means(L21 ) var(e.YYY_t2@0 L21 ) method(mlmv) latent (L21)

estimates store diffLCSmeans

sem (L21 -> YYY_t2@1) (YYY_t1@1 _cons@0 -> YYY_t2) if Gender=="M" , ///

group(raceetn3) means(1: L21@equallcs ) means(2: L21@equallcs ) means(3:L21@equallcs ) var(e.YYY_t2@0 L21 ) method(mlmv) latent (L21)

estimates store eqLCSmeans

lrtest diffLCSmeans eqLCSmeans

* can test 2 1vs2 I use new labels equallcs to set means equal and then when not, black=group 1, white=group 1, hisp =group 1 for the 3rd, left free, not-equal

sem (L21 -> YYY_t2@1) (YYY_t1@1 _cons@0 -> YYY_t2) if Gender=="M" , ///

group(raceetn3) means(1: L21@equallcs ) means(2: L21@equallcs ) means(3:L21@hisp ) var(e.YYY_t2@0 L21 ) method(mlmv) latent (L21)

estimates store eq1vs2

lrtest diffLCSmeans eq1vs2

* can test 2 2vs3

sem (L21 -> YYY_t2@1) (YYY_t1@1 _cons@0 -> YYY_t2) if Gender=="M" , ///

group(raceetn3) means(1: L21@black ) means(2: L21@equallcs ) means(3:L21@equallcs ) var(e.YYY_t2@0 L21 ) method(mlmv) latent (L21)

estimates store eq2vs3

lrtest diffLCSmeans eq2vs3

* can test 2 1vs3

sem (L21 -> YYY_t2@1) (YYY_t1@1 _cons@0 -> YYY_t2) if Gender=="M" , ///

group(raceetn3) means(1: L21@equallcs ) means(2: L21@white ) means(3:L21@equallcs ) var(e.YYY_t2@0 L21 ) method(mlmv) latent (L21)

estimates store eq1vs3

lrtest diffLCSmeans eq1vs3

3.I tried the constraint option too, like:

constraint 1 _b[YYY:1.GROUPING] - _b[Age:2.GROUPING] = 0

constraint 2 _b[YYY:2.GROUPING] - _b[Age:3.GROUPING] = 0

which allows you to run the model then without, then by adding at the end

constraints (1 2)

but it doesn’t seem to do the trick for me.

__More:__
i. Mplus does this easily and flexibly, of course, but the Stata solution is of note, because it’s a ‘general statistics’ software, not a (what some think of Mplus) a SEM dedicated software. A longer explained code is here. One can also go to this demonstration/deconstruction piece too.

ii. Others can do it of course too; the SAS LCS code is below, e.g., not with group contrasting however (for now).

* This simply introduces a NEW variable you don't have in the data that statistically forces the mathematical equality: y2 = y1 + L21;

**proc**

**calis**data = one ;

path

y2 <--- L21=

**1**, /* constrained = 1 */
y2 <--- y1 =

**1**; /* constrained = 0 */
/* fchange <--- y1 = a; POSSIBLE */

pvar

y2 =

**0**, /* constrained = 0 */
y1 = var1,

L21= varlds;

mean

y2 =

**0**, /* constrained = 0 */
L21= meanlds; /* otherwise it's not estimated: Mn=1.80488 SE=3.10569 t=0.5812 */

**run**;