shinyStan with cmdstan?

113 views
Skip to first unread message

Seth Flaxman

unread,
Mar 3, 2015, 12:20:15 PM3/3/15
to stan-...@googlegroups.com
Does shinyStan play well with cmdstan? I fit a model in cmdstan, with two chains and output in model_output_*.csv and then in R I did:

fit = read_stan_csv(c("model_output_1.csv","model_output_2.csv")) 
launch_shinystan(fit)

I'm getting the following:

Error in samps_all[(warmup_val + 1):nIter, , , drop = FALSE] : 
  subscript out of bounds
In addition: Warning message:
In stan2shinystan(object) :
  Most features of shinyStan are only available for models using
            algorithm NUTS or algorithm HMC.
Error in samps_all[(warmup_val + 1):nIter, , , drop = FALSE] : 
  subscript out of bounds

Shiny does start but in the inline browser window that pops up I don't have any parameters to do anything with in the "Parameters plot" tab. It loaded something--if I go to Explore then there are parameters to choose from from my model under the "Select parameter" dropdown... no visualizations though.

Details on my setup: I ran cmdstan 2.6 on Linux, but otherwise I'm using Windows 7 with RStudio, RStan 2.6, shinyStan 1.0.0. Here's the full sessionInfo():

> sessionInfo() 
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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     

other attached packages:
 [1] xtable_1.7-4    threejs_0.2.1   xts_0.9-7       zoo_1.7-11      dygraphs_0.4.1  reshape2_1.4    plyr_1.8.1      gtools_3.4.1   
 [9] rstan_2.6.0     inline_0.3.13   Rcpp_0.11.4     shinyStan_1.0.0 shinyBS_0.50    shiny_0.11.1    ggplot2_1.0.0   kernlab_0.9-19 

loaded via a namespace (and not attached):
 [1] base64_1.1        colorspace_1.2-4  digest_0.6.4      grid_3.1.2        gtable_0.1.2      htmltools_0.2.6   htmlwidgets_0.3.2
 [8] httpuv_1.3.2      lattice_0.20-29   magrittr_1.5      MASS_7.3-35       mime_0.2          munsell_0.4.2     proto_0.3-10     
[15] R6_2.0.1          rjson_0.2.15      RJSONIO_1.3-0     scales_0.2.4      stats4_3.1.2      stringr_0.6.2     tools_3.1.2      
[22] yaml_2.1.13      

Ben Goodrich

unread,
Mar 3, 2015, 1:06:21 PM3/3/15
to stan-...@googlegroups.com, fla...@gmail.com
On Tuesday, March 3, 2015 at 12:20:15 PM UTC-5, Seth Flaxman wrote:
Does shinyStan play well with cmdstan?

In theory yes. I think your .csv files are somehow not what rstan expects. Can you post them or send them to me?

Ben

Seth Flaxman

unread,
Mar 3, 2015, 2:28:10 PM3/3/15
to Ben Goodrich, stan-...@googlegroups.com

Ben Goodrich

unread,
Mar 3, 2015, 2:59:33 PM3/3/15
to stan-...@googlegroups.com, fla...@gmail.com

Jonah

unread,
Mar 3, 2015, 3:18:15 PM3/3/15
to stan-...@googlegroups.com, fla...@gmail.com
Shucks. Sorry about that. I'll look into sorting this out. 

Jonah

unread,
Mar 3, 2015, 4:09:55 PM3/3/15
to stan-...@googlegroups.com, fla...@gmail.com
Seth, I'm working on a fix. Can you try reinstalling shinyStan from this github branch:

devtools::install_github("stan-dev/shinystan", ref = "feature/issue_21_make_compatible_with_cmdstan", build_vignettes = TRUE)

(You shouldn't need to run the entire install_shinystan() function again if you already did that before.) 

Let me know if it works for you once you've reinstalled or if you get the same or a different error. 

Jonah

p.s. shinyStan might be a little slow to start up initially for a model with as many parameters as you have, but once it's finished computing some stuff it should speed up. 

Guido Biele

unread,
Mar 3, 2015, 5:44:55 PM3/3/15
to fla...@gmail.com
Hi Jonah,

I also couldn't work with a cmdstan csv file loaded into R with shinystan 1.0. 
I just tried it with the branch you linked below, and now it works!

great job with shinyStan!!!

Guido

Jonah

unread,
Mar 3, 2015, 6:08:20 PM3/3/15
to stan-...@googlegroups.com, fla...@gmail.com
Thanks Guido! Glad it works now. We'll add this fix (or probably a more well-tested one) to the next release so you won't have to install it from a separate branch in the future. 

Seth Flaxman

unread,
Mar 4, 2015, 12:10:32 AM3/4/15
to Jonah, stan-...@googlegroups.com
Works for me as well. Thanks so much! 

Re: slowness. You were right, it's pretty responsive after the initial period when it's loading, except I just switched to the "Trace" tab and it's being slow again. Plus there seems to be an issue with the default y limits, screenshot here:


I assume you've done something fancy to try to get good default y limits? Or maybe something is just broken? Here's what I was expecting:


Seth

Jonah Sol Gabry

unread,
Mar 4, 2015, 1:08:27 AM3/4/15
to Seth Flaxman, stan-...@googlegroups.com
Glad it's working for you. 

The trace plots are definitely the slowest I think and I'm working on a few speed ups. And you're right about the y-axis limits. I noticed that the other day. There's an issue open on GitHub, so it's officially on the to-do list. Should have that fixed soon. 
Reply all
Reply to author
Forward
0 new messages