Closed abfleishman closed 1 year ago
In order to use the cmdstanr
backend, flocker::flock
needs to see the argument backend = "cmdstanr"
. By default (and this just follows conventions from brms
) it will try to use package rstan
. So it seems you have a problem with the rstan
backend. Try adding backend = "cmdstanr"
to you call to flocker::flock
, and see if that works. If it doesn't work, let's check if you are able to compile and run any brms
models. What happens if you do
library(brms)
fit1 <- brm(time ~ age, data = kidney, family = lognormal(), backend = "cmdstanr")
@jsocolar Thank you! That was the issue! (clearly a beginner's problem). I must have missed that in your tutorial.
The following worked for me perfectly!
library(flocker)
ex_data <- example_flocker_data()
names(ex_data)
flocker_data <- make_flocker_data(obs = ex_data$obs,
unit_covs = ex_data$unit_covs,
event_covs = ex_data$event_covs)
flock(f_occ = ~ uc1,
f_det = ~ 1,
flocker_data = flocker_data,
backend = "cmdstanr")
No worries. I'm not sure it's in the tutorial, and I'll make sure to update it! I'll leave this issue open until I do that. brms
has so many knobs to twiddle that any feedback about which ones need to be documented for users of flocker
who don't already use brms
is super helpful.
Hi there,
I'm also getting a cryptic error using the example data (as well as a stripped-down dataset of my own). Running:
library(flocker)
ex_data <- example_flocker_data()
flocker_data <- make_flocker_data(obs = ex_data$obs,
unit_covs = ex_data$unit_covs,
event_covs = ex_data$event_covs)
flock(f_occ = ~ uc1,
f_det = ~ 1,
flocker_data = flocker_data)
yields the cryptic: Error in stanc(file = file, model_code = model_code, model_name = model_name, : parser failed badly
.
For the moment, I am limited to using rstan as a backend, since CmdStan seems to not play nicely with macOS Ventura and Intel silicon. I'm hoping that issue will be resolved soon (which may go some way to resolving this issue?!), but in the meantime, I'd appreciate getting to mess around with flocker using the rstan backend. Any suggestions on how I might do that?
I have verified that both rstan
and brms
seem to work as expected. I successfully generated samples for the centered parameterization of the eight schools model in rstan
and the kidney example in brms
. So to my uneducated eye, I should have all of the ingredients to sample with flocker, but clearly something is amiss. I get the same result when I specify backend = 'rstan'
explicitly.
Thanks for your help!
Here's my R session environment for reference:
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Ventura 13.0
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] brms_2.18.0 Rcpp_1.0.9 flocker_0.1-0 forcats_0.5.2 stringr_1.4.1
[6] dplyr_1.0.10 purrr_0.3.5 readr_2.1.3 tidyr_1.2.1 tibble_3.1.8
[11] ggplot2_3.3.6 tidyverse_1.3.2
loaded via a namespace (and not attached):
[1] googledrive_2.0.0 colorspace_2.0-3 ellipsis_0.3.2 ggridges_0.5.4
[5] estimability_1.4.1 markdown_1.3 base64enc_0.1-3 fs_1.5.2
[9] rstudioapi_0.14 farver_2.1.1 rstan_2.26.13 DT_0.26
[13] fansi_1.0.3 mvtnorm_1.1-3 lubridate_1.8.0 xml2_1.3.3
[17] codetools_0.2-18 bridgesampling_1.1-2 shinythemes_1.2.0 bayesplot_1.9.0
[21] jsonlite_1.8.3 broom_1.0.1 dbplyr_2.2.1 shiny_1.7.3
[25] compiler_4.2.1 httr_1.4.4 emmeans_1.8.2 backports_1.4.1
[29] assertthat_0.2.1 Matrix_1.5-1 fastmap_1.1.0 gargle_1.2.1
[33] cli_3.4.1 later_1.3.0 htmltools_0.5.3 prettyunits_1.1.1
[37] tools_4.2.1 igraph_1.3.5 coda_0.19-4 gtable_0.3.1
[41] glue_1.6.2 reshape2_1.4.4 posterior_1.3.1 V8_4.2.1
[45] cellranger_1.1.0 vctrs_0.5.0 nlme_3.1-160 crosstalk_1.2.0
[49] tensorA_0.36.2 ps_1.7.2 rvest_1.0.3 mime_0.12
[53] miniUI_0.1.1.1 lifecycle_1.0.3 gtools_3.9.3 googlesheets4_1.0.1
[57] zoo_1.8-11 scales_1.2.1 colourpicker_1.2.0 hms_1.1.2
[61] promises_1.2.0.1 Brobdingnag_1.2-9 parallel_4.2.1 inline_0.3.19
[65] shinystan_2.6.0 curl_4.3.3 gridExtra_2.3 loo_2.5.1
[69] StanHeaders_2.26.13 stringi_1.7.8 dygraphs_1.1.1.6 checkmate_2.1.0
[73] boot_1.3-28 pkgbuild_1.3.1 rlang_1.0.6 pkgconfig_2.0.3
[77] matrixStats_0.62.0 distributional_0.3.1 lattice_0.20-45 rstantools_2.2.0
[81] htmlwidgets_1.5.4 tidyselect_1.2.0 processx_3.8.0 plyr_1.8.7
[85] magrittr_2.0.3 R6_2.5.1 generics_0.1.3 DBI_1.1.3
[89] pillar_1.8.1 haven_2.5.1 withr_2.5.0 xts_0.12.2
[93] abind_1.4-5 modelr_0.1.9 crayon_1.5.2 utf8_1.2.2
[97] tzdb_0.3.0 grid_4.2.1 readxl_1.4.1 callr_3.7.3
[101] threejs_0.3.3 reprex_2.0.2 digest_0.6.30 xtable_1.8-4
[105] httpuv_1.6.6 RcppParallel_5.1.5 stats4_4.2.1 munsell_0.5.0
[109] shinyjs_2.1.0
Hi @joshua-goldberg. Weird! I have a mac (different os though) on intel silicon running rstan 2.26.10 and I can run your example just fine. I don't have time to mess around with my rstan installation right now... Maybe the first thing to check is restarting R?
Hi @jsocolar-
I'm pretty sure I had tried a restart before posting, but I opened a fresh instance R/Rstudio just now and get the same "parser failed badly" error with little hint of where the issue is emerging. Running via Terminal leads to the same error. I'm pretty sure I'm working with a fresh install of the dev version of rstan.
I suspect this is a Ventura-on-Intel thing, which is making me regret the snap decision to upgrade before more people from the Stan community vetted the transition. I avoided Catalina for a couple of years because of all the config issues, perhaps I should have done the same with Ventura.
I'm happy to help with troubleshooting when you have more time, but not proficient enough to develop a solution without guidance. I'll sit tight in the meantime.
I'm going to close this for the time being, since I don't think that the fix lies within flocker
.
I just found your package and I am super excited to try it! I installed
cmdstanr
using the instructions laid out on their page. installedflocker
and tried using the data in the tutorial to create a model. it failed immediately. I am guessing it is a problem with my environment? but would love your advice for debugging.