rmcelreath / glmer2stan

Define Stan models using glmer-style (lme4) formulas
55 stars 11 forks source link

rstan/tidyr extract() namespace conflict #8

Open harryprince opened 6 years ago

harryprince commented 6 years ago

Fail to run example at https://github.com/rmcelreath/glmer2stan#2-binomial-with-varying-intercepts

library(lme4)
devtools::install_github("rmcelreath/glmer2stan")
library(glmer2stan)

Input:

data(cbpp) # built into lme4

m2_lme4 <- glmer( cbind(incidence,size-incidence) ~ period + (1|herd) , data=cbpp , family=binomial )

cbpp$herd_index <- as.integer(cbpp$herd)
m2_g2s <- glmer2stan( cbind(incidence,size-incidence) ~ period + (1|herd_index) , data=cbpp , family="binomial" )

Error:

 Error in UseMethod("extract_") :    no applicable method for 'extract_' applied to an object of class "stanfit"

According to this issue: https://github.com/stan-dev/rstan/issues/118, it seems rstan/tidyr extract() namespace conflict.

SessionInfo:

R version 3.4.3 (2017-11-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

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

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

other attached packages:
 [1] glmer2stan_0.995    lme4_1.1-17         bindrcpp_0.2        MDPtoolbox_4.0.3    linprog_0.9-2       lpSolve_5.6.13     
 [7] Matrix_1.2-12       promises_1.0.1      sparklyr_0.7.0-9026 forcats_0.2.0       stringr_1.3.0       dplyr_0.7.4        
[13] purrr_0.2.4         readr_1.1.1         tidyr_0.8.0         tibble_1.4.2        tidyverse_1.2.1     rethinking_1.59    
[19] rstan_2.17.3        StanHeaders_2.17.2  ggplot2_2.2.1       RMySQL_0.10.13      DBI_0.8            

loaded via a namespace (and not attached):
  [1] minqa_1.2.4                 colorspace_1.3-2            smoof_1.5.1                 rsconnect_0.8.7            
  [5] rprojroot_1.3-2             base64enc_0.1-3             rstudioapi_0.7              listenv_0.7.0              
  [9] ParamHelpers_1.10           hash_2.2.6                  mvtnorm_1.0-7               lubridate_1.7.1            
 [13] xml2_1.2.0                  splines_3.4.3               codetools_0.2-15            mnormt_1.5-5               
 [17] knitr_1.20                  mco_1.0-15.1                zeallot_0.1.0               jsonlite_1.5               
 [21] nloptr_1.0.4                broom_0.4.4                 dbplyr_1.2.1                mlrMBO_1.1.1               
 [25] tfruns_1.3                  shiny_1.0.5                 compiler_3.4.3              httr_1.3.1                 
 [29] backports_1.1.2             assertthat_0.2.0            lazyeval_0.2.1              cli_1.0.0                  
 [33] later_0.7.1                 addinpromises_0.1.0         htmltools_0.3.6             tools_3.4.3                
 [37] misc3d_0.8-4                igraph_1.2.1                coda_0.19-1                 gtable_0.2.0               
 [41] glue_1.2.0                  reshape2_1.4.3              parallelMap_1.3             Rcpp_0.12.17               
 [45] cellranger_1.1.0            RJSONIO_1.3-0               nlme_3.1-131                psych_1.8.3.3              
 [49] mlr_2.12                    globals_0.11.0              rvest_0.3.2                 mime_0.5                   
 [53] devtools_1.13.4             future_1.8.1                MASS_7.3-47                 scales_0.5.0               
 [57] hms_0.4.0                   plot3D_1.1.1                inline_0.3.15               RColorBrewer_1.1-2         
 [61] BBmisc_1.11                 geohash_0.3.0               yaml_2.1.19                 curl_3.1                   
 [65] memoise_1.1.0               reticulate_1.7.1            gridExtra_2.3               loo_2.0.0                  
 [69] keras_2.1.6.9001            stringi_1.1.6               highr_0.6                   tensorflow_1.5.0.9001      
 [73] checkmate_1.8.5             lhs_0.16                    rlang_0.2.0                 pkgconfig_2.0.1            
 [77] matrixStats_0.53.1          evaluate_0.10.1             lattice_0.20-35             bindr_0.1                  
 [81] htmlwidgets_1.0             tidyselect_0.2.4            plyr_1.8.4                  magrittr_1.5               
 [85] R6_2.2.2                    pillar_1.1.0                haven_1.1.0                 whisker_0.3-2              
 [89] foreign_0.8-69              withr_2.1.2                 survival_2.41-3             tibbletime_0.1.0.9001      
 [93] modelr_0.1.1                crayon_1.3.4                utf8_1.1.3                  plotly_4.7.1               
 [97] rmarkdown_1.9               grid_3.4.3                  readxl_1.0.0                data.table_1.10.4-3        
[101] git2r_0.20.0                ReinforcementLearning_1.0.2 digest_0.6.15               xtable_1.8-2               
[105] httpuv_1.3.5                openssl_1.0.1               pool_0.1.4                  stats4_3.4.3               
[109] munsell_0.4.3               viridisLite_0.3.0