I want to run a multilevel cross-lagged panel model with 7 waves for two variables (x1-x7; y1-y7).
VARIABLE:
NAMES ARE
ID day v_day
v_min cpm Sedentary
light life mod vig lightlife
mvpa mvpab sed10 sed30 sed60 sedp
lightlifep modp vigp mvpap totalPA totalPAp Sleep Sleep2
sex age eth;
Cluster = ID; !Specifies the person ID
Usevar = Sleep Sedentary;
Lagged = Sedentary(1) Sleep(1) ; !lags sedentary & sleep by 1
MISSING ARE ALL(-999);
Analysis:
TYPE = twolevel Random;
Estimator = Bayes; !DSEM requires Bayes
Proc= 2;
Biter= (5000);
bseed = 526;
thin = 10;
Model:
%WITHIN%
!Random Slopes;
SED_Lag | Sedentary ON Sedentary&1; !autoregressive path for sedentary
SED_Sle | Sedentary ON Sleep&1; !Crosslagged predicting sedentary
SLE_Sed | Sleep ON Sedentary; !Crosslagged predicting sleep
SLE_lag | Sleep ON Sleep&1; !autoregessive path for sleep
%Between% ! Allowing for correlated error terms
Sedentary WITH Sleep;
Sed_Lag WITH SED_Sle SLE_sed SLE_lag Sedentary Sleep;
SED_sle WITH SLE_sed SLE_lag Sedentary Sleep;
SLE_sed WITH SLE_lag Sedentary Sleep;
SLE_lag WITH Sedentary Sleep;
OUTPUT: STDYX; !Standardized output to compare cross lagged effects
I wonder if it possible to eplicate this in lavaan, and if so, what the code would looks like? or is there a better way of doing it?