if (FALSE) {
#————————————————————————————————————————————————————————————————————————————
# Step-wise Procedure (Sukpan & Kuiper, 2026)
#
# Note that only the first step is shown in this example:
# - CLPM versus RI-CLPM(Kappa)
# - CLPM versus RI-CLPM(Omega)
#
# Model specification based on code provided on the accompanying website of
# Mulder and Hamaker (2021)
#——————————————————————————————————————
## Model Specification: Cross-Lagged Panel Model (CLPM)
## i.e., Var(Kappa) = 0, Var(Omega) = 0, Cov(Kappa, Omega) = 0
mod.clpm <- '
# Create between components (random intercepts)
RIx =~ 1*x1 + 1*x2 + 1*x3
RIy =~ 1*y1 + 1*y2 + 1*y3
# Create within-person centered variables
wx1 =~ 1*x1
wx2 =~ 1*x2
wx3 =~ 1*x3
wy1 =~ 1*y1
wy2 =~ 1*y2
wy3 =~ 1*y3
# Estimate lagged effects between within-person centered variables
wx2 + wy2 ~ wx1 + wy1
wx3 + wy3 ~ wx2 + wy2
# Estimate covariance between within-person centered variables at first wave
wx1 ~~ wy1 # Covariance
# Estimate covariances between residuals of within-person centered variables
wx2 ~~ wy2
wx3 ~~ wy3
# Fix variance and covariance of random intercepts to zero, i.e.,
RIx ~~ 0*RIx
RIy ~~ 0*RIy
RIx ~~ 0*RIy
# Estimate (residual) variance of within-person centered variables
wx1 ~~ wx1
wy1 ~~ wy1
wx2 ~~ wx2
wy2 ~~ wy2
wx3 ~~ wx3
wy3 ~~ wy3
'
#——————————————————————————————————————
## Model Specification: Random Intercept Cross-Lagged Panel Model RI-CLPM(Kappa)
## i.e., Var(Kappa) > 0, Var(Omega) = 0, Cov(Kappa, Omega) = 0
mod.ri.clpm.k <- '
# Create between components (random intercepts)
RIx =~ 1*x1 + 1*x2 + 1*x3
RIy =~ 1*y1 + 1*y2 + 1*y3
# Create within-person centered variables
wx1 =~ 1*x1
wx2 =~ 1*x2
wx3 =~ 1*x3
wy1 =~ 1*y1
wy2 =~ 1*y2
wy3 =~ 1*y3
# Estimate lagged effects between within-person centered variables
wx2 + wy2 ~ wx1 + wy1
wx3 + wy3 ~ wx2 + wy2
# Estimate covariance between within-person centered variables at first wave
wx1 ~~ wy1
# Estimate covariances between residuals of within-person centered variables
wx2 ~~ wy2
wx3 ~~ wy3
# Fix variance of random intercept RIy and covariance with RIx to zero
RIx ~~ RIx
RIy ~~ 0*RIy
RIx ~~ 0*RIy
# Estimate (residual) variance of within-person centered variables
wx1 ~~ wx1
wy1 ~~ wy1
wx2 ~~ wx2
wy2 ~~ wy2
wx3 ~~ wx3
wy3 ~~ wy3
'
#——————————————————————————————————————
## Model Specification: Random Intercept Cross-Lagged Panel Model RI-CLPM(Omega)
## i.e., Var(Kappa) = 0, Var(Omega) > 0, Cov(Kappa, Omega) = 0
mod.ri.clpm.o <- '
# Create between components (random intercepts)
RIx =~ 1*x1 + 1*x2 + 1*x3
RIy =~ 1*y1 + 1*y2 + 1*y3
# Create within-person centered variables
wx1 =~ 1*x1
wx2 =~ 1*x2
wx3 =~ 1*x3
wy1 =~ 1*y1
wy2 =~ 1*y2
wy3 =~ 1*y3
# Estimate lagged effects between within-person centered variables
wx2 + wy2 ~ wx1 + wy1
wx3 + wy3 ~ wx2 + wy2
# Estimate covariance between within-person centered variables at first wave
wx1 ~~ wy1 # Covariance
# Estimate covariances between residuals of within-person centered variables
wx2 ~~ wy2
wx3 ~~ wy3
# Fix variance of random intercept RIx and covariance with RIy to zero
RIx ~~ 0*RIx
RIy ~~ RIy
RIx ~~ 0*RIy
# Estimate (residual) variance of within-person centered variables
wx1 ~~ wx1
wy1 ~~ wy1
wx2 ~~ wx2
wy2 ~~ wy2
wx3 ~~ wx3
wy3 ~~ wy3
'
#——————————————————————————————————————
## Estimate Models
#
# Note that the example analysis cannot be conduct as the data set 'data'
# is not available.
# CLPM
fit.clpm <- lavaan(mod.clpm, data = data, estimator = "MLR")
# RI-CLPM(Kappa)
fit.ri.clpm.k <- lavaan(mod.ri.clpm.k, data = data, estimator = "MLR")
# RI-CLPM(Omega)
fit.ri.clpm.o <- lavaan(mod.ri.clpm.o, data = data, estimator = "MLR")
#···················
# Chi-Bar-Square Difference Test
# CLPM vs. RI-CLPM(Kappa)
difftest.chibarsq(fit.clpm, fit.ri.clpm.k)
# CLPM vs. RI-CLPM(Omega)
difftest.chibarsq(fit.clpm, fit.ri.clpm.o)
}
Run the code above in your browser using DataLab