This function generates the lavaan syntax for a cross-lagged panel model (CLPM). With random intercepts, the syntax yields the random-intercepts cross-lagged panel model (RI-CLPM). The function takes an arbitrary number of different variables, and an arbitrary number of repeated assessments.
Arguments
- vars_list
List of vectors of variable names of length t (number of repeated assessments)
- random_intercepts
(logical) Whether to add random intercepts (RI-CLPM model; default
FALSE)- parallel_paths_equal
(logical) Whether to fix parallel paths (between the same pairs of variables at different times) to equality (default
FALSE)
Details
The RI-CLPM model requires a minimum of 3 assessments, and is described in Hamaker et al (2015). The corresponding model syntax is based on Mulder & Hamaker (2021).
Direct paths are labelled using capital letters for variables and digits for time.
For example, the direct path between the first variable (A) at time 1 (1)
in vars_list and the third variable (C) at time 2 (2) is labelled A1C2.
With those labels, you can calculate custom parameters (like indirect effects)
using the := syntax in lavaan (e.g.: ind1 := A1B2*B2C3).
If parallel_paths_equal is set to TRUE, digits are removed from labels,
and parallel paths (between the same pairs of variables) are constrained to be
equal over time. For example, both A1B2 and A2B3 will become AB.
References
Hamaker, E. L., Kuiper, R. M., & Grasman, R. P. P. P. (2015). A critique of the cross-lagged panel model. Psychological Methods, 20, 102-116.
Mulder, J. D., & Hamaker, E. L. (2021). Three extensions of the random intercept cross-lagged panel model. Structural Equation Modeling: A Multidisciplinary Journal. https://doi.org/10.1080/10705511.2020.1784738.
Examples
library(lavaan)
#> This is lavaan 0.6-14
#> lavaan is FREE software! Please report any bugs.
vars <- list(
c("x1", "x2", "x3"),
c("y1", "y2", "y3")
)
get_crosslagged_model(vars) |>
sem(df) |>
summary()
#> lavaan 0.6.14 ended normally after 28 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of model parameters 17
#>
#> Number of observations 500
#>
#> Model Test User Model:
#>
#> Test statistic 1.203
#> Degrees of freedom 4
#> P-value (Chi-square) 0.878
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Expected
#> Information saturated (h1) model Structured
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|)
#> x2 ~
#> x1 (A1A2) 0.774 0.061 12.784 0.000
#> y1 (B1A2) 0.282 0.056 5.024 0.000
#> y2 ~
#> x1 (A1B2) 0.730 0.063 11.530 0.000
#> y1 (B1B2) 0.298 0.059 5.075 0.000
#> x3 ~
#> x2 (A2A3) 0.637 0.059 10.780 0.000
#> y2 (B2A3) 0.456 0.059 7.781 0.000
#> y3 ~
#> x2 (A2B3) 0.763 0.058 13.075 0.000
#> y2 (B2B3) 0.366 0.058 6.322 0.000
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|)
#> x1 ~~
#> y1 0.237 0.019 12.732 0.000
#> .x2 ~~
#> .y2 0.212 0.017 12.425 0.000
#> .x3 ~~
#> .y3 0.228 0.018 12.714 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|)
#> x1 0.318 0.020 15.811 0.000
#> .x2 0.303 0.019 15.811 0.000
#> .x3 0.335 0.021 15.811 0.000
#> y1 0.369 0.023 15.811 0.000
#> .y2 0.331 0.021 15.811 0.000
#> .y3 0.327 0.021 15.811 0.000
#>