Parameter estimates and fit statistics of latent change score models

library(lcsm)

The main underlying functions to extract parameters and fit statistics come from the broom package: broom::tidy() and broom::glance(). The functions extract_param() and extract_fit() offer some tools that I find helpful when running LCS models in R, for example:

A table of the description of all parameters that can be estimated is shown here.

Create some univariate models

# First create a lavaan object
uni_lcsm_01 <- fit_uni_lcsm(data = data_bi_lcsm, 
                            var = c("x1", "x2", "x3", "x4", "x5"),
                            model = list(alpha_constant = FALSE, 
                                         beta = FALSE, 
                                         phi = FALSE))

uni_lcsm_02 <- fit_uni_lcsm(data = data_bi_lcsm, 
                            var = c("x1", "x2", "x3", "x4", "x5"),
                            model = list(alpha_constant = TRUE, 
                                         beta = FALSE, 
                                         phi = FALSE))

uni_lcsm_03 <- fit_uni_lcsm(data = data_bi_lcsm, 
                            var = c("x1", "x2", "x3", "x4", "x5"),
                            model = list(alpha_constant = TRUE, 
                                         beta = TRUE, 
                                         phi = FALSE))

Extract fit statistics

This function takes the lavaan objects as input and returns some fit statistics. More fit statistics can be returned using the argument details = TRUE.


extract_fit(uni_lcsm_01, uni_lcsm_02, uni_lcsm_03)
#> # A tibble: 3 x 8
#>   model  chisq  npar    aic    bic   cfi  rmsea   srmr
#>   <chr>  <dbl> <dbl>  <dbl>  <dbl> <dbl>  <dbl>  <dbl>
#> 1 1     6527.      3 12139. 12151. 0     0.875  6.26  
#> 2 2       33.3     6  5651.  5676. 0.994 0.0525 0.0534
#> 3 3       33.2     7  5653.  5682. 0.993 0.0557 0.0519

Extract parameters

# Now extract parameter estimates
# Only extract first 7 columns for this example by adding [ , 1:7]
param_uni_lcsm_02 <- extract_param(uni_lcsm_03, printp = TRUE)

# Print table of parameter estimates
knitr::kable(param_uni_lcsm_02, 
             digits = 3, 
             caption = "Parameter estimates for bivariate LCSM")
Parameter estimates for bivariate LCSM
label estimate std.error statistic p.value conf.low conf.high std.lv std.all std.nox
gamma_lx1 21.075 0.037 565.047 < .001 21.002 21.149 30.574 30.574 30.574
sigma2_lx1 0.475 0.038 12.420 < .001 0.400 0.550 1.000 1.000 1.000
sigma2_ux 0.213 0.008 26.674 < .001 0.198 0.229 0.213 0.310 0.310
alpha_g2 -1.803 0.118 -15.282 < .001 -2.034 -1.572 -3.303 -3.303 -3.303
sigma2_g2 0.298 0.023 13.149 < .001 0.254 0.343 1.000 1.000 1.000
sigma_g2lx1 0.156 0.020 7.797 < .001 0.117 0.195 0.415 0.415 0.415
beta_x -0.002 0.006 -0.329 .742 -0.015 0.010 -0.003 -0.003 -0.003

TODOs