Clustered data troubleshooting- nlevels> 1L is not TRUE?

172 views
Skip to first unread message

jordo...@gmail.com

unread,
Feb 23, 2019, 7:19:51 PM2/23/19
to lavaan
Hello all,
I am a newcomer to multilevel analysis and I am looking to use lavaan to account for data gathered across many sites within a given region (i.e. data clustered by site). I want to see how well the model holds across the many sites, while accounting for the random variation between sites. That is, the model of interest is the same between as within, but I'd like to account for site-level clustering. The structural model is relatively straightforward (see code below) with two factors and one mediating variable all predicting the DV.

lav.model <- "
      F1 =~ NA*y1 + y2 + y3
      F2 =~ NA*y4 + y5
      F1 ~~ 1*F1
      F2 ~~ 1*F2
      F1 ~~ F2
      M1 ~ a*F1 + c*F2
      DV ~ b*F1 + d*F2 + e*M1

"
lav.fit <- sem(lav.model, data=mlm.data, std.ov=TRUE, missing="ML", cluster="site")
summary(lav.fit, fit.measures=TRUE)

I had a bit of trouble getting it to run, but when I used the EM optimization method suggested here, I get the following error:
"Error in lavaan::lavaan(model = lav.model, data = mlm.data, cluster = "site",  : lavdata@nlevels > 1L is not TRUE"

The "nlevels > 1L is not TRUE" is confusing because I thought I had a lower level (cluster="site") specified.
Is this model specified correctly? Am I answering the question I think I am answering?

I am very appreciative of whatever insights you all can provide.

Terrence Jorgensen

unread,
Feb 28, 2019, 10:04:17 PM2/28/19
to lavaan
Is this model specified correctly?

No, you need to specify a model at both levels.


Also, lavaan can currently only estimate multilevel models with complete data, but that is not what led to your error.

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

jordo...@gmail.com

unread,
Mar 5, 2019, 9:45:58 AM3/5/19
to lavaan
Yes, so I should specify a saturated model at the second level.

It would look something like this

"level: 1

      F1 =~ NA*y1 + y2 + y3
      F2 =~ NA*y4 + y5
      F1 ~~ 1*F1
      F2 ~~ 1*F2
      F1 ~~ F2
      M1 ~ a*F1 + c*F2
      DV ~ b*F1 + d*F2 + e*M1
level: 2
      M1 ~~ M1 + DV
      DV ~~ DV"

Thank you for your help.

Terrence Jorgensen

unread,
Mar 6, 2019, 2:59:13 PM3/6/19
to lavaan
Yes, so I should specify a saturated model at the second level.

If you want a saturated Level-2 model, you need to correlate all variables, not just M1 and DV (i.e., they need to correlate with the level-2 components of the indicators y1-y5).
Reply all
Reply to author
Forward
0 new messages