Closed devarajarun closed 11 months ago
I have not seen this error before. Is it correct that you are fitting the 3-factor cfa from the bcfa() help page? Also, could you paste the output of sessionInfo()?
I tried to use the example data.
The model works fine with lavaan sem function or whatever function from lavaan but the functions from blavaan shows the above mentioned error.
Is this a problem with the new Matrix package, which was updated 7 days ago?
It seems plausible that it is related to the new Matrix version. I just updated to Matrix 1.6-3 and was unable to reproduce this error. But I am on Ubuntu so would miss a Mac-specific problem.
If you haven't tried, reinstalling blavaan can sometimes solve these problems. It may also help if you post the sessionInfo().
I tried reinstalling blavaan package still the error persist.
Here is the sessioninfo() after running the blavaan function
sessionInfo() R version 4.3.1 (2023-06-16) Platform: x86_64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.3.1
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] semPlot_1.1.6 dplyr_1.1.4 ggplot2_3.4.4 Matrix_1.6-3 MatrixModels_0.5-3 blavaan_0.5-2 Rcpp_1.0.11
[8] lavaan_0.6-16 tidySEM_0.2.6 OpenMx_2.21.10
loaded via a namespace (and not attached):
[1] matrixStats_1.1.0 bitops_1.0-7 sf_1.0-14 httr_1.4.7 RColorBrewer_1.1-3
[6] tools_4.3.1 backports_1.4.1 utf8_1.2.4 R6_2.5.1 vegan_2.6-4
[11] sm_2.2-5.7.1 mgcv_1.9-0 rhdf5filters_1.12.1 permute_0.9-7 withr_2.5.2
[16] sp_2.1-1 prettyunits_1.2.0 gridExtra_2.3 nonnest2_0.5-6 fdrtool_1.2.17
[21] qgraph_1.9.8 progressr_0.14.0 cli_3.6.1 Biobase_2.60.0 fastDummies_1.7.3
[26] sandwich_3.0-2 mvtnorm_1.2-3 pbapply_1.7-2 proxy_0.4-27 QuickJSR_1.0.7
[31] pbivnorm_0.6.0 StanHeaders_2.26.28 foreign_0.8-85 dbscan_1.1-11 parallelly_1.36.0
[36] lisrelToR_0.1.5 rstudioapi_0.15.0 generics_0.1.3 gtools_3.9.4 xlsx_0.6.5
[41] car_3.1-2 spdep_1.2-8 zip_2.3.0 inline_0.3.19 loo_2.6.0
[46] interp_1.1-4 biomformat_1.28.0 fansi_1.0.5 S4Vectors_0.38.2 abind_1.4-5
[51] lifecycle_1.0.4 CompQuadForm_1.4.3 carData_3.0-5 rhdf5_2.44.0 adegraphics_1.0-21
[56] Rtsne_0.16 grid_4.3.1 promises_1.2.1 crayon_1.5.2 lattice_0.22-5
[61] cowplot_1.1.1 xlsxjars_0.6.1 tmvnsim_1.0-2 knitr_1.45 pillar_1.9.0
[66] bain_0.2.10 boot_1.3-28.1 corpcor_1.6.10 future.apply_1.11.0 codetools_0.2-19
[71] wk_0.9.0 glue_1.6.2 RNeXML_2.4.11 data.table_1.14.8 vctrs_0.6.4
[76] png_0.1-8 gtable_0.3.4 gsubfn_0.7 xfun_0.41 openxlsx_4.2.5.2
[81] mime_0.12 phylobase_0.8.10 coda_0.19-4 survival_3.5-7 pheatmap_1.0.12
[86] rJava_1.0-6 iterators_1.0.14 MplusAutomation_1.1.0 jmv_2.4.11 units_0.8-4
[91] ellipsis_0.3.2 nlme_3.1-163 phyloseq_1.44.0 progress_1.2.2 rstan_2.32.3
[96] GenomeInfoDb_1.36.4 mi_1.1 rpart_4.1.21 KernSmooth_2.23-22 Hmisc_5.1-1
[101] colorspace_2.1-0 spData_2.3.0 BiocGenerics_0.46.0 DBI_1.1.3 nnet_7.3-19
[106] ade4_1.7-22 mnormt_2.1.1 tidyselect_1.2.0 processx_3.8.2 compiler_4.3.1
[111] adespatial_0.3-23 microbiome_1.22.0 htmlTable_2.4.2 adephylo_1.1-16 xml2_1.3.5
[116] checkmate_2.3.0 scales_1.2.1 psych_2.3.9 classInt_0.4-10 quadprog_1.5-8
[121] callr_3.7.3 sem_3.1-15 stringr_1.5.1 digest_0.6.33 microViz_0.11.0
[126] minqa_1.2.6 rmarkdown_2.25 XVector_0.40.0 base64enc_0.1-3 htmltools_0.5.7
[131] pkgconfig_2.0.3 jpeg_0.1-10 lme4_1.1-35.1 fastmap_1.1.1 htmlwidgets_1.6.2
[136] rlang_1.1.2 shiny_1.8.0 jmvcore_2.4.7 zoo_1.8-12 jsonlite_1.8.7
[141] RCurl_1.98-1.13 magrittr_2.0.3 Formula_1.2-5 GenomeInfoDbData_1.2.10 s2_1.1.4
[146] bayesplot_1.10.0 texreg_1.39.3 Rhdf5lib_1.22.1 munsell_0.5.0 rockchalk_1.8.157
[151] ape_5.7-1 proto_1.0.0 stringi_1.8.1 zlibbioc_1.46.0 MASS_7.3-60
[156] plyr_1.8.9 pkgbuild_1.4.2 parallel_4.3.1 listenv_0.9.0 deldir_1.0-9
[161] rncl_0.8.7 adegenet_2.1.10 kutils_1.73 Biostrings_2.68.1 splines_4.3.1
[166] pander_0.6.5 multtest_2.56.0 hms_1.1.3 ps_1.7.5 igraph_1.5.1
[171] uuid_1.1-1 seqinr_4.2-30 reshape2_1.4.4 stats4_4.3.1 rstantools_2.3.1.1
[176] XML_3.99-0.15 evaluate_0.23 latticeExtra_0.6-30 RcppParallel_5.1.7 rdacca.hp_1.1-0
[181] nloptr_2.0.3 foreach_1.5.2 httpuv_1.6.12 RANN_2.6.1 NMIT_0.1
[186] tidyr_1.3.0 purrr_1.0.2 future_1.33.0 xtable_1.8-4 funrar_1.5.0
[191] e1071_1.7-13 later_1.3.1 glasso_1.11 class_7.3-22 arm_1.13-1
[196] tibble_3.2.1 IRanges_2.34.1 cluster_2.1.4 corrplot_0.92 globals_0.16.2
Thanks for the info. I now remember seeing some issues long ago in relation to the rstan function extract_sparse_parts()
, which is used by blavaan to set up the Stan model. It might be interesting to see whether this works in a fresh R session:
x <- matrix(1:4, 2, 2)
rstan::extract_sparse_parts(x)
I believe that your error message is coming from extract_sparse_parts()
, but I am not yet sure how to fix it!
I think there is a problem with extract_sparse_parts()
library(blavaan) Loading required package: Rcpp This is blavaan 0.5-2 On multicore systems, we suggest use of future::plan("multicore") or future::plan("multisession") for faster post-MCMC computations. x <- matrix(1:4, 2, 2) rstan::extract_sparse_parts(x) Error in Matrix::t(A) : invalid 'lazy' to 'R_sparse_transpose'
In your last post, I believe the library(blavaan)
line would not be necessary to see the error, which means that the problem lies with rstan. But let me know if you need to load blavaan to see the error.
I am happy to reopen this if it seems that blavaan is involved in the error.
Please tell me how I can overcome this error. I am using R version 4.3.1 in MacOS. Tried reinstalling Matrix package, still I get the same error.
[1] "Error in Matrix::t(A) : invalid 'lazy' to 'R_sparse_transpose'\n" attr(,"class") [1] "try-error" attr(,"condition") <simpleError in Matrix::t(A): invalid 'lazy' to 'R_sparse_transpose'> Error in blavaan(HS.model, data = HolzingerSwineford1939, auto.var = TRUE, : blavaan ERROR: problem with translation from lavaan to MCMC syntax.