Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(lcsm) library(lavaan)
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 LCSMs in R, for example:
extract_param()
: only one row per estimated parameter,extract_fit()
: fit statistics for multiple lavaan
objects can be extracted.# First fit some latent change score models # No change model uni_lcsm_01 <- fit_uni_lcsm(data = data_uni_lcsm, var = c("x1", "x2", "x3", "x4", "x5"), model = list(alpha_constant = FALSE, beta = FALSE, phi = FALSE)) # Constant change only model uni_lcsm_02 <- fit_uni_lcsm(data = data_uni_lcsm, var = c("x1", "x2", "x3", "x4", "x5"), model = list(alpha_constant = TRUE, beta = FALSE, phi = FALSE)) # Constant change and proportional change (Dual change model) uni_lcsm_03 <- fit_uni_lcsm(data = data_uni_lcsm, var = c("x1", "x2", "x3", "x4", "x5"), model = list(alpha_constant = TRUE, beta = TRUE, phi = FALSE))
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 statistics fit_uni_lcsm <- extract_fit(uni_lcsm_01, uni_lcsm_02, uni_lcsm_03) # Print table of parameter estimates knitr::kable(fit_uni_lcsm, digits = 3, caption = "Parameter estimates for bivariate LCSM")
# Now extract parameter estimates 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")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.