Convergence Issue: Multilevel Mediation Model with Categorical Exogenous Variable

166 views
Skip to first unread message

Riley Hess

unread,
Sep 9, 2021, 1:06:29 PM9/9/21
to lavaan
Hello,

I am trying to run a multilevel mediation model in lavaan with a categorical independent variable, but am running into convergence issues. There are three dummy-coded independent variables (d1, d2, d3), one continuous mediator (admiration), and one continuous dependent variable (activefac). Observations are clustered within participants. 

When I run this model as a single level mediation model I don't get any errors. There are 1381 observations and 179 clusters. 

Please let me know if any additional information is needed. Thank you!

Best,
Riley 

Here is the model syntax:

mediation1 <- '
level:1
activefac~ b*admiration + c1*d1 + c2*d2 + c3*d3
admiration~a1*d1 + a2*d2 + a3*d3
#indirect and total effects
ab1:=a1*b
ab2:=a2*b
ab3:=a3*b
total1 := c1 + (a1 * b)
total2 := c2 + (a2 * b)
total3 := c3 + (a3 + b)
level:2
admiration ~~ admiration + d1 + d2 + d3
d1 ~~ d2 + d3
d2 ~~ d3
'
mediation1out <- sem(mediation1, datalong, cluster = "participantID", estimator = "MLR")

And here are the errors and warnings: 

Warning messages:
1: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING:
    Level-1 variable “activefac” has no variance within some clusters.
    The cluster ids with zero within variance are: 102 123 160 166
2: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING:
    Level-1 variable “admiration” has no variance within some
    clusters. The cluster ids with zero within variance are: 2 5 6 7
    18 32 37 38 45 57 59 61 63 64 66 67 70 76 93 97 98 108 129 134 145
    162 163 166 167 168 169 170 173 174 176 35
3: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING:
    Level-1 variable “d1” has no variance within some clusters. The
    cluster ids with zero within variance are: 101
4: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING:
    Level-1 variable “d2” has no variance within some clusters. The
    cluster ids with zero within variance are: 85 88 94 117 141 148
    179 65 101
5: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING:
    Level-1 variable “d3” has no variance within some clusters. The
    cluster ids with zero within variance are: 123 35 101
6: In lavaan::lavaan(model = mediation1, data = datalong, cluster = "participantID",  :
  lavaan WARNING:
    the optimizer warns that a solution has NOT been found!
7: In lavaan::lavaan(model = mediation1, data = datalong, cluster = "participantID",  :
  lavaan WARNING: estimation of the baseline model failed.




Screen Shot 2021-09-09 at 1.05.06 PM.png

Terrence Jorgensen

unread,
Sep 17, 2021, 5:46:19 PM9/17/21
to lavaan
When I run this model as a single level mediation model I don't get any errors. 

You don't have any restrictions on your Level-2 model.  Why don't you just fit the single-level model and specify cluster= so  you get cluster-robust SEs?

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