how to test each beta in multiple group analyses

36 views
Skip to first unread message

AvidLavaanUser

unread,
Aug 19, 2019, 9:10:49 PM8/19/19
to lavaan
Dear lavaan community

I am performing multiple group analyses by gender with mediation, and I got a significant difference between the models. But I want to know if each beta from each path significantly differs from each other: girls' beta and boys' beta for a path, b path, and c path (and possibly ab). Could you please let me know how I can get it done?
(Is it something I can incorporate it in my syntax below? Or is it separate from the syntax below?)

pdt: predictor
mdt: mediator
ouc: outcome
CV1: control variable 1
CV2: control variable 2

## a model for the same: make everything the same
m13s16oucs <- '
# direct effect
ouc ~ c(c,c)*pdt
# mediator
mdt ~ c(a,a)*pdt + c(za,za)*CV1 + c(ya,ya)*CV2
ouc ~ c(b,b)*mdt + c(zb,zb)*CV1 + c(yb,yb)*CV2
ouc ~ c(d,d)*1 # intercepts: *1, only for DVs
mdt ~c(e,e)*1
ouc ~~ c(f,f)*ouc # variances
mdt ~~ c(g,g)*mdt
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit.m13s16oucs<-sem(m13s16oucs,data=m,group="gender",missing="fiml")
summary(fit.m13s16oucs,fit.measures=TRUE,standardized=TRUE,rsquare=TRUE)

## a different model: allow paramters to be freely estimated (CV1_a sig)
m13s16oucd <- ' 
# direct effect
ouc ~ c(c1,c2)*pdt
# mediator
mdt ~ c(a1,a2)*pdt + c(za1,za2)*CV1 + c(ya1,ya2)*CV2
ouc ~ c(b1,b2)*mdt + c(zb1,zb2)*CV1 + c(yb1,yb2)*CV2
ouc ~ c(d1,d2)*1 # intercepts: *1, only for DVs
mdt ~c(e1,e2)*1
ouc ~~ c(f1,f2)*ouc # variances
mdt ~~ c(g1,g2)*mdt
# indirect effect (a*b)
ab1 := a1*b1
ab2 := a2*b2
# total effect
total1 := c1 + (a1*b1)
total2 := c2 + (a2*b2)
'
fit.m13s16oucd<-sem(m13s16oucd,data=m,group="gender",missing="fiml")
summary(fit.m13s16oucd,fit.measures=TRUE,standardized=TRUE,rsquare=TRUE)

# check if the two models are different
anova(fit.m13s16oucs,fit.m13s16oucd)
# different

I would really appreciate it.

Avid lavaan user

Terrence Jorgensen

unread,
Aug 21, 2019, 6:28:13 AM8/21/19
to lavaan
Could you please let me know how I can get it done?

You could constrain one path at a time to equality and use anova to compare models, but that is quite tedious.  An asymptotically equivalent Wald test is more efficient:

?lavTestWald


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

AvidLavaanUser

unread,
Aug 27, 2019, 11:08:40 PM8/27/19
to lavaan
Thank you so much, Terrence!

To help others who wonder the same question, I pasted the syntax that worked below:

pdt: predictor
mdt: mediator
ouc: outcome
CV1: control variable 1
CV2: control variable 2

## a different model: allow paramters to be freely estimated
m13s16oucd <- ' 
# direct effect
ouc ~ c(c1,c2)*pdt
# mediator
mdt ~ c(a1,a2)*pdt + c(za1,za2)*CV1 + c(ya1,ya2)*CV2
ouc ~ c(b1,b2)*mdt + c(zb1,zb2)*CV1 + c(yb1,yb2)*CV2
ouc ~ c(d1,d2)*1 # intercepts: *1, only for DVs
mdt ~c(e1,e2)*1
ouc ~~ c(f1,f2)*ouc # variances
mdt ~~ c(g1,g2)*mdt
# indirect effect (a*b)
ab1 := a1*b1
ab2 := a2*b2
# total effect
total1 := c1 + (a1*b1)
total2 := c2 + (a2*b2)
'
fit.m13s16oucd<-sem(m13s16oucd,data=m,group="gender",missing="fiml")

lavTestWald(fit.m13s16oucd,constraints="a1==a2") 
lavTestWald(fit.m13s16oucd,constraints="b1==b2") 
lavTestWald(fit.m13s16oucd,constraints="c1==c2") 
lavTestWald(fit.m13s16oucd,constraints="ab1==ab2") 

AvidLavaanUser
Reply all
Reply to author
Forward
0 new messages