danheck / TreeBUGS

R package for fitting hierarchical multinomial processing tree (MPT) models
12 stars 5 forks source link

Error: Index out of range when calculating PPPs #6

Closed mariusbarth closed 4 years ago

mariusbarth commented 4 years ago

Hi Daniel,

I think I encountered a bug in the PPP() function. Applying PPP() to a traitMPT results in the following error message. If you have an idea how to easily fix it, let me know. I will try to take a look into it this weekend.

Best regards, Marius

PPP(mpt_model)
 Fehler in checkForRemoteErrors(val) : 
  4 nodes produced errors; first error: Indizierung außerhalb der Grenzen 
9. stop(count, " nodes produced errors; first error: ", firstmsg, 
    domain = NA) 
8. checkForRemoteErrors(val) 
7. staticClusterApply(cl, fun, length(x), argfun) 
6. clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, ...) 
5. do.call(c, clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, ...), quote = TRUE) 
4. parLapply(cl = cl, X = arglist, fun = FUN, ..., chunk.size = chunk.size) 
3. parApply(cl, cbind(par.thetaFE, par.ind), 1, getPostPred) at posteriorPredictive.R#177
2. posteriorPredictive(fittedModel, M, expected = TRUE, nCPU = nCPU) at PPP.R#29
1. PPP(mpt_model) 

My session info:

> devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.3 (2020-02-29)
 os       Ubuntu 16.04.6 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language de_DE                       
 collate  de_DE.UTF-8                 
 ctype    de_DE.UTF-8                 
 tz       Europe/Berlin               
 date     2020-05-14                  

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package      * version     date       lib source                            
 abind          1.4-5       2016-07-21 [1] CRAN (R 3.6.0)                    
 afex         * 0.27-2      2020-03-28 [1] CRAN (R 3.6.3)                    
 assertthat     0.2.1       2019-03-21 [1] CRAN (R 3.6.0)                    
 backports      1.1.6       2020-04-05 [1] CRAN (R 3.6.3)                    
 BayesFactor  * 0.9.12-4.2  2018-05-19 [1] CRAN (R 3.6.0)                    
 beeswarm       0.2.3       2016-04-25 [1] CRAN (R 3.6.0)                    
 boot           1.3-25      2020-04-26 [4] CRAN (R 3.6.3)                    
 broom          0.7.0.9000  2020-05-12 [1] Github (mariusbarth/broom@c878e6d)
 callr          3.4.3       2020-03-28 [1] CRAN (R 3.6.3)                    
 car            3.0-7       2020-03-11 [1] CRAN (R 3.6.3)                    
 carData        3.0-3       2019-11-16 [1] CRAN (R 3.6.1)                    
 cellranger     1.1.0       2016-07-27 [1] CRAN (R 3.6.0)                    
 cli            2.0.2       2020-02-28 [1] CRAN (R 3.6.3)                    
 coda         * 0.19-3      2019-07-05 [1] CRAN (R 3.6.0)                    
 codetools      0.2-16      2018-12-24 [4] CRAN (R 3.5.2)                    
 colorspace     1.4-1       2019-03-18 [1] CRAN (R 3.6.0)                    
 contfrac       1.1-12      2018-05-17 [1] CRAN (R 3.6.0)                    
 crayon         1.3.4       2017-09-16 [1] CRAN (R 3.6.0)                    
 curl           4.3         2019-12-02 [1] CRAN (R 3.6.1)                    
 data.table     1.12.8      2019-12-09 [1] CRAN (R 3.6.1)                    
 DBI            1.1.0       2019-12-15 [1] CRAN (R 3.6.1)                    
 dbplyr         1.4.3       2020-04-19 [1] CRAN (R 3.6.3)                    
 desc           1.2.0       2018-05-01 [1] CRAN (R 3.6.0)                    
 deSolve        1.28        2020-03-08 [1] CRAN (R 3.6.3)                    
 devtools       2.3.0       2020-04-10 [1] CRAN (R 3.6.3)                    
 digest         0.6.25      2020-02-23 [1] CRAN (R 3.6.3)                    
 dplyr        * 0.8.99.9003 2020-05-12 [1] Github (tidyverse/dplyr@d2627f7)  
 ellipsis       0.3.0       2019-09-20 [1] CRAN (R 3.6.1)                    
 elliptic       1.4-0       2019-03-14 [1] CRAN (R 3.6.0)                    
 emmeans      * 1.4.6       2020-04-19 [1] CRAN (R 3.6.3)                    
 estimability   1.3         2018-02-11 [1] CRAN (R 3.6.0)                    
 fansi          0.4.1       2020-01-08 [1] CRAN (R 3.6.1)                    
 farver         2.0.3       2020-01-16 [1] CRAN (R 3.6.3)                    
 forcats      * 0.5.0       2020-03-01 [1] CRAN (R 3.6.3)                    
 foreign        0.8-76      2020-03-03 [4] CRAN (R 3.6.3)                    
 fs             1.4.1       2020-04-04 [1] CRAN (R 3.6.3)                    
 generics       0.0.2       2018-11-29 [1] CRAN (R 3.6.0)                    
 ggplot2      * 3.3.0       2020-03-05 [1] CRAN (R 3.6.3)                    
 glue           1.4.1       2020-05-13 [1] CRAN (R 3.6.3)                    
 gtable         0.3.0       2019-03-25 [1] CRAN (R 3.6.0)                    
 gtools         3.8.2       2020-03-31 [1] CRAN (R 3.6.3)                    
 haven          2.2.0       2019-11-08 [1] CRAN (R 3.6.1)                    
 highr          0.8         2019-03-20 [1] CRAN (R 3.6.0)                    
 hms            0.5.3       2020-01-08 [1] CRAN (R 3.6.1)                    
 httr           1.4.1       2019-08-05 [1] CRAN (R 3.6.1)                    
 hypergeo       1.2-13      2016-04-07 [1] CRAN (R 3.6.0)                    
 jsonlite       1.6.1       2020-02-02 [1] CRAN (R 3.6.3)                    
 knitr          1.28        2020-02-06 [1] CRAN (R 3.6.3)                    
 labeling       0.3         2014-08-23 [1] CRAN (R 3.6.0)                    
 latex2exp      0.4.0       2015-11-30 [1] CRAN (R 3.6.0)                    
 lattice        0.20-41     2020-04-02 [1] CRAN (R 3.6.3)                    
 lifecycle      0.2.0       2020-03-06 [1] CRAN (R 3.6.3)                    
 lme4         * 1.1-23      2020-04-07 [1] CRAN (R 3.6.3)                    
 lmerTest       3.1-2       2020-04-08 [1] CRAN (R 3.6.3)                    
 logspline      2.1.16      2020-05-08 [1] CRAN (R 3.6.3)                    
 lubridate      1.7.8       2020-04-06 [1] CRAN (R 3.6.3)                    
 magrittr       1.5         2014-11-22 [1] CRAN (R 3.6.0)                    
 MASS           7.3-51.6    2020-04-26 [4] CRAN (R 3.6.3)                    
 Matrix       * 1.2-18      2019-11-27 [4] CRAN (R 3.6.1)                    
 MatrixModels   0.4-1       2015-08-22 [1] CRAN (R 3.6.0)                    
 memoise        1.1.0       2017-04-21 [1] CRAN (R 3.6.0)                    
 mgcv           1.8-31      2019-11-09 [4] CRAN (R 3.6.1)                    
 minqa          1.2.4       2014-10-09 [1] CRAN (R 3.6.0)                    
 modelr         0.1.7       2020-04-30 [1] CRAN (R 3.6.3)                    
 multcomp       1.4-13      2020-04-08 [1] CRAN (R 3.6.3)                    
 munsell        0.5.0       2018-06-12 [1] CRAN (R 3.6.0)                    
 mvtnorm        1.1-0       2020-02-24 [1] CRAN (R 3.6.3)                    
 nlme           3.1-147     2020-04-13 [1] CRAN (R 3.6.3)                    
 nloptr         1.2.2.1     2020-03-11 [1] CRAN (R 3.6.3)                    
 numDeriv       2016.8-1.1  2019-06-06 [1] CRAN (R 3.6.0)                    
 openxlsx       4.1.5       2020-05-06 [1] CRAN (R 3.6.3)                    
 packrat        0.5.0       2018-11-14 [1] CRAN (R 3.6.0)                    
 papaja       * 0.1.0.9842  2020-05-13 [1] local                             
 pbapply        1.4-2       2019-08-31 [1] CRAN (R 3.6.1)                    
 pillar         1.4.4       2020-05-05 [1] CRAN (R 3.6.3)                    
 pkgbuild       1.0.8       2020-05-07 [1] CRAN (R 3.6.3)                    
 pkgconfig      2.0.3       2019-09-22 [1] CRAN (R 3.6.1)                    
 pkgload        1.0.2       2018-10-29 [1] CRAN (R 3.6.0)                    
 plyr           1.8.6       2020-03-03 [1] CRAN (R 3.6.3)                    
 prettyunits    1.1.1       2020-01-24 [1] CRAN (R 3.6.3)                    
 processx       3.4.2       2020-02-09 [1] CRAN (R 3.6.3)                    
 ps             1.3.3       2020-05-08 [1] CRAN (R 3.6.3)                    
 purrr        * 0.3.4       2020-04-17 [1] CRAN (R 3.6.3)                    
 R6             2.4.1       2019-11-12 [1] CRAN (R 3.6.1)                    
 Rcpp           1.0.4.6     2020-04-09 [1] CRAN (R 3.6.3)                    
 readr        * 1.3.1       2018-12-21 [1] CRAN (R 3.6.0)                    
 readxl         1.3.1       2019-03-13 [1] CRAN (R 3.6.0)                    
 remotes        2.1.1       2020-02-15 [1] CRAN (R 3.6.3)                    
 reprex         0.3.0       2019-05-16 [1] CRAN (R 3.6.3)                    
 reshape2       1.4.4       2020-04-09 [1] CRAN (R 3.6.3)                    
 rio            0.5.16      2018-11-26 [1] CRAN (R 3.6.0)                    
 rjags          4-10        2019-11-06 [1] CRAN (R 3.6.1)                    
 rlang          0.4.6.9000  2020-05-12 [1] Github (r-lib/rlang@4bea875)      
 rprojroot      1.3-2       2018-01-03 [1] CRAN (R 3.6.0)                    
 rstudioapi     0.11        2020-02-07 [1] CRAN (R 3.6.3)                    
 runjags        2.0.4-6     2019-12-17 [1] CRAN (R 3.6.1)                    
 rvest          0.3.5       2019-11-08 [1] CRAN (R 3.6.1)                    
 sandwich       2.5-1       2019-04-06 [1] CRAN (R 3.6.0)                    
 scales         1.1.1       2020-05-11 [1] CRAN (R 3.6.3)                    
 sessioninfo    1.1.1       2018-11-05 [1] CRAN (R 3.6.0)                    
 statmod        1.4.34      2020-02-17 [1] CRAN (R 3.6.3)                    
 stringi        1.4.6       2020-02-17 [1] CRAN (R 3.6.3)                    
 stringr      * 1.4.0       2019-02-10 [1] CRAN (R 3.6.0)                    
 survival       3.1-12      2020-04-10 [1] CRAN (R 3.6.3)                    
 testthat       2.3.2       2020-03-02 [1] CRAN (R 3.6.3)                    
 TH.data        1.0-10      2019-01-21 [1] CRAN (R 3.6.0)                    
 tibble       * 3.0.1       2020-04-20 [1] CRAN (R 3.6.3)                    
 tidyr        * 1.0.3       2020-05-07 [1] CRAN (R 3.6.3)                    
 tidyselect     1.1.0       2020-05-11 [1] CRAN (R 3.6.3)                    
 tidyverse    * 1.3.0       2019-11-21 [1] CRAN (R 3.6.3)                    
 TreeBUGS     * 1.4.5       2020-05-14 [1] local                             
 usethis        1.6.1       2020-04-29 [1] CRAN (R 3.6.3)                    
 vctrs          0.3.0.9000  2020-05-12 [1] Github (r-lib/vctrs@4ff6b79)      
 withr          2.2.0       2020-04-20 [1] CRAN (R 3.6.3)                    
 xfun           0.13        2020-04-13 [1] CRAN (R 3.6.3)                    
 xml2           1.3.2       2020-04-23 [1] CRAN (R 3.6.3)                    
 xtable         1.8-4       2019-04-21 [1] CRAN (R 3.6.0)                    
 zip            2.0.4       2019-09-01 [1] CRAN (R 3.6.1)                    
 zoo            1.8-8       2020-05-02 [1] CRAN (R 3.6.3)                    

[1] /home/mariusbarth/R/x86_64-pc-linux-gnu-library/3.6
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
danheck commented 4 years ago

Thanks for reporting the bug. Is this an MPT model with a single tree/multinomial distribution? In this case, the issue is due to dropping dimensions and should be fixed in commit 21892d869ba5076b0719ff6dbad5a4446b67e92c

mariusbarth commented 4 years ago

Hi Daniel, thanks for your super quick response. It actually is a model with only one tree, and your commit fixed the problem -- it now works like a charm. Big Thanks!