Moderated Mediation in SEM help

226 views
Skip to first unread message

Emma Corley

unread,
Jul 20, 2021, 12:29:30 PM7/20/21
to lavaan
Hi all, 

I am trying to fit (what I think) is a moderated mediation model with 2 moderators to correspond with the attached diagram. However, I'm relatively new to both R and lavaan and could really do with some help trying to build my model.

I have attached the code I have generated below. I guess my main question is whether I have specified the model correctly. Any help or guidance would be very much appreciated!

I also had a question regarding using a latent variable as a moderator. I found some questions regarding indProd function (in this group) but I am a little confused of how to generate such a code. I was hoping to use the variable ELAS (which consists of 4 items with 4 levels) as a moderator variable. At the moment I've just used a total score as I having a lot of difficulty trying to find a way to use this as a latent variable. 

#moderated mediation
moderated_mediation <-'
#latent variable
IQ=~ in1 + in2 + in3

#regressions
TBV~ a1*gene
IQ~ b1*TBV 
TBV~ a2*ELAS
TBV~a3*gene_ELAS
IQ~ b2*eduageS
IQ~ b3*TBV_eduageS
IQ~ cdash*gene 

#covariates
TBV~ totalB + Sex + Age


#mean of centered moderators (for use in simple slopes)
ELAS ~ ELA.mean*1
eduageS ~eduage.mean*1

#variance of moderators 
ELAS ~~ ELA.var*ELASS
eduageS ~~ eduage.var*eduageS 

#index of moderated mediation 
imm1 := a1*b3
imm2 := b1*a3

#indirect effects conditional on moderators

indirect1.SDbelow := a1*b1* + a3*-sqrt(ELA.var)*b1
indirect1.mean := a1*b1 + a3*ELA.mean*b1
indirect1.SDabove := a1*b1 + a3*sqrt(ELA.var)*b1

indirect2.SDbelow := a1*b1 + a1*-sqrt(eduage.var)*b3
indirect2.mean := a1*b1 + a1*eduage.mean*b3
indirect2.SDabove := a1*b1 + a1*sqrt(eduage.var)*b3
'
#fit model 
sem <- sem(model= moderated_mediation, data= df, fixed.x = FALSE,  missing ='fiml')
#fit measures
summary(sem, fit.measures= TRUE, standardize= TRUE, rsquare= TRUE)

Many thanks again, 
Emma
hypothesised model.pdf

Terrence Jorgensen

unread,
Jul 21, 2021, 4:47:45 AM7/21/21
to lavaan
I guess my main question is whether I have specified the model correctly. Any help or guidance would be very much appreciated!

Looks like you have separate moderators of the "a" and "b" paths, conforming to Model 4 in Preacher et al.'s (2007) tutorial:  https://doi.org/10.1080/00273170701341316

Inspecting that path diagram will inform you about correct model specification.
 
I was hoping to use the variable ELAS (which consists of 4 items with 4 levels) as a moderator variable. At the moment I've just used a total score as I having a lot of difficulty trying to find a way to use this as a latent variable. 

If by "4 levels" you mean it is ordinal, then you can't use the product-indicator approach while treating it as ordinal.  You would have to treat it as continuous.  
The ?indProd help page has examples, as well as references you can read for more information about the methods.  Here is a book chapter that has example lavaan syntax, where one observed variable is treated as a single-indicator factor so it can interact with a multiple-indicator common factor (I believe that conforms to your situation, but this chapter is about testing measurement invariance, not moderated mediation).


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

Reply all
Reply to author
Forward
0 new messages