I have created a website on how to run the random intercept cross-lagged panel model (RI-CLPM), and various extensions on it, in lavaan. One of the extensions is including a time-invariant outcome (z2). Quite simple from a modeling perspective, but I can't seem to get lavaan to run the model.
You can find the code below. The model also includes a time-invariant predictor for the observed variables (z1). The estimation terminates normally with just z1, but as soon as I add the line "z2 ~ RIx + RIy", lavaan tells me the initial model-implied matrix is not positive definite. The model, however, does run in Mplus. If you want to recreate the problem, you can find simulated data (RICLPM-Z.dat) on
https://github.com/JeroenDMulder/RI-CLPM/tree/master/dataAny help/thoughts/pointers in the right direction with this seemingly small issue would be greatly appreciated :)
RICLPM3.ext1 <- '
# Create between components (random intercepts)
RIx =~ 1*x1 + 1*x2 + 1*x3 + 1*x4 + 1*x5
RIy =~ 1*y1 + 1*y2 + 1*y3 + 1*y4 + 1*y5
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
# Regression of time-invariant outcome z2 on random intercepts.
z2 ~ RIx + RIy
# Create within-person centered variables
wx1 =~ 1*x1
wx2 =~ 1*x2
wx3 =~ 1*x3
wx4 =~ 1*x4
wx5 =~ 1*x5
wy1 =~ 1*y1
wy2 =~ 1*y2
wy3 =~ 1*y3
wy4 =~ 1*y4
wy5 =~ 1*y5
# Regression of observed variables on z1 (constrained).
x1 + x2 + x3 + x4 + x5 ~ s1*z1 # Constrained over time.
y1 + y2 + y3 + y4 + y5 ~ s2*z1 # Constrained over time.
# Estimate the lagged effects between the within-person centered variables.
wx2 + wy2 ~ wx1 + wy1
wx3 + wy3 ~ wx2 + wy2
wx4 + wy4 ~ wx3 + wy3
wx5 + wy5 ~ wx4 + wy4
# Estimate the covariance between the within-person centered variables at the first wave.
wx1 ~~ wy1 # Covariance
# Estimate the covariances between the residuals of the within-person centered variables (the innovations).
wx2 ~~ wy2
wx3 ~~ wy3
wx4 ~~ wy4
wx5 ~~ wy5
# Estimate the (residual) variance of the within-person centered variables.
wx1 ~~ wx1 # Variances
wy1 ~~ wy1
wx2 ~~ wx2 # Residual variances
wy2 ~~ wy2
wx3 ~~ wx3
wy3 ~~ wy3
wx4 ~~ wx4
wy4 ~~ wy4
wx5 ~~ wx5
wy5 ~~ wy5
'
RICLPM3.ext1.fit <- lavaan(RICLPM3.ext1, data = datZ, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(RICLPM3.ext1.fit, standardized = T)