Generate lavaan syntax for latent change score models

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(lcsm)

Univariate LCSM syntax

The example below shows how to specify a generic univariate latent change score model using the function specify_uni_lcsm().

uni_lcsm_syntax <- specify_uni_lcsm(timepoints = 5,
                                    var = "x",  
                                    change_letter = "g",
                                    model = list(alpha_constant = TRUE, 
                                                 beta = TRUE, 
                                                 phi = TRUE))
# To get a readable output use cat() function
cat(uni_lcsm_syntax)

Bivariate LCSM syntax

True Score to Change Score

# Specify bivariate LCS model
lavaan_bi_lcsm_delta_01 <- specify_bi_lcsm(timepoints = 5, 
                                           var_x = "x",
                                           model_x = list(alpha_constant = TRUE, 
                                                          beta = TRUE, 
                                                          phi = TRUE),
                                           var_y = "y",  
                                           model_y = list(alpha_constant = TRUE, 
                                                          beta = TRUE, 
                                                          phi = TRUE),  
                                           coupling = list(delta_lag_xy = TRUE, 
                                                           delta_lag_yx = TRUE),
                                           change_letter_x = "g",
                                           change_letter_y = "j")
# To get a readable output use cat() function
cat(lavaan_bi_lcsm_delta_01)

True Score to Change Score

# Specify bivariate LCS model
lavaan_bi_lcsm_xi_01 <- specify_bi_lcsm(timepoints = 5, 
                                        var_x = "x",
                                        model_x = list(alpha_constant = TRUE, 
                                                       beta = TRUE, 
                                                       phi = TRUE),
                                        var_y = "y",  
                                        model_y = list(alpha_constant = TRUE, 
                                                       beta = TRUE, 
                                                       phi = TRUE),  
                                        coupling = list(xi_lag_xy = TRUE, 
                                                        xi_lag_yx = TRUE),
                                        change_letter_x = "g",
                                        change_letter_y = "j")
# To get a readable output use cat() function
cat(lavaan_bi_lcsm_xi_01)

TODOs



Try the lcsm package in your browser

Any scripts or data that you put into this service are public.

lcsm documentation built on July 25, 2020, 1:06 a.m.