Closed maugavilla closed 4 years ago
I think the markdown mangled your code, but I got it and think it is now fixed. But I still need to test it more...
Oh, I am sorry, apparentle it didnt like the use of quotes for the lavaan syntax
I tried the github version, and worked for my example
thanks
Ed
I was running a couple of examples of longitudinal measurement invariance. The issue only happened with factor loading invariance, didint happened with intercept invariance. And when I did partial measurement invariance I get issues
If between time points, 2 of them are equal and only 1 factor loading is different it works fine (s_g3) ft3 =~ l1as_g3 + l2r_g3 + l3m_g3 ft5 =~ l1bs_g5 + l2r_g5 + l3m_g5 ft8 =~ l1bs_g8 + l2r_g8 + l3*m_g8
But when for an indicator, all factor loadings are different over time it doesnt work ft3 =~ l1as_g3 + l2r_g3 + l3m_g3 ft5 =~ l1bs_g5 + l2r_g5 + l3m_g5 ft8 =~ l1cs_g8 + l2r_g8 + l3*m_g8
Stan reports this issue over and over and the chains dont sample Chain 2: Exception: Exception: []: accessing element out of range. index 7 out of range; expecting index to be between 1 and 5; index position = 1load_par2 (in 'model_stanmarg' at line 115) (in 'model_stanmarg' at line 823) small_example_data.xlsx
With the data set I am attaching this code produce the error for me
weak_mod <- '
factor loadings
ft3 =~ l1as_g3 + l2r_g3 + l3m_g3 ft5 =~ l1bs_g5 + l2r_g5 + l3m_g5 ft8 =~ l1cs_g8 + l2r_g8 + l3*m_g8
residual covariances
s_g3 ~~ s_g5 + s_g8 s_g5 ~~ s_g8 r_g3 ~~ r_g5 + r_g8 r_g5 ~~ r_g8 m_g3 ~~ m_g5 + m_g8 m_g5 ~~ m_g8
Factor means
ft3 ~01 ft5 ~01 ft8 ~0*1
factor variances
ft3 ~~ 1ft3 ft5 ~~ NAft5 ft8 ~~ NA*ft8
item intercepts
s_g3 ~1 r_g3 ~1 m_g3 ~1 s_g5 ~1 r_g5 ~1 m_g5 ~1 s_g8 ~1 r_g8 ~1 m_g8 ~1 '
fit_weak <- bcfa(weak_mod, std.lv=T, data = dat2, n.chains = 3, burnin = 3000, sample = 1000, target="stan", bcontrol = list(cores=3))
summary(fit_weak, standardize=T, rsquare=T, neff=T)
Matrix products: default
locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] blavaan_0.3-11.649 Rcpp_1.0.5 lavaan_0.6-7
loaded via a namespace (and not attached): [1] TH.data_1.0-10 colorspace_1.4-1 ellipsis_0.3.1 ggridges_0.5.2
[5] brms_2.13.5 rsconnect_0.8.16 estimability_1.3 markdown_1.1
[9] base64enc_0.1-3 rstudioapi_0.11 listenv_0.8.0 rstan_2.21.2
[13] MatrixModels_0.4-1 DT_0.15 fansi_0.4.1 mvtnorm_1.1-1
[17] bridgesampling_1.0-0 codetools_0.2-16 splines_4.0.2 mnormt_2.0.2
[21] shinythemes_1.1.2 bayesplot_1.7.2 jsonlite_1.7.1 mcmc_0.9-7
[25] shiny_1.5.0 compiler_4.0.2 backports_1.1.10 emmeans_1.5.1
[29] assertthat_0.2.1 Matrix_1.2-18 fastmap_1.0.1 cli_2.0.2
[33] later_1.1.0.1 htmltools_0.5.0 quantreg_5.67 prettyunits_1.1.1
[37] tools_4.0.2 igraph_1.2.5 coda_0.19-3 gtable_0.3.0
[41] glue_1.4.2 reshape2_1.4.4 dplyr_1.0.2 V8_3.2.0
[45] vctrs_0.3.4 nlme_3.1-149 conquer_1.0.2 crosstalk_1.1.0.1
[49] stringr_1.4.0 globals_0.13.0 ps_1.3.4 mime_0.9
[53] miniUI_0.1.1.1 CompQuadForm_1.4.3 lifecycle_0.2.0 runjags_2.0.4-6
[57] semTools_0.5-3 gtools_3.8.2 future_1.18.0 MASS_7.3-51.6
[61] zoo_1.8-8 scales_1.1.1 colourpicker_1.1.0 promises_1.1.1
[65] Brobdingnag_1.2-6 parallel_4.0.2 sandwich_2.5-1 inline_0.3.16
[69] SparseM_1.78 shinystan_2.5.0 curl_4.3 gridExtra_2.3
[73] ggplot2_3.3.2 loo_2.3.1 StanHeaders_2.21.0-6 stringi_1.5.3
[77] dygraphs_1.1.1.6 pkgbuild_1.1.0 rlang_0.4.7 pkgconfig_2.0.3
[81] matrixStats_0.56.0 lattice_0.20-41 purrr_0.3.4 rstantools_2.1.1
[85] htmlwidgets_1.5.1 processx_3.4.4 tidyselect_1.1.0 plyr_1.8.6
[89] magrittr_1.5 R6_2.4.1 generics_0.0.2 multcomp_1.4-13
[93] pillar_1.4.6 withr_2.2.0 xts_0.12.1 survival_3.1-12
[97] abind_1.4-5 tibble_3.0.3 future.apply_1.6.0 crayon_1.3.4
[101] nonnest2_0.5-5 tmvnsim_1.0-2 grid_4.0.2 pbivnorm_0.6.0
[105] callr_3.4.4 threejs_0.3.3 digest_0.6.25 xtable_1.8-4
[109] httpuv_1.5.4 MCMCpack_1.4-9 RcppParallel_5.0.2 stats4_4.0.2
[113] munsell_0.5.0 shinyjs_2.0.0