donaldRwilliams / BGGM

Bayesian Gaussian Graphical Models
https://donaldrwilliams.github.io/BGGM/
GNU General Public License v2.0
54 stars 14 forks source link

system is computationally singular #94

Closed paradeisios closed 3 months ago

paradeisios commented 3 months ago

I have a dataset that is 127 x 56, constituted by integrer and floats. When I try to run

fit <- estimate(df, type="continuous")

I get the following error

BGGM: Posterior Sampling (Group 1)
Error in solve.default(cov(Y)) : 
  system is computationally singular: reciprocal condition number = 4.246e-17

If I scale the data, I get the following error

BGGM: Posterior Sampling 
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error: wishrnd(): given matrix is not symmetric positive definite

Session Info:


R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=nl_BE.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=nl_BE.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=nl_BE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=nl_BE.UTF-8 LC_IDENTIFICATION=C       

time zone: Asia/Tokyo
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] NetworkComparisonTest_2.2.2 emmeans_1.10.1              lme4_1.1-35.1               Matrix_1.6-5               
 [5] mgm_1.2-14                  EGAnet_2.0.6                igraph_2.0.3                bootnet_1.6                
 [9] glasso_1.11                 qgraph_1.9.8                BGGM_2.1.2.9000             lubridate_1.9.2            
[13] forcats_1.0.0               stringr_1.5.0               dplyr_1.1.2                 purrr_1.0.1                
[17] readr_2.1.4                 tidyr_1.3.0                 tibble_3.2.1                tidyverse_2.0.0            
[21] ggplot2_3.5.1              

loaded via a namespace (and not attached):
  [1] splines_4.3.3            R.oo_1.25.0              rpart_4.1.23             lifecycle_1.0.3         
  [5] rstatix_0.7.2            matrixcalc_1.0-6         Rdpack_2.6               doParallel_1.0.17       
  [9] processx_3.8.3           lattice_0.22-5           BFpack_1.3.0             MASS_7.3-60.0.1         
 [13] backports_1.4.1          magrittr_2.0.3           Hmisc_5.1-2              rmarkdown_2.22          
 [17] remotes_2.5.0            yaml_2.3.7               plotrix_3.8-4            IsingFit_0.4            
 [21] pkgbuild_1.4.3           pbapply_1.7-0            minqa_1.2.6              RColorBrewer_1.1-3      
 [25] multcomp_1.4-23          abind_1.4-5              quadprog_1.5-8           R.utils_2.12.2          
 [29] TH.data_1.1-2            pracma_2.4.4             rgl_1.3.1                nnet_7.3-19             
 [33] sandwich_3.0-2           gdata_3.0.0              ellipse_0.5.0            MatrixModels_0.5-3      
 [37] codetools_0.2-19         tidyselect_1.2.0         shape_1.4.6.1            farver_2.1.1            
 [41] IsingSampler_0.2.3       stats4_4.3.3             base64enc_0.1-3          eigenmodel_1.11         
 [45] jsonlite_1.8.8           e1071_1.7-13             mitml_0.4-5              Formula_1.2-5           
 [49] ggridges_0.5.6           survival_3.5-8           iterators_1.0.14         foreach_1.5.2           
 [53] tools_4.3.3              sna_2.7-2                snow_0.4-4               Rcpp_1.0.10             
 [57] NetworkToolbox_1.4.2     glue_1.6.2               mnormt_2.1.1             gridExtra_2.3           
 [61] pan_1.9                  Bergm_5.0.7              mgcv_1.9-1               xfun_0.39               
 [65] QRM_0.4-31               numDeriv_2016.8-1.1      withr_2.5.0              timeSeries_4032.109     
 [69] fastmap_1.1.1            GGally_2.2.1             boot_1.3-30              fansi_1.0.4             
 [73] SparseM_1.81             callr_3.7.3              digest_0.6.34            estimability_1.5.1      
 [77] timechange_0.2.0         R6_2.5.1                 mice_3.16.0              colorspace_2.1-0        
 [81] gtools_3.9.5             jpeg_0.1-10              weights_1.0.4            R.methodsS3_1.8.2       
 [85] utf8_1.2.3               generics_0.1.3           Rglpk_0.6-5.1            candisc_0.9.0           
 [89] data.table_1.14.8        corpcor_1.6.10           robustbase_0.99-3        class_7.3-22            
 [93] htmlwidgets_1.6.4        ggstats_0.6.0            pkgconfig_2.0.3          gtable_0.3.3            
 [97] bain_0.2.11              timeDate_4032.109        htmltools_0.5.8.1        lavaan_0.6-17           
[101] carData_3.0-5            rle_0.9.2                MCMCpack_1.7-0           scales_1.3.0            
[105] heplots_1.7.0            png_0.1-8                wordcloud_2.6            knitr_1.43              
[109] rstudioapi_0.14          tzdb_0.4.0               reshape2_1.4.4           curl_5.0.1              
[113] coda_0.19-4.1            statnet.common_4.9.0     checkmate_2.3.1          nlme_3.1-163            
[117] nloptr_2.0.3             zoo_1.8-12               proxy_0.4-27             cachem_1.0.8            
[121] ergm_4.6.0               parallel_4.3.3           foreign_0.8-86           desc_1.4.3              
[125] reshape_0.8.9            pillar_1.9.0             grid_4.3.3               vctrs_0.6.2             
[129] ggpubr_0.6.0             slam_0.1-51              car_3.1-2                jomo_2.7-6              
[133] xtable_1.8-4             cluster_2.1.6            htmlTable_2.4.2          evaluate_0.21           
[137] pbivnorm_0.6.0           lpSolveAPI_5.5.2.0-17.12 mvtnorm_1.2-2            cli_3.6.1               
[141] compiler_4.3.3           crayon_1.5.2             rlang_1.1.1              smacof_2.1-6            
[145] ggsignif_0.6.4           labeling_0.4.2           fdrtool_1.2.17           ps_1.7.5                
[149] plyr_1.8.8               stringi_1.7.12           psych_2.4.3              network_1.18.2          
[153] nnls_1.5                 networktools_1.5.2       gsl_2.1-8                munsell_0.5.0           
[157] glmnet_4.1-8             quantreg_5.97            hms_1.1.3                mcmc_0.9-8              
[161] extraDistr_1.10.0        trust_0.1-8              rbibutils_2.2.16         broom_1.0.4             
[165] memoise_2.0.1            DEoptimR_1.1-3           polynom_1.4-1           
ph-rast commented 3 months ago

Hi @paradeisios , could you try installing the latest version of BGGM 2.1.3 via CRAN: install.packages(BGGM). Also, I'm on R 4.4.1, this probably does not matter but if possible, you may want to upgrade to a newer R version. Let me know if it still fails -- if so, please add a reproducible example for me to work off from.

ph-rast commented 3 months ago

I'll close this issue as I can't reproduce it. Feel free to open it again in case the latest package version throws that same error. If it does, please provide sample code that reproduces the error.