Hi Everyone,
I was hoping that someone here could help me with specifying the lavaan syntax for a multiple mediation model on clustered data. I have used multilevel in R before but this is my first attempt at running a full mediation analysis in the SEM framework. It is a steep leaning curve ! The goal of my study is to determine whether a treatment ( "group" in my data) predicts intent to quit smoking ("intent_scale"). We aim to measure the effect indirect and total effect considering two mediators : self efficacy (se_centred_scale) and vulnerabiliy (vuln_scale). The difficulty arises because there is repeated observations of these variables daily (day_r) within subjects, so I would need to be able to consider a random effect of subject (1|subject in lmer() syntax) and/or a random intercept + slope model (1+day_r|subject).
I have read all I could find about multilevel SEMs, and how to specify them in lavaan using either the wide data format, either the '"cluster" option, but I am struggling to see how to use this information to specify my own model. I don't think I understand how to structure my model at level 1 and level 2 with the lavaan syntax. At the moment, i have managed to write the syntax for model I am trying to fit. It is running fine but totally ignores the clustered natures of the data.
Ideally I would like to find a way to specify the same model considering a subject-level random effect ( or a random intercept-slope model). I would greatly appreciate your input! Below is the first few rows of my data, my current multiple mediation model, and the corresponding path.
Thanks again for your help!
Marie-Jeanne
Post-doctoral fellow
Menzies Institute for Medical Research Univeristy of Tasmania, Australia
multipleMediationNOcovariate <- '
intent_scale ~ b1 * vuln_scale_centred + b2 * se_scale_centred + c * group
vuln_scale_centred ~ a1 * group
se_scale_centred ~ a2 * group
indirect1 := a1 * b1
indirect2 := a2 * b2
total := c + (a1 * b1) + (a2 * b2)
vuln_scale_centred ~~se_scale_centred # residual covariance between the 2 mediators
'