multilevel$interaction <- (multilevel$moderator_c * multilevel$IV_c)
MLmod.med.serial <- '
level: 1
DV ~ (wc1)*IV_c + (wc2)*moderator_c + (wc3)*interaction + (wb1)*mediator1_c + (wb2)*mediator2_c
mediator1_c ~ (wa11)*IV_c + (wa12)* moderator_c + (wa31)*interaction
mediator2_c ~ (wa21)*IV_c + (wa22)* moderator_c + (wa32)*interaction + (wd)*mediator1_c
mediator1_c ~~ mediator2_c
level: 2
DV ~ (bc1)*IV_c + (bc2)*moderator_c + (bc3)*interaction + (bb1)*mediator1_c + (bb2)*mediator2_c
mediator1_c ~ (ba11)*IV_c + (ba12)*moderator_c + (ba31)*interaction
tlb_c ~ (ba21)*IV_c + (ba22)*moderator_c + (ba32)*interaction + (bd)*mediator1_c
mediator1_c ~~ mediator2_c
# defined parameters
wind.m1 := wa11 * wb1
bind.m1 := ba11 * bb1
wind.m2 := wa21 * wb2
bind.m2 := ba21 * bb2
wind.serial := wa11 * wd* wb2
bind.serial := ba11 * bd* bb2
windex1 := wa31 * wb1
windex2 := wa32 * wb2
bindex1 := ba31 * bb1
bindex2 := ba32 * bb2
windex.serial := wa31 * wd * wb2
bindex.serial := ba31 * bd * bb2
'
MLmod.med.serial.fit <- sem(MLmod.med.serial, multilevel, cluster = "team", estimator = "MLR", bootstrap = 1000)
And this is the error I keep getting:
Error in if (fx.delta < tol) { : missing value where TRUE/FALSE needed
I would be really grateful for your help!
Best regards,
Laura
Fitting unrestricted (H1) model in group 1
EM iter: 0 fx = -8934.0914083798
EM iter: 1 fx = -4543.0880957699 fx.delta = 4391.00331261
EM iter: 2 fx = -3733.4423660440 fx.delta = 809.64572973
EM iter: 3 fx = -2969.1494916639 fx.delta = 764.29287438
EM iter: 4 fx = -2211.8537773779 fx.delta = 757.29571429
EM iter: 5 fx = -1456.8285984765 fx.delta = 755.02517890
EM iter: 6 fx = -702.7848069543 fx.delta = 754.04379152
EM iter: 7 fx = 50.7617113116 fx.delta = 753.54651827
EM iter: 8 fx = 804.0279350211 fx.delta = 753.26622371
EM iter: 9 fx = 1557.1236039216 fx.delta = 753.09566890
EM iter: 10 fx = 2310.1127167566 fx.delta = 752.98911283
EM iter: 11 fx = 3063.0642529586 fx.delta = 752.95153620
EM iter: 12 fx = 3816.3675000648 fx.delta = 753.30324711
EM iter: 13 fx = 4572.9979835792 fx.delta = 756.63048351
EM iter: 14 fx = 5377.2642435012 fx.delta = 804.26625992
EM iter: 15 fx = NA fx.delta = NA
Error in if (fx.delta < tol) { : missing value where TRUE/FALSE needed
Update: Issue solved!
For others who might encounter the same problem:
I tried to model a cross-level interaction and introduced a level 2-variable in the level 1-section. This doesn't work because the level 2-variable has no level 1-variance. For a cross-level interaction to work, one would need a random slope on level 1 instead which is not yet possible in lavaan. According to Yves, lavaan dev 0.6-4.1343 (or higher) will produce the following warning:
Warning messages:
1: In lav_data_full(data = data, group = group, cluster = cluster, :
lavaan WARNING:
Level-1 variable "mod" has no variance at the within level.
The variable appears to be a between-level variable. Please remove
this variable from the level 1 section in the model syntax.
2: In lav_h1_implied_logl(lavdata = lavdata, lavsamplestats = lavsamplestats, :
lavaan WARNING:
H1 estimation resulted in a within covariance matrix with (near)
zero variances for some of the level-1 variables: mod
Thanks a lot for the great help and the quick response!
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/d40d2d26-e874-452e-b6fd-bcf6b293dea2%40googlegroups.com.