Hi!
I am new in R and also in Lavaan and got a little stuck unfortunately.
I want to run a 2-level cross lagged panel model to find out within and between subject cross lagged paths. To specify, i made the following model with the accessory figure.
We have data from +-80 people and one individual shows multiple data points. One of the variables is a binary variable, which i know is not ideal in Lavaan in R.
When I run this model I get the error: lavaan WARNING: the optimizer warns that a solution has NOT been found!
I'm not sure about my definition of Level 2. If I remove the AR paths out of level 2, the model runs normally. Could it be correct that the AR paths (residual correlation) do not have to be included in level 2? Or might be another point in my model cause the problem?
Thanks in advance!
Dunja
Model1 <- '
level: 1
#residual correlations (AR paths)
Xt ~~ Xt_1 #a
Yt ~~ Yt_1 #b
#covariances (CS paths)
Xt_1 ~~ Yt_1 #c
Xt ~~ Yt #d
#cross-lagged paths
Yt ~ Xt_1 #e
Xt ~ Yt_1 #f
level: 2
#residual correlations (AR paths)
Xt ~~ Xt_1 #a
Yt ~~ Yt_1 #b
#covariances (CS paths)
Xt_1 ~~ Yt_1 #c
Xt ~~ Yt #d
#cross-lagged paths
Yt ~ Xt_1 #e
Xt ~ Yt_1 #f
'
#model fit
fit <- sem(model = Model1, data = d1,
std.lv=TRUE, cluster = "subjectid")
summary (fit, fit.measures=TRUE)