Multilevel mediation with missing data

95 views
Skip to first unread message

Adam Lekwa

unread,
Aug 25, 2021, 11:26:04 AM8/25/21
to lavaan
Greetings-

I am trying to fit a two level 2-2-1 mediation in which data are missing in the mediator and the outcome. For example:

m221 <- '
level:1
outcome ~ 1
level:2
outcome ~ b*mediator + c*treatment
mediator ~ a*treatment
indirect:= a*b
total:= indirect+c'

fit.m221 <- sem(m221, data = mydata, cluster = "ClassroomID", missing = "ml")

I'm receiving the following error, and am unsure if it is because of a problem in my dataset, or if I am hitting a bug:

"Error in utils::combn(ov.names, 2) : n < m"

Thanks in advance for any advice,

Adam

Terrence Jorgensen

unread,
Aug 27, 2021, 4:36:49 AM8/27/21
to lavaan
I'm receiving the following error, and am unsure if it is because of a problem in my dataset, or if I am hitting a bug:

"Error in utils::combn(ov.names, 2) : n < m"

Many years ago, there was a bug preventing single-variable SEMs in lavaan; perhaps there is something similar going on here.  But perhaps the problem is that you are specifying an intercept at Level 1, which should be fixed to zero by definition.  Instead, try estimating outcome ~~ outcome.

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

Adam Lekwa

unread,
Aug 27, 2021, 10:52:51 AM8/27/21
to lavaan
Thanks, Terrence.

I'm getting the same error after making that change--it shows up with or without specifying outcome ~~ outcome at level 1. I should note that the error disappears and I can get this to run simply by changing "missing = 'ml' " over to "missing = 'listwise' ".

Thanks again,

Adam

Yves Rosseel

unread,
Aug 30, 2021, 2:32:32 AM8/30/21
to lav...@googlegroups.com
Hm. That sounds like a potential bug. Would you be able to send me a
minimal example (including a small dataset) to reproduce this error?

Please email it direclty to Yves dot Rosseel at UGent dot be

Yves.
> <http://www.uva.nl/profile/t.d.jorgensen>
>
> --
> You received this message because you are subscribed to the Google
> Groups "lavaan" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to lavaan+un...@googlegroups.com
> <mailto:lavaan+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/lavaan/1739afc5-2f9b-469a-80c0-a77f2112e8fbn%40googlegroups.com
> <https://groups.google.com/d/msgid/lavaan/1739afc5-2f9b-469a-80c0-a77f2112e8fbn%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages