Would the following be possible in lavaan?

276 views
Skip to first unread message

W.B. Vries, de

unread,
Mar 1, 2023, 6:04:17 AM3/1/23
to lavaan
Hi everyone,

I am currently considering using SEM for one of my PhD projects. I have three waves of data on employee-supervisor dyads and aim to estimate a mediation model. I would like to estimate a Random Intercept Cross-Lagged Panel Model (RI-CLPM; Hamaker, Kuiper, & Grasman, 2015) to separate between effects (between the dyads) from within effects (over time). Given that the same supervisor appears in multiple dyads, I would like to estimate a multi-level model, with level: 1 the dyad level, and level: 2 the supervisor level. I believe that currently multi-level SEM is only possible with two levels, random intercept only. I want to know if the random intercept introduced in a RI-CLPM makes it so one cannot specify a multi-level model anymore. Lastly, I would also like to include a number of covariates. I believe all of these options are possible separately, but could one combine them? 

That is, would it be possible to do multi-level mediation using a RI-CLPM, with covariates?

Best,
Wout

Terrence Jorgensen

unread,
Mar 7, 2023, 6:02:15 AM3/7/23
to lavaan
the same supervisor appears in multiple dyads

So you have a "many-with-1" design?  


Then is your CLPM a longitudinal actor-partner interdependence model (APIM)?

I would like to estimate a multi-level model, with level: 1 the dyad level, and level: 2 the supervisor level. I believe that currently multi-level SEM is only possible with two levels, random intercept only. I want to know if the random intercept introduced in a RI-CLPM makes it so one cannot specify a multi-level model anymore.

That is not a problem.  You are handling your nesting of repeated measures within subjects/dyads via wide-format (like growth-curve modeling), so the model you describe is still only 2 levels (dyads within supervisors). 
  • The level-1 effects are how supervisors behave with specific employees (and vice versa), relative to how they behave with all their employees on average
  • The level-2 effects are how supervisors behave with all employees on average (and vice versa)

Lastly, I would also like to include a number of covariates. I believe all of these options are possible separately, but could one combine them? 

Yes, that's possible.

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

W.B. Vries, de

unread,
Mar 7, 2023, 10:19:23 AM3/7/23
to lavaan
Thanks a lot!

W.B. Vries, de

unread,
Mar 8, 2023, 10:22:07 AM3/8/23
to lavaan
I indeed have a many-with-1 design, with supervisors rating their employees, and vice versa. I aim to assess the impact of a supervisor's directive leadership style (rated by the employee) on an employee's performance and creativity (rated by the supervisor). Eventually I would also look at contextual determinants of directive leadership to make it a mediation model. 

But taking it step by step, I started with the second step of the mediation, and tried to add covariates to a RI-CLPM. I used the riclpmr package to generate lavaan syntax, and I manually added covariates by regressing the observed variables on the covariates (constrained over time; based on Mulder & Hamaker, 2021). This is the lavaan model I came up with:

