Question on multi-group multilevel analysis

351 views
Skip to first unread message

jtk

unread,
May 14, 2019, 12:52:38 PM5/14/19
to lavaan
Hello all. I have some questions regarding using lavaan for my data. Basically, my aim is to test whether a model fits my data, and more importantly, to see whether age (as a categorical variable) is a moderator, so it's a multi-group path analysis. However, the tricky part is that, to better capture the phenomenon, participants were asked to fill in the questionnarie repeatedly for 6 times, so it sounds like a multilevel analysis too.

My questions are (they are a bit long, hope I have expressed myself well): 

1. For lavaan, result of multilevel SEM was reported like a multi-group SEM. Then is it possible to conduct a multi-group SEM on a multilevel model as well? I tried the syntax below, but the error "subscript out of bound" appeared, and I'm not sure if it's because the analysis is not supported, or if there're some issues in my code.

Code sample: 
SRSIMCA_md <- '
level: 1
disc_o ~ PI2_c + iden2_c + CEFF_c
PI2_c ~ iden2_c + SR_c
CEFF_c ~ iden2_c + SR_c
iden2_c ~ SR_c


level: 2
disc_o ~ MSR + MPI2 + Miden2 + MCEff'



SRSIMCA_mdfit
<- sem(SRSIMCA_d, data = all, cluster = "PartiID", group = "agegp")



2. If multi-group analysis for multilevel model is not supported, do you have some suggestions on what can be done instead? In fact, I have no intention/ prediction on the within- and between-person differences, and I'm only using multilevel SEM because my data are in a nested format (ICC is high too). Personally I have considered using disaggregation approach, but then there is still question. 

Here are two codes I tried:

a. randomly trying out if lavaan can take cluster variable into account while not specifying a multilevel model (all variables in the model are on level 1)
SRSIMCA_c_1lv <- '
CAI_o ~ PI2 + iden2 + CEfficacy
PI2 ~ iden2 + SR
CEfficacy ~ iden2 + SR
iden2 ~ SR'



SRSIMCA_c_1lvfit
<- sem(SRSIMCA_c_1lv, data = all, cluster = "PartiID")


b. just normal specification
SRSIMCA_c_1lv <- '
CAI_o ~ PI2 + iden2 + CEfficacy
PI2 ~ iden2 + SR
CEfficacy ~ iden2 + SR
iden2 ~ SR'



SRSIMCA_c_1lvfit
<- sem(SRSIMCA_c_1lv, data = all)


Code a is just my random testing. The results are essentially the same, but there are still some slight differences. May I confirm if these two codes are doing the same thing (disaggregation)?

Thank you in advance, and sorry if I have only limited knowledge in multilevel/ SEM!

Terrence Jorgensen

unread,
May 17, 2019, 9:00:48 AM5/17/19
to lavaan
participants were asked to fill in the questionnarie repeatedly for 6 times, so it sounds like a multilevel analysis too.

Would this be more straight-forward to handle as longitudinal data?  i.e., multivariate (wide format) rather than multilevel (long format)?  

Then is it possible to conduct a multi-group SEM on a multilevel model as well? 

Yes.  This feature is not well documented because the multilevel features in lavaan are still very "beta".  Yves plans to have lavaanify() recognize multigroup syntax within multilevel blocks the same way it works in single-level models, but for now, you need to define Level-2 groups using separate models (blocks) just like you do for levels.  And within each group's block, define both level's models as blocks.  Here is an example:

Galo <- read.table("https://users.ugent.be/~yrosseel/lavaan/kiel2018/Galo.dat")
names
(Galo) <- c("school", "sex", "galo", "advice", "feduc", "meduc",
                 
"focc", "denom")
Galo$g <- ifelse(Galo$school < 30, "foo", "bar") # randomly assign schools to groups
model
<- ' group: foo
level: within
  galo ~ focc
level: between
  galo ~ focc


group: bar

level: within
  galo ~ focc
level: between
  galo ~ focc
'
fitmg
<- sem(model, data = Galo, cluster = "school", fixed.x = FALSE,
             std
.lv = TRUE, h1 = TRUE, group = "g")



Level-1 groups is a whole other problem:  https://doi.org/10.1080/00273171.2014.1003769

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

jtk

unread,
May 25, 2019, 3:29:20 AM5/25/19
to lavaan
Thank you very much for your help, Dr. Jorgensen! I will definitely try it out. 
(I'm sorry for the late thank you. I thought I subscribed to the post already but turns out I didn't)
Reply all
Reply to author
Forward
0 new messages