Stan 2.9 is Here!

Stan logo

We’re happy to announce that Stan 2.9.0 is fully available(1) for CmdStan, RStan, and PyStan — it should also work for Stan.jl (Julia), MatlabStan, and StataStan. As usual, you can find everything you need on the

The main new features are:

  • R/MATLAB-like slicing of matrices. There’s a new chapter in the user’s guide part of manual up front explaining how it all works (and more in the language reference on the nitty-gritty details). This means you can write foo[xs] where xs is an array of integers and use explicit slicing, as with bar[1:3, 2] and baz[:3, , xs] and so on.
  • Variational inference is available on an experimental basis in RStan and PyStan, and the adaptation has been improved; we still don’t have a good handle on when variational inference will work and when it won’t, so we would strongly advise only using it for rough work and then verifying with MCMC.
  • Better-behaved unit-vector transform; alas, this is broken already due to a dimensionality mismatch and you’ll have to wait for Stan 2.9.1 or Stan 2.10 before the unit_vector type will actually work (it never worked in the past, either—our bad in both the past and now for not having enough tests around it).

We also fixed some minor bugs and cleaned up quite a bit of the code and build process.

We also would like to welcome two new developers: Krzysztof Sakrejda and Aki Vehtari. Aki’s been instrumental in many of our design discussions and Krzysztof’s first major code contribution was sparse matrix multiplication, which leads to our next topic.

We have also released the first version of RStanARM package. The short story on RStanARM is that it’s an MCMC and VB-based replacement for lm() and glm() from core R, and to some extent, lmer() and glmer() from lme4. I believe there’s also a new version of ShinyStan (2.1) available.

We also wrote up a paper on Stan’s reverse-mode automatic differentiation, the cornerstone of the Stan Math Library:

Sincerely,

The Stan Development Team


(1) Apologies to those of you who tried to download and install RStan as it was trickling through the CRAN process. The problem is that the managers of CRAN felt a single RStan package was too large (4MB or so) and forced us to import existing packages and break RStan down (BH for the Boost headers, RcppEigen for the Eigen headers, StanHeaders for the Stan header files, and RStan itself for RStan itself). Alas, they provide no foolproof way to synchronize releases. We can insist on a particular version, but R always tries to download the latest or just fails. In the future, we’ll be more proactive and let people know ahead of time when things are in an unsettled state on CRAN and how to install through GitHub. Thanks for your patience.

ShinyStan v2.0.0

For those of you not familiar with ShinyStan, it is a graphical user interface for exploring Stan models (and more generally MCMC output from any software). For context, here’s the post on this blog first introducing ShinyStan (formerly shinyStan) from earlier this year.

shinystan_images

ShinyStan v2.0.0 released

ShinyStan v2.0.0 is now available on CRAN. This is a major update with a new look and a lot of new features. It also has a new(ish) name: ShinyStan is the app/GUI and shinystan the R package (both had formerly been shinyStan for some reason apparently not important enough for me to remember). Like earlier versions, this version has enhanced functionality for Stan models but is compatible with MCMC output from other software packages too.

You can install the new version from CRAN like any other package:

install.packages("shinystan")

If you prefer a version with a few minor typos fixed you can install from Github using the devtools package:

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

(Note: after installing the new version and checking that it works we recommend removing the old one by running remove.packages(“shinyStan”).)

If you install the package and want to try it out without having to first fit a model you can launch the app using the preloaded demo model:

library(shinystan)
launch_shinystan_demo()

Notes

This update contains a lot of changes, both in terms of new features added, greater UI stability, and an entirely new look. Some release notes can be found on GitHub and there are also some instructions for getting started on the ShinyStan wiki page. Here are two highlights:

  • The new interactive diagnostic plots for Hamiltonian Monte Carlo. In particular, these are designed for models fit with Stan using NUTS (the No-U-Turn Sampler).

    Diagnostics screenshot Diagnostics screenshotshinystan_diagnostics3

  • The deploy_shinystan function, which lets you easily deploy ShinyStan apps for your models to RStudio’s ShinyApps hosting service. Each of your apps (i.e. each of your models) will have a unique URL. To use this feature please also install the shinyapps package: devtools::install_github("rstudio/shinyapps").

The plan is to release a minor update with bug fixes and other minor tweaks in a month or so. So if you find anything we should fix or change (or if you have any other suggestions) we’d appreciate the feedback.