bbolker / broom.mixed

tidy methods for mixed models in R
229 stars 23 forks source link

tidy() failing on brms cumulative-link model with 'subscript out of bounds' error #70

Open PhoenixB opened 5 years ago

PhoenixB commented 5 years ago

Dear Ben,

I fitted a complex model with brms and tried to tidy it with broom.mixed, but it keeps failing with Error in x[[2]] : subscript out of bounds. Do you have any idea what is going on? Do you need more information?

Kindest regards, Pascal

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-koji-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /gpfs/vitalit/software/el7/lib64/R/lib/libRblas.so

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

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

other attached packages:
 [1] broom.mixed_0.2.4.9000 optparse_1.6.2         modelr_0.1.2
 [4] tidybayes_1.0.4        fs_1.2.7               forcats_0.4.0
 [7] stringr_1.4.0          dplyr_0.8.0.1          purrr_0.3.2
[10] readr_1.3.1            tidyr_0.8.3            tibble_2.1.1
[13] ggplot2_3.1.1          tidyverse_1.2.1        pacman_0.5.1

loaded via a namespace (and not attached):
 [1] nlme_3.1-137              matrixStats_0.54.0
 [3] xts_0.11-1                lubridate_1.7.4
 [5] threejs_0.3.1             httr_1.3.1
 [7] rstan_2.18.2              TMB_1.7.15
 [9] tools_3.5.1               backports_1.1.4
[11] R6_2.4.0                  DT_0.4
[13] lazyeval_0.2.2            colorspace_1.3-2
[15] withr_2.1.2               prettyunits_1.0.2
[17] processx_3.2.0            tidyselect_0.2.5
[19] gridExtra_2.3             Brobdingnag_1.2-6
[21] compiler_3.5.1            cli_1.1.0
[23] rvest_0.3.2               arrayhelpers_1.0-20160527
[25] shinyjs_1.0               xml2_1.2.0
[27] colourpicker_1.0          scales_1.0.0
[29] dygraphs_1.1.1.6          brms_2.8.8
[31] mvtnorm_1.0-10            callr_3.0.0
[33] ggridges_0.5.1            StanHeaders_2.18.1
[35] digest_0.6.18             base64enc_0.1-3
[37] pkgconfig_2.0.2           htmltools_0.3.6
[39] htmlwidgets_1.3           rlang_0.3.4
[41] readxl_1.1.0              rstudioapi_0.10
[43] shiny_1.1.0               generics_0.0.2
[45] svUnit_0.7-12             zoo_1.8-5
[47] jsonlite_1.6              crosstalk_1.0.0
[49] gtools_3.8.1              inline_0.3.15
[51] magrittr_1.5              loo_2.1.0
[53] bayesplot_1.6.0           Matrix_1.2-14
[55] Rcpp_1.0.1                munsell_0.5.0
[57] abind_1.4-5               stringi_1.4.3
[59] pkgbuild_1.0.2            plyr_1.8.4
[61] ggstance_0.3.1            grid_3.5.1
[63] parallel_3.5.1            promises_1.0.1
[65] crayon_1.3.4              miniUI_0.1.1.1
[67] fortunes_1.5-4            lattice_0.20-35
[69] haven_2.1.0               hms_0.4.2
[71] ps_1.2.0                  pillar_1.3.1
[73] igraph_1.2.2              markdown_0.9
[75] shinystan_2.5.0           stats4_3.5.1
[77] reshape2_1.4.3            rstantools_1.5.1
[79] glue_1.3.1                httpuv_1.4.5
[81] cellranger_1.1.0          gtable_0.3.0
[83] getopt_1.20.2             assertthat_0.2.1
[85] mime_0.6                  xtable_1.8-4
[87] broom_0.5.2               coda_0.19-2
[89] later_0.7.5               rsconnect_0.8.13
[91] shinythemes_1.1.2         bridgesampling_0.6-0
bbolker commented 5 years ago

Definitely need more information, please. There are several known issues with "complex" models in brms (multivariate responses: #39, monotonic effects: #45), but I don't know what's in your model. A reproducible example would be great. At the very least, to continue the conversation, can you post your brms() call?

PhoenixB commented 5 years ago

Thank you very much! The call is brm(bf(answer ~ 1 + face * disfigurement * situation + (1 | participant_id)), cumulative("logit", threshold = "flexible"), list(max_treedepth = 15, adapt_delta = 0.9)), where answer is a ordinal response variable with values from 0 to 10, face, disfigurement and situation are factors with 4, 5, and 2 levels, respectively and participant_id is a character variable with 4009 levels. With the broom package, it worked as expected, but the brms_tidiers seem to become deprecated soon, so I moved to broom.mixed.

bbolker commented 5 years ago

OK. I'm guessing that cumulative link models are not working yet (in essence, they're a form of multivariate-response model). Many of the changes here from the original broom versions are trying to get parameters renamed in a more sensible way. A short-term solution might be to have a flag to turn off the cleverness and return whatever the original broom version was giving ...