This code depends on the tidyverse library for the str_glue
function
library(here) # import the file so we can use define_longitudinal_measurement_invariance_model source(here("R/latent_growth_curve_model.r")) df = data.frame( cm01ec_lat= c("ec01_cmpar1", "ec01_cmpar2", "ec01_cmpar3", "ec01_cmpar4"), cm03ec_lat= c("ec03_cmpar1", "ec03_cmpar2", "ec03_cmpar3", "ec03_cmpar4"), cm05ec_lat= c("ec05_cmpar1", "ec05_cmpar2", "ec05_cmpar3", "ec05_cmpar4"), cm07ec_lat= c("ec07_cmpar1", "ec07_cmpar2", "ec07_cmpar3", "ec07_cmpar4") ) # You can generate CONFIGURAL, WEAK, STRONG, PARTIAL_STRONG, OR STRICT models variable_of_interest_name = "ec" ec_cm_no_growth <- define_latent_growth_curve_model( df, variable_of_interest_name, "NO_GROWTH", "PARTIAL_STRONG", c(2,3) ) ec_cm_linear <- define_latent_growth_curve_model( df, variable_of_interest_name, "LINEAR", "PARTIAL_STRONG", c(2,3), c(0, 2, 4, 6) ) ec_cm_latent_basis <- define_latent_growth_curve_model( df, variable_of_interest_name, "LATENT_BASIS", "STRONG", slope_weights = c(0, NA, NA, 6) ) # You could then plug it into your cool cfa function #ec_cm_latent_basis <- sem(ec_cm_latent_basis, data=dat, mimic = "mplus") #summary(ec_cm_latent_basis, fit.measures=TRUE)
writeLines(ec_cm_latent_basis)
writeLines(ec_cm_no_growth)
writeLines(ec_cm_linear)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.