Binomial_logit_lupmf does not compile but binomial_logit_lpmf does

I am working through this tutorial Reduce Sum: A Minimal Example (

I am using Docker on WSL2 to run RStudio locally (see session info at the end of the post). Key points: R version 4.1.2, StanHeaders_2.21.0-7, rstan_2.21.3 . I’ve tried reinstall RStan, but that did not work.

When I try to use the example model from the tutorial, I get this error:

 error in 'modele9b102764e3_test_red_sum' at line 7, column 31
     5:                         vector rating,
     6:                         vector beta) {
     7:     return binomial_logit_lupmf(slice_n_redcards |
     8:                                   n_games[start:end],

Error in stanc(file = file, model_code = model_code, model_name = model_name,  : 
  failed to parse Stan model 'test_red_sum' due to the above error.
In addition: Warning message:
In readLines(file, warn = TRUE) :
  incomplete final line found on '/home/rstudio/Documents/Documents/occupancy_learn/test_red_sum.stan'

Not show, but when I use a simpler model with binomial_logit_lpmf( instead of binomial_logit_lupmf(, the model complies.

Any suggestions?

Session info:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              

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

other attached packages:
 [1] ggpubr_0.4.0         ggthemes_4.2.4       GGally_2.1.2         forcats_0.5.1       
 [5] stringr_1.4.0        dplyr_1.0.8          purrr_0.3.4          readr_2.1.2         
 [9] tidyr_1.2.0          tibble_3.1.6         tidyverse_1.3.1      rstan_2.21.3        
[13] ggplot2_3.3.5        StanHeaders_2.21.0-7

loaded via a namespace (and not attached):
 [1] nlme_3.1-155       matrixStats_0.61.0 fs_1.5.2           lubridate_1.8.0   
 [5] RColorBrewer_1.1-3 progress_1.2.2     httr_1.4.2         tools_4.1.2       
 [9] backports_1.4.1    utf8_1.2.2         R6_2.5.1           DBI_1.1.2         
[13] colorspace_2.0-3   withr_2.5.0        tidyselect_1.1.2   gridExtra_2.3     
[17] prettyunits_1.1.1  processx_3.5.3     compiler_4.1.2     cli_3.2.0         
[21] rvest_1.0.2        xml2_1.3.3         labeling_0.4.2     scales_1.1.1      
[25] mvtnorm_1.1-3      callr_3.7.0        digest_0.6.29      minqa_1.2.4       
[29] pkgconfig_2.0.3    lme4_1.1-28        dbplyr_2.1.1       rlang_1.0.2       
[33] readxl_1.4.0       rstudioapi_0.13    generics_0.1.2     farver_2.1.0      
[37] jsonlite_1.8.0     car_3.0-12         inline_0.3.19      magrittr_2.0.3    
[41] loo_2.5.1          Matrix_1.4-0       Rcpp_1.0.8.3       munsell_0.5.0     
[45] fansi_1.0.3        abind_1.4-5        lifecycle_1.0.1    stringi_1.7.6     
[49] carData_3.0-5      MASS_7.3-55        pkgbuild_1.3.1     plyr_1.8.7        
[53] grid_4.1.2         parallel_4.1.2     crayon_1.5.1       lattice_0.20-45   
[57] cowplot_1.1.1      haven_2.4.3        splines_4.1.2      hms_1.1.1         
[61] ps_1.6.0           pillar_1.7.0       boot_1.3-28        ggsignif_0.6.3    
[65] codetools_0.2-18   stats4_4.1.2       reprex_2.0.1       glue_1.6.2        
[69] RcppParallel_5.1.5 modelr_0.1.8       vctrs_0.4.0        nloptr_2.0.0      
[73] tzdb_0.3.0         cellranger_1.1.0   gtable_0.3.0       reshape_0.8.8     
[77] assertthat_0.2.1   broom_0.7.12       rstatix_0.7.0      ellipsis_0.3.2 

Hi, the _lupmf suffix is not supported in rstan 2.21, which uses Stan version 2.21. The _lupmf suffices became available in version 2.25.

There is also a note at the top of the tutorial that it requires CmdStan 2.25, so even if you use lpmf suffixes, the rest of the tutorial will not work with this version of rstan.

1 Like

@rok_cesnovar Thanks for getting back to me. Any idea when 2.25 or greater will make it RStan? I searched and did not find anything for Stan and RStan’s releases and could not figure out a pattern from GitHub.

There’s an experimental branch in the Rstan repository that will bring Rstan at least to 2.27 (probably higher by now) but this hasn’t been merged in yet. @hsbadr is leading that effort, so he will have more insights on this.

1 Like

The experimental branch is in parallel with Stan development (currently at v2.29.2). It’s quite stable for me, but @bgoodri wants to secure the way to CRAN before merging it. Personally, I’d tag the current develop branch and merge it now.

It can be installed as follows:

remove.packages(c("StanHeaders", "rstan"))
remotes::install_github("stan-dev/rstan/StanHeaders@experimental", upgrade = "always", force = TRUE)
remotes::install_github("stan-dev/rstan/rstan/rstan@experimental", upgrade = "always", force = TRUE)