Announcing Stan Playground
Stan Playground is a new open-source, browser-based editor and runtime environment for Stan models. Users can edit, compile, and run models, as well as analyze the results using built-in plots and statistics or custom analysis code in Python or R, all with no local installation required.
I gave a live demo of the site at StanCon 2024 (video forthcoming), and we (myself, @magland, and @JSoules) are happy to now announce it for broader use.
Whether you’re a new user, an educator trying to teach Stan, or an experienced user who just doesn’t have their new laptop configured yet, we hope to make your life just a bit easier.
You can visit the live website here: https://stan-playground.flatironinstitute.org.
Feature Overview
For users familiar with tools like the Compiler Explorer, repl.it or JSFiddle, Stan Playground hopes to provide a similar experience for Stan models.
Stan editor
The site features an editor for Stan code with syntax highlighting and provides warnings and errors from the Stan
compiler for instant feedback.
Compiling models
Compilation of the models is the only part of Stan Playground which is not run locally. We provide a public server for convenience, but you can also host your own.
Preparing data
Data can be provided in JSON format in its own editor, or can be generated from code written in R (using webR) or Python (using pyodide), including code that imports published datasets.
Sampling
After a model has been compiled, sampling can be run entirely in your local browser.
Viewing and analyzing results
Stan Playground has several built-in ways of viewing the samples, but also supports performing your own analysis, again in R or Python.
Sharing
Stan Playground has built-in sharing features to allow you to download a copy of your project, upload an existing project, or share via a Github Gist. Sharing with a Gist provides a link you can send to other users–when clicked, the link loads your shared project in the recipient’s browser.
You can also prepare custom links if you have files already living at some URL (e.g., they are already in a github repository).
For example, this link will load the “golf” case study from the example models repository:
Dark Mode
Like any good modern website, you can also use it in dark mode:
Limitations and planned features
There are several things Stan Playground can’t do, but might one day! We’re hoping to hear from you all about which of these deserves priority:
- Providing initial values for sampling
- brms support
- Pathfinder and other algorithms besides HMC-NUTS
- Other items in our issue tracker
It’s also worth noting that the use of web technologies does place some constraints on what is (currently) possible. One a few early users have run into is memory constraints – Web Assembly is currently limited to somewhere between 2 and 4GB of RAM usage, depending on your browser. You can still do a lot of cool modeling within those limits, but it’s still important to be aware of.