"
ri_w =~ 1*W1_E_Directive + 1*W2_E_Directive + 1*W3_E_Directive
ri_x =~ 1*W1_Perf + 1*W2_Perf + 1*W3_Perf
ri_y =~ 1*W1_Crea + 1*W2_Crea + 1*W3_Crea
ri_w ~~ ri_w
ri_x ~~ ri_x
ri_y ~~ ri_y
ri_w ~~ ri_x + ri_y
ri_x ~~ ri_y
W1_E_Directive ~ W1_E_Directive_mu*1
W2_E_Directive ~ W2_E_Directive_mu*1
W3_E_Directive ~ W3_E_Directive_mu*1
W1_Perf ~ W1_Perf_mu*1
W2_Perf ~ W2_Perf_mu*1
W3_Perf ~ W3_Perf_mu*1
W1_Crea ~ W1_Crea_mu*1
W2_Crea ~ W2_Crea_mu*1
W3_Crea ~ W3_Crea_mu*1
lat_w1 =~ 1*W1_E_Directive
lat_w2 =~ 1*W2_E_Directive
lat_w3 =~ 1*W3_E_Directive
lat_x1 =~ 1*W1_Perf
lat_x2 =~ 1*W2_Perf
lat_x3 =~ 1*W3_Perf
lat_y1 =~ 1*W1_Crea
lat_y2 =~ 1*W2_Crea
lat_y3 =~ 1*W3_Crea
lat_w1 ~~ lat_x1 + lat_y1
lat_w2 ~~ r_wx*lat_x2 + r_wy*lat_y2
lat_w3 ~~ r_wx*lat_x3 + r_wy*lat_y3
lat_x1 ~~ lat_y1
lat_x2 ~~ r_xy*lat_y2
lat_x3 ~~ r_xy*lat_y3
lat_w2 ~ w_w*lat_w1 + w_x*lat_x1 + w_y*lat_y1
lat_w3 ~ w_w*lat_w2 + w_x*lat_x2 + w_y*lat_y2
lat_x2 ~ x_w*lat_w1 + x_x*lat_x1 + x_y*lat_y1
lat_x3 ~ x_w*lat_w2 + x_x*lat_x2 + x_y*lat_y2
lat_y2 ~ y_w*lat_w1 + y_x*lat_x1 + y_y*lat_y1
lat_y3 ~ y_w*lat_w2 + y_x*lat_x2 + y_y*lat_y2
lat_w1 ~~ lat_w1
lat_w2 ~~ e_w*lat_w2
lat_w3 ~~ e_w*lat_w3
lat_x1 ~~ lat_x1
lat_x2 ~~ e_x*lat_x2
lat_x3 ~~ e_x*lat_x3
lat_y1 ~~ lat_y1
lat_y2 ~~ e_y*lat_y2
lat_y3 ~~ e_y*lat_y3

# New code added:
# https://jeroendmulder.github.io/RI-CLPM/lavaan.html#Ext_1:_time-invariant_predictor
# Control for W1 Covariates at W1, W2, W3

W1_E_Directive + W2_E_Directive + W3_E_Directive ~ c1*L_Age + c2*E_Age + c3*L_Sex + c4*E_Sex + c5*L_Educ.Low + c6*L_Educ.High + c7*Level.Low + c8*Level.High +
c9*E_Educ.Low + c10*E_Educ.High + c11*L_PosTenure + c12*E_PosTenure + c13*L_Hoursworked + c14*E_Hoursworked+ c15*WFHPotentialHigh + c17*Master
W1_Perf + W2_Perf + W3_Perf ~ c1*L_Age + c2*E_Age + c3*L_Sex + c4*E_Sex + c5*L_Educ.Low + c6*L_Educ.High + c7*Level.Low + c8*Level.High +
c9*E_Educ.Low + c10*E_Educ.High + c11*L_PosTenure + c12*E_PosTenure + c13*L_Hoursworked + c14*E_Hoursworked+ c15*WFHPotentialHigh + c17*Master
W1_Crea + W2_Crea + W3_Crea ~ c1*L_Age + c2*E_Age + c3*L_Sex + c4*E_Sex + c5*L_Educ.Low + c6*L_Educ.High + c7*Level.Low + c8*Level.High +
c9*E_Educ.Low + c10*E_Educ.High + c11*L_PosTenure + c12*E_PosTenure + c13*L_Hoursworked + c14*E_Hoursworked+ c15*WFHPotentialHigh + c17*Master
"

This syntax seems to work, but I wonder if any of you could check that for me. 


The next step I want to take is to account for the fact that the same supervisor appears in multiple dyads, by defining a level for the dyad and for the supervisor. 

Without covariates, I came up with the following lavaan model. I followed this resource https://lavaan.ugent.be/tutorial/multilevel.html, specifically the part about "if you do not have a model in mind for level 2, you can specify a saturated level by adding all variances and covariances of the endogenous variables". 

