Lavaan Multigroup Comparison Question

61 views
Skip to first unread message

David Freire

unread,
Apr 22, 2020, 12:15:51 AM4/22/20
to lavaan
Hi Everyone!

I had a quick question regarding Multigroup Comparison in Lavaan. Conceptually speaking, if I wanted to take a fully constrained model (using group.equal = c("intercepts", "regressions")) and free specific paths, would I need to place constraints on the covariances of the model as well? This is what I am working with so far:

practicemodel4<-
  '
#Regressions  
 w3DISCRIM ~ c("a1","a1")*w2DISCRIM
 w3PSSM ~ c("b1","b1")*w2PSSM + a*w2DISCRIM
 w3DEPRESS ~ c("c1","c1")*w2DEPRESS + c("d1","d1")*w2PSSM
 w4DISCRIM ~ c("e1","e1")*w3DISCRIM
 w4PSSM ~ c("f1","f1")*w3PSSM + c*w3DISCRIM
 w4DEPRESS ~ c("g1","g1")*w3DEPRESS + b*w3PSSM
 w5DISCRIM ~ c("h1","h1")*w4DISCRIM
 w5PSSM ~ c("i1","i1")*w4PSSM + c("j1","j1")*w4DISCRIM
 w5DEPRESS ~ c("k1","k1")*w4DEPRESS + d*w4PSSM
 
 #Direct Effects
 w4DEPRESS ~ e*w2DISCRIM
 w5DEPRESS ~ f*w3DISCRIM
 direct := e + f 
 
 #Mediations
 med1 := a*b
 med2 := c*d
 mediated := med1 + med2 

 #Covariances
 w2DISCRIM ~~ w2PSSM + w2DEPRESS
 w2PSSM ~~ w2DEPRESS
 w3DISCRIM ~~ w3PSSM + w3DEPRESS
 w3PSSM ~~ w3DEPRESS
 w4DISCRIM ~~ w4PSSM + w4DEPRESS
 w4PSSM ~~ w4DEPRESS
 w5DISCRIM ~~ w5PSSM + w5DEPRESS
 w5PSSM ~~ w5DEPRESS

 #Total Effect
 total1 := med1 + e
 total2 := med2 + f'
modelcomparison2 <- lavaan::sem(practicemodel4, data=seasons.edited, missing = 'fiml', fixed.x = FALSE, group = "groupcomp")
summary(modelcomparison2,fit.measures = TRUE)

I wanted to make sure I am doing the constraining and freeing paths correctly. Any help is appreciated!
Thank you in advance!

Sincerely,
David 

Terrence Jorgensen

unread,
Apr 23, 2020, 1:45:10 AM4/23/20
to lavaan
would I need to place constraints on the covariances of the model as well?

I can't see why that would be necessary.
 
 w3PSSM ~ c("b1","b1")*w2PSSM + a*w2DISCRIM

I wanted to make sure I am doing the constraining and freeing paths correctly

You are correctly constraining the w2PSSM path by providing the same label in each group.  But you still need to provide a vector of labels (1 per group) for the w2DISCRIM path.  You only provided a single label "a", which will be applied to the first group.  If you want that to be free across groups, give them different labels (e.g., c("a1","a2")*w2DISCRIM) so that you can define the indirect effect separately per group (and also define a difference parameter to test whether they are equal across groups).

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

David Freire

unread,
Apr 23, 2020, 1:32:23 PM4/23/20
to lavaan
Hi Terrence!

Thank you so much for your feedback! I took what you said and wanted to ask if the way I coded it in R makes sense for a multigroup comparison where I am comparing a fully constrained model to a model with the mediation paths being freed:

#Full Constrained Model

practicemodel4<-
  '
#Regressions  
 w3DISCRIM ~ w2DISCRIM
 w3PSSM ~ w2PSSM + c(a1,a1)*w2DISCRIM
 w3DEPRESS ~ w2DEPRESS + w2PSSM
 w4DISCRIM ~ w3DISCRIM
 w4PSSM ~ w3PSSM + c(c1,c1)*w3DISCRIM
 w4DEPRESS ~ w3DEPRESS + c(b1,b1)*w3PSSM
 w5DISCRIM ~ w4DISCRIM
 w5PSSM ~ w4PSSM + w4DISCRIM
 w5DEPRESS ~ w4DEPRESS + c(d1,d1)*w4PSSM
 
 #Direct Effects
 w4DEPRESS ~ c(e1,e1)*w2DISCRIM
 w5DEPRESS ~ c(f1,f1)*w3DISCRIM
 direct := e1 + f1
 
 #Mediations
 med1 := a1*b1
 med2 := c1*d1
 mediated := med1 + med2

 #Covariances
 w2DISCRIM ~~ w2PSSM + w2DEPRESS
 w2PSSM ~~ w2DEPRESS
 w3DISCRIM ~~ w3PSSM + w3DEPRESS
 w3PSSM ~~ w3DEPRESS
 w4DISCRIM ~~ w4PSSM + w4DEPRESS
 w4PSSM ~~ w4DEPRESS
 w5DISCRIM ~~ w5PSSM + w5DEPRESS
 w5PSSM ~~ w5DEPRESS

 #Total Effect
 total1 := med1 + e1
 total2 := med2 + f1'
modelcomparison1 <- lavaan::sem(practicemodel4, data=seasons.edited, missing = 'fiml', fixed.x = FALSE, group = "groupcomp", group.equal = c("intercepts", "regressions"))
summary(modelcomparison1,fit.measures = TRUE)
anova(modelcomparison,modelcomparison1)

#Partial Constrained Model
practicemodel5<-
  '
#Regressions  
 w3DISCRIM ~ c("a1","a1")*w2DISCRIM
 w3PSSM ~ c("b1","b1")*w2PSSM + c("l1","l2")*w2DISCRIM
 w3DEPRESS ~ c("c1","c1")*w2DEPRESS + c("d1","d1")*w2PSSM
 w4DISCRIM ~ c("e1","e1")*w3DISCRIM
 w4PSSM ~ c("f1","f1")*w3PSSM + c("n1","n2")*w3DISCRIM
 w4DEPRESS ~ c("g1","g1")*w3DEPRESS + c("m1","m2")*w3PSSM
 w5DISCRIM ~ c("h1","h1")*w4DISCRIM
 w5PSSM ~ c("i1","i1")*w4PSSM + c("j1","j1")*w4DISCRIM
 w5DEPRESS ~ c("k1","k1")*w4DEPRESS + c("o1","o2")*w4PSSM
 
 #Direct Effects
 w4DEPRESS ~ c("p1","p2")*w2DISCRIM
 w5DEPRESS ~ c("q1","q2")*w3DISCRIM
 direct := p1 + p2 + q1 + q2
 
 #Mediations
 med1 := l1*m1
 med2 := l2*m2
 med3 := n1*o1
 med4 := n2*o2
 mediated := med1 + med2 + med3 + med4 

 #Covariances
 w2DISCRIM ~~ w2PSSM + w2DEPRESS
 w2PSSM ~~ w2DEPRESS
 w3DISCRIM ~~ w3PSSM + w3DEPRESS
 w3PSSM ~~ w3DEPRESS
 w4DISCRIM ~~ w4PSSM + w4DEPRESS
 w4PSSM ~~ w4DEPRESS
 w5DISCRIM ~~ w5PSSM + w5DEPRESS
 w5PSSM ~~ w5DEPRESS

 #Total Effect
 total1 := med1 + p1
 total2 := med2 + p2
 total3 := med3 + q1
 total4 := med4 + q2'
modelcomparison3 <- lavaan::sem(practicemodel5, data=seasons.edited, missing = 'fiml', fixed.x = FALSE, group = "groupcomp")
summary(modelcomparison3,fit.measures = TRUE)

Thank you in advance for all of your help!

Sincerely,
David 
Reply all
Reply to author
Forward
0 new messages