There have been a few new features in Stan Playground since the original post that I thought would be worth highlighting. Because the website is continually deployed, we don’t exactly have “releases”, so some of these have been available for quite some time:
Improvements to user scripting
We’ve improved our integration with pyodide and webR that allows users to run Python and R code directly in Stan Playground. These should be faster/smoother overall, and you can now cancel a script that is stuck rather than needing to refresh your page:
This file contains the “glue” code necessary to run your data generation and analysis code locally using CmdStanPy/R.
Scatter plots tab
We now provide some interactive scatter plots on a new tab of the Output viewer. This allows you to select different combinations of variables to scatter against each other:
The headers on the tables are now “sticky” and follow as you scroll, the page should load faster, compilation should be slightly quicker, the console text (including print statements) is also now viewable in its own tab, “Pedantic Mode” warnings can be enabled in settings, and more. Thank you to everyone who has used the site for providing feedback and suggestions!
We’ve discussed this. The public compilation server will probably track the latest release, but it would be nice if we gave some way of swapping out e.g. the stanc version used to give you red squigglies in the editor etc. This would both let you run different versions but also something like Torsten, which is the first thing @charlesm93 asked me about when I showed him this a while back. I got a version of torsten working inside it locally, but we never decided quite how to let users select these.
Stan Playground has continued to get regular maintenance in the form of bug fixes and version bumps (it has been running Stan 2.37 since ~24 hours after the CmdStan release of that version), but today I’m back to show off an exciting new feature: embedded Stan Playground sites wherever you want them.
Just include one script and add a <stan-playground-embed> section to your page and you’ll get a minified version of the website embedded with your own model and data ready to go
If you’d like to chime in on that second issue I’d love to hear more about what “BRMS support” looks like to you. Do you just want it to generate the Stan code, or would you also like it to feature in the analysis portions, etc
As a starting point I’d love to generate Stan models and get it to also create the needed Stan data from the given R data. That would already be super cool. More functionality is great as always, but this would be a good starting point for teaching.
BTW, is it in principle possible to cache the Stan compiled models in advance just like a cmdstan executable?
The compilation server performs caching already. We clear it out every now and then, but if you compile e.g. one of the examples it will almost certainly be a cache hit and should be nearly instant, compared to 10-15s for a cache miss
The reason is a bit subtle, but stems from the fact that Stan’s runtime errors can include source code locations inside of them. So even something like deleting ‘extra’ whitespace can lead to confusion.
For example, if
// pretend there are 10 lines before this
model {
foo ~ normal(0, sigma);
bar ~ normal(theta, 2)
}
gets turned into
// pretend there are 10 lines before this
model {
foo ~ normal(0, sigma);
bar ~ normal(theta, 2)
}
By whatever cache-hit-maximizing normalization you are performing, suddenly an error message line 13: second argument to normal_lpdf must be positive looks like it is claiming that somehow 2 is non-positive, when really the issue is with the sigma variable.
Particularly for a teaching tool, we really wanted to avoid these issues. There are also times where you may want to force a cache miss, such as if the compilation server somehow returned a corrupted file, which would be annoyingly defeated by normalization logic
That said, you can manually maximize your odds by using the format button.
oh, I See. maybe add an option “auto-format prior compile”? Then that option will be on by default and the behaviour is to automatically reformat the Stan model prior to sending it to compilation. Then what gets compiled and what is on screen will match… maybe this is an easy one to get more people to enjoy caching …