"
# Dyad level
level: 1
ri_w =~ 1*W1_E_Directive + 1*W2_E_Directive + 1*W3_E_Directive
ri_x =~ 1*W1_Perf + 1*W2_Perf + 1*W3_Perf
ri_y =~ 1*W1_Crea + 1*W2_Crea + 1*W3_Crea
ri_w ~~ ri_w
ri_x ~~ ri_x
ri_y ~~ ri_y
ri_w ~~ ri_x + ri_y
ri_x ~~ ri_y
W1_E_Directive ~ W1_E_Directive_mu*1
W2_E_Directive ~ W2_E_Directive_mu*1
W3_E_Directive ~ W3_E_Directive_mu*1
W1_Perf ~ W1_Perf_mu*1
W2_Perf ~ W2_Perf_mu*1
W3_Perf ~ W3_Perf_mu*1
W1_Crea ~ W1_Crea_mu*1
W2_Crea ~ W2_Crea_mu*1
W3_Crea ~ W3_Crea_mu*1
lat_w1 =~ 1*W1_E_Directive
lat_w2 =~ 1*W2_E_Directive
lat_w3 =~ 1*W3_E_Directive
lat_x1 =~ 1*W1_Perf
lat_x2 =~ 1*W2_Perf
lat_x3 =~ 1*W3_Perf
lat_y1 =~ 1*W1_Crea
lat_y2 =~ 1*W2_Crea
lat_y3 =~ 1*W3_Crea
lat_w1 ~~ lat_x1 + lat_y1
lat_w2 ~~ r_wx*lat_x2 + r_wy*lat_y2
lat_w3 ~~ r_wx*lat_x3 + r_wy*lat_y3
lat_x1 ~~ lat_y1
lat_x2 ~~ r_xy*lat_y2
lat_x3 ~~ r_xy*lat_y3
lat_w2 ~ w_w*lat_w1 + w_x*lat_x1 + w_y*lat_y1
lat_w3 ~ w_w*lat_w2 + w_x*lat_x2 + w_y*lat_y2
lat_x2 ~ x_w*lat_w1 + x_x*lat_x1 + x_y*lat_y1
lat_x3 ~ x_w*lat_w2 + x_x*lat_x2 + x_y*lat_y2
lat_y2 ~ y_w*lat_w1 + y_x*lat_x1 + y_y*lat_y1
lat_y3 ~ y_w*lat_w2 + y_x*lat_x2 + y_y*lat_y2
lat_w1 ~~ lat_w1
lat_w2 ~~ e_w*lat_w2
lat_w3 ~~ e_w*lat_w3
lat_x1 ~~ lat_x1
lat_x2 ~~ e_x*lat_x2
lat_x3 ~~ e_x*lat_x3
lat_y1 ~~ lat_y1
lat_y2 ~~ e_y*lat_y2
lat_y3 ~~ e_y*lat_y3

# Supervisor level
level: 2
W1_E_Directive ~~ W1_E_Directive + W2_E_Directive + W3_E_Directive + W1_Perf + W2_Perf + W3_Perf + W1_Crea + W2_Crea + W3_Crea
W2_E_Directive ~~ W2_E_Directive + W3_E_Directive + W1_Perf + W2_Perf + W3_Perf + W1_Crea + W2_Crea + W3_Crea
W3_E_Directive ~~ W3_E_Directive + W1_Perf + W2_Perf + W3_Perf + W1_Crea + W2_Crea + W3_Crea
W1_Perf ~~ W1_Perf + W2_Perf + W3_Perf + W1_Crea + W2_Crea + W3_Crea
W2_Perf ~~ W2_Perf + W3_Perf + W1_Crea + W2_Crea + W3_Crea
W3_Perf ~~ W3_Perf + W1_Crea + W2_Crea + W3_Crea
W1_Crea ~~ W1_Crea + W2_Crea + W3_Crea
W2_Crea ~~ W2_Crea + W3_Crea
W3_Crea ~~ W3_Crea
"

However, estimating this model, adding the argument cluster = Supervisorid, the model does not converge. The warnings indicate that there is no variation within clusters for both directive leadership as employee performance/creativity. I checked what would happen if I removed those cases, but the model still did not converge. Is my specification correct?

I also noticed that if I do not specify a level 1 and 2 model, but do add cluster = Supervisorid argument, in the output it indicates that the Standard errors are Robust.cluster, rather than Standard. Would this approach be an alternative to modeling the two levels, if I cannot get a multi-level model to converge?

Best,
Wout

Terrence Jorgensen

unread,
Mar 14, 2023, 9:30:09 AM3/14/23
to lavaan
if I do not specify a level 1 and 2 model, but do add cluster = Supervisorid argument, in the output it indicates that the Standard errors are Robust.cluster, rather than Standard. Would this approach be an alternative to modeling the two levels, if I cannot get a multi-level model to converge?

Yes, those are cluster-robust SEs.
Reply all
Reply to author
Forward
0 new messages