Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some families with smooth and bs='gp' crash R #664

Closed
daskandalis opened this issue May 10, 2019 · 3 comments
Closed

Some families with smooth and bs='gp' crash R #664

daskandalis opened this issue May 10, 2019 · 3 comments

Comments

@daskandalis
Copy link

I am trying to analyse non-Gaussian data with smooths. In the following example, the binomial and Poisson models crash R but the beta model does not. The Binomial and Poisson models run fine without bs='gp' (I am also curious as to whether a Gaussian process is appropriate with such distributions). Binomial and Poisson models can be rescued by running them together, with or without beta. In my data the beta model crashes and the binomial is fine, but the beta can similarly be rescued by running with the binomial.

require(brms)

N <- 100

n <- sample( 1:N, N, replace=TRUE )

binom <- rbinom(N, n, 0.6)
pois <- rpois(N, 1)
beta <- rbeta(N, 1,1)
t=seq(0,10,length.out=N)

dat <- data.frame(t=t, binom=binom, n=n, pois=pois, beta=beta)

pois.bf <- bf(pois~s(t,bs='gp'), family=poisson())
binom.bf <- bf(binom|trials(n)~s(t,bs='gp'), family=binomial())
beta.bf <- bf(beta~s(t,bs='gp'),family=zero_one_inflated_beta())

# crashes session
pois.mod <- brm( pois.bf, seed=1, chains=1, iter=100, data=dat )

# crashes session
binom.mod <- brm( binom.bf, seed=1, chains=1, iter=100, data=dat )

beta.mod <- brm( beta.bf, seed=1, chains=1, iter=100, data=dat )

mv.mod <- brm( binom.bf + pois.bf + beta.bf, seed=1, chains=1, iter=100, data=dat )

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 yaml_2.2.0

@daskandalis daskandalis changed the title Poisson family with smooth and bs='gp' crashes R Some families with smooth and bs='gp' crash R May 10, 2019
@paul-buerkner
Copy link
Owner

paul-buerkner commented May 10, 2019

Thanks for providing a reproducible example. Unfortunately, it runs for me just fine (on Windows 10, R 3.6, Rtools 3.5). I can't tell you what causes a problem but it is likely related to Stan itself (if at all) but not to brms, since the latter merely writes the Stan code.

Here is my session Info

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

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

other attached packages:
[1] brms_2.8.9 Rcpp_1.0.1

loaded via a namespace (and not attached):
 [1] Brobdingnag_1.2-6    splines_3.6.0        gtools_3.8.1        
 [4] StanHeaders_2.18.0   threejs_0.3.1        shiny_1.1.0         
 [7] assertthat_0.2.1     stats4_3.6.0         pillar_1.3.1        
[10] backports_1.1.4      lattice_0.20-38      glue_1.3.1          
[13] digest_0.6.18        promises_1.0.1       colorspace_1.4-1    
[16] htmltools_0.3.6      httpuv_1.4.5         Matrix_1.2-17       
[19] plyr_1.8.4           dygraphs_1.1.1.6     pkgconfig_2.0.2     
[22] rstan_2.18.2         purrr_0.3.2          xtable_1.8-3        
[25] mvtnorm_1.0-8        scales_1.0.0         processx_3.2.0      
[28] later_0.7.5          tibble_2.1.1         mgcv_1.8-28         
[31] bayesplot_1.6.0      ggplot2_3.1.1        DT_0.4              
[34] withr_2.1.2          shinyjs_1.0          lazyeval_0.2.2      
[37] cli_1.1.0            magrittr_1.5         crayon_1.3.4        
[40] mime_0.6             ps_1.2.0             nlme_3.1-139        
[43] xts_0.11-1           pkgbuild_1.0.2       colourpicker_1.0    
[46] rsconnect_0.8.8      tools_3.6.0          loo_2.1.0           
[49] prettyunits_1.0.2    matrixStats_0.54.0   stringr_1.4.0       
[52] munsell_0.5.0        callr_3.0.0          packrat_0.4.9-3     
[55] compiler_3.6.0       rlang_0.3.4          grid_3.6.0          
[58] ggridges_0.5.1       rstudioapi_0.8       htmlwidgets_1.3     
[61] crosstalk_1.0.0      igraph_1.2.2         miniUI_0.1.1.1      
[64] base64enc_0.1-3      codetools_0.2-16     gtable_0.3.0        
[67] inline_0.3.15        abind_1.4-5          markdown_0.9        
[70] reshape2_1.4.3       R6_2.4.0             gridExtra_2.3       
[73] rstantools_1.5.1     zoo_1.8-4            bridgesampling_0.6-0
[76] dplyr_0.8.0.1        shinystan_2.5.0      shinythemes_1.1.1   
[79] stringi_1.4.3        parallel_3.6.0       tidyselect_0.2.5    
[82] coda_0.19-2         

@daskandalis
Copy link
Author

Switched to R 3.6, Rtools 3.5, Rstudio 1.2.x and both models are now compiling.

@paul-buerkner
Copy link
Owner

Glad it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants