Lavaan Multigroup Serial Mediation Model

1,990 views
Skip to first unread message

kristy.d...@eagles.usm.edu

unread,
Apr 10, 2016, 1:33:17 PM4/10/16
to lavaan
I am trying to run a mulrigroup serial mediation model in lavaan. I'm familiar with the basic model code and how to ask for multigroup comparisons. However, when I run this, lavaan only provides the basic parameters for each group. Lavaan is not giving the indirect effects for each group, rather just indirect effects for one overall model (from what I can tell). Any suggestions on how to specify that lavaan provides these additional parameters for both groups is much appreciated.

Terrence Jorgensen

unread,
Apr 11, 2016, 5:36:27 AM4/11/16
to lavaan
If you want to estimate the indirect effect in each group (without equality constraints), then you give each associated parameter a different label in each group, then calculate each indirect effect.  

M ~ c(a1, a2)*X
Y ~ c(b1, b2)*M
ab1 := a1*b1 # indirect effect in group 1
ab2 := a2*b2 # indirect effect in group 2

User-defined parameters are not labeled in the output as being associated with one particular group because you could very well define parameters as functions of parameters in multiple groups (e.g., 'nonsense := (a1*b2) / sqrt(a2 / b1)').

Terry

Message has been deleted

kristy.d...@eagles.usm.edu

unread,
Apr 11, 2016, 7:29:13 PM4/11/16
to lavaan
Terry,

Thank you for your help! I have been struggling for a bit on trying to figure this out. I am new to R as well as path analysis, so I have some additional questions if it is too much to ask.

Essentially, I am hoping to run the serial mediation model in which the model is first freely estimated in both groups, then fully constrained (so as to see if there are differences between groups). Then I want to run a partially constrained model, if it is indicated as an appropriate step (based on the prior step; and following each step with a chi-square difference test). To do this, I started with my base model code (see below). I'm struggling to understand how to incorporate the syntax you suggested into my existing code. I have attached a depiction of the theoretical model as well. Would you mind helping me resolve my confusion with the syntax?


Thanks so much!

Kristy


model1a <- '

extern ~ a3*mER_total+ b3*CmMAGm + c1*pardis + aAGE + pAGE

mER_total ~ a2*CmMAGm + b2*pardis + aAGE + pAGE

CmMAGm ~ a1*pardis + aAGE + pAGE

indirect1:=a1*a2*a3

indirect2:=a1*b3

indirect3:=a3*b2

tot:= (a1*a2*a3)+(a1*b3)+(a3*b2) + c1'



#pardis and cmag #freely estimated


fit1a<-sem(model1a, data=data, group = 'Q20')

summary(fit1a, standardized = T, fit.measures = T, rsquare=T, modindices=T)

parameterEstimates(fit1a, ci=T, boot.ci='perc')



#pardis and cmag #equal model estimated


fit1b<-sem(model1a, data=data, group = 'Q20', group.equal = c("loadings"))

summary(fit1b, standardized = T, fit.measures = T, rsquare=T, modindices=T)

parameterEstimates(fit1b, ci=T, boot.ci='perc')



#pardis and cmag #equal partially constrained estimated


fit1c<-sem(model1a, data=data, group = 'Q20', group.partial = c("mER_total ~~ CmMAGm"))

summary(fit1c, standardized = T, fit.measures = T, rsquare=T, modindices=T)

parameterEstimates(fit1c, ci=T, boot.ci='perc')


Figure1.pptx

Terrence Jorgensen

unread,
Apr 12, 2016, 4:03:18 AM4/12/16
to lavaan

fit1b<-sem(model1a, data=data, group = 'Q20', group.equal = c("loadings"))

You don't have any factor loadings to estimate, so this use of the "group.equal" argument doesn't make any sense.  Instead, you want to constrain "regressions".  But using the group.equal argument will not allow you to define the indirect effects you want to estimate.  Instead, you should use the syntax to constrain the parameters to equality, as I suggested in the previous post.  Using only 1 label applies that label to only the first group's parameter, but using a vector of labels allows you to label the parameter in each group.  Assuming you have 2 groups, you could distinguish between parameters of Group 1 using lowercase and Group 2 using uppercase, for example:

CmMAGm ~ c(a1, A1)*pardis 

Note that R is case-sensitive, so "a1" is distinct from "A1", but if you have more groups, you could just give entirely new labels to each group (e.g., 'CmMAGm ~ c(g1.a1, g2.a1, g3.a1)*pardis').  If you give the parameter the same label in both groups, they will be constrained to equality:

CmMAGm ~ c(a1, a1)*pardis 

When the parameters are not constrained to equality across groups, then you define an indirect effect separately for each group, as I showed in my previous post:

g1.indirect1 := g1.a1 * g1.a2 * g1.a3
g2.indirect1 := g2.a1 * g2.a2 * g2.a3

 and so on...

fit1c<-sem(model1a, data=data, group = 'Q20', group.partial = c("mER_total ~~ CmMAGm"))


The group.equal argument is where you provide exceptions to the group.equal argument, so it doesn't make sense to use group.partial without group.equal.  Also, the "~~" operator is for (co)variances, not regressions.  If you want to free one constraint at a time, you need to add the regression parameter you want to free (e.g., 'mER_total ~ CmMAGm').

But again, that would not allow you to define the indirect effect in each group if there are any group differences.  You could use the group.equal shortcut to first find out how many parameters can be constrained across groups (which would not require all the time spent bootstrapping).  Then, once you settle on a model, then you can add the user-defined indirect effects to the syntax.  But you are only working with constraints on 6 regression slopes, so I would suggest you use the lavaan syntax to make your constriants -- it's good practice.

Terry

kristy.d...@eagles.usm.edu

unread,
Apr 12, 2016, 6:55:45 AM4/12/16
to lavaan
Terry,

This makes so much sense! Thank you so much! I was able to correct my syntax and it is running without error in R. 

Thank you for your help!

Kristy
Reply all
Reply to author
Forward
0 new messages