##standardized assessments measurement model ```{r} standardized_assessment_cfa <- ' pre_ol =~ WJIV_Pre_OrlLang_SS + PELI_Pre_VOL_Score + PELI_Pre_COMP_Score pre_decode =~ WJIV_Pre_PhnCod_SS + PELI_Pre_AK_Score + PELI_Pre_PA_Score pre_ol ~~ pre_decode ' ``` ### Set Priors ```{r} priors <- list( nu = "normal(0, 5)", # intercepts lambda = "normal(0.1, 2)", # loadings theta = "gamma(1, 1)", # observed variable precision psi = "gamma(1, 1)", # latent variable precision rho = "uniform(-1, 1)" # latent variable correlation ) # Set the seed value, for replicability and due to issues with multidimensionality set.seed(123) # set same seed as was used with simulated data ``` ### Features of MCMC - the number of chains - the number of iterations to warmup - the total number of iterations ```{r MCMC setup} n.chains = 4 n.warmup = 100 n.burnin = 0 n.iters.per.chain.after.warmup.and.burnin = 1000 n.iters.total.per.chain = n.warmup+n.burnin+n.iters.per.chain.after.warmup.and.burnin ``` ###Run Standardized Assessments Measurement Model ```{r Combined Model} standardized.measurement.cfa <- bcfa( model = standardized_assessment_cfa, # Specify the model data = stand.TELL.complete_scaled, # Specify the data dp = priors, # Specify priors; ensure 'priors' is correctly defined n.chains = n.chains, # Set the number of chains burnin = n.warmup, # Burn-in period; 'burnin' is synonymous with 'warmup' in some contexts target = "stan", sample = n.iters.per.chain.after.warmup.and.burnin, # Number of iterations after warm-up/burn-in mcmcfile = TRUE, # Whether to write MCMC model to file save.lvs = FALSE, # Whether to save latent variable scores inits = "simple", # Initialization method bcontrol = list(cores = n.chains) # Parallelization control, using multiple cores ) ```