Skip to content

Stan 2.7 (CRAN, variational inference, and much much more)


Stan 2.7 is now available for all interfaces. As usual, everything you need can be found starting from the Stan home page:


  • RStan is on CRAN!(1)
  • Variational Inference in CmdStan!!(2)
  • Two new Stan developers!!! 
  • A whole new logo!!!! 
  • Math library with autodiff now available in its own repo!!!!! 

(1) Just doing install.packages(“rstan”) isn’t going to work because of dependencies; please go to the RStan getting started page for instructions of how to install from CRAN. It’s much faster than building from source and you no longer need a machine with a lot of RAM to install.

(2) Coming soon to an interface near you.

Full Release Notes

v2.7.0 (9 July 2015)

New Team Members
* Alp Kucukelbir, who brings you variational inference
* Robert L. Grant, who brings you the StataStan interface

Major New Feature
* Black-box variational inference, mean field and full
  rank (#1505)

New Features
* Line numbers reported for runtime errors (#1195)
* Wiener first passage time density (#765) (thanks to
  Michael Schvartsman)
* Partial initialization (#1069)
* NegBinomial2 RNG (#1471) and PoissonLog RNG (#1458) and extended
  range for Dirichlet RNG (#1474) and fixed Poisson RNG for older
  Mac compilers (#1472)
* Error messages now use operator notation (#1401)
* More specific error messages for illegal assignments (#1100)
* More specific error messages for illegal sampling statement 
  signatures (#1425)
* Extended range on ibeta derivatives with wide impact on CDFs (#1426)
* Display initialization error messages (#1403)
* Works with Intel compilers and GCC 4.4 (#1506, #1514, #1519)

Bug Fixes
* Allow functions ending in _lp to call functions ending in _lp (#1500)
* Update warnings to catch uses of illegal sampling functions like
  CDFs and updated declared signatures (#1152)
* Disallow constraints on local variables (#1295)
* Allow min() and max() in variable declaration bounds and remove
  unnecessary use of math.h and top-level :: namespace (#1436)
* Updated exponential lower bound check (#1179)
* Extended sum to work with zero size arrays (#1443)
* Positive definiteness checks fixed (were > 1e-8, now > 0) (#1386)

Code Reorganization and Back End Upgrades
* New static constants (#469, #765)
* Added major/minor/patch versions as properties (#1383)
* Pulled all math-like functionality into stan::math namespace
* Pulled the Stan Math Library out into its own repository (#1520)
* Included in Stan C++ repository as submodule
* Removed final usage of std::cout and std::cerr (#699) and
  updated tests for null streams (#1239)
* Removed over 1000 CppLint warnings
* Remove model write CSV methods (#445)
* Reduced generality of operators in fvar (#1198)
* Removed folder-level includes due to order issues (part of Math
  reorg) and include math.hpp include (#1438)
* Updated to Boost 1.58 (#1457)
* Travis continuous integration for Linux (#607)
* Add grad() method to math::var for autodiff to encapsulate math::vari
* Added finite diff functionals for testing (#1271)
* More configurable distribution unit tests (#1268)
* Clean up directory-level includes (#1511)
* Removed all lint from new math lib and add cpplint to build lib
* Split out derivative functionals (#1389)

Manual and Documentation
* New Logo in Manual; remove old logos (#1023)
* Corrected all known bug reports and typos; details in 
  issues #1420, #1508, #1496
* Thanks to Sunil Nandihalli, Andy Choi, Sebastian Weber,
  Heraa Hu, @jonathan-g (GitHub handle), M. B. Joseph, Damjan
  Vukcevic, @tosh1ki (GitHub handle), Juan S. Casallas
* Fix some parsing issues for index (#1498)
* Added chapter on variational inference
* Added strangely unrelated regressions and multivariate probit
* Discussion from Ben Goodrich about reject() and sampling
* Start to reorganize code with fast examples first, then
* Added file (#1408)


  1. JD says:

    Great! I’ve been using Stan to fit a Gaussian spatial process, recently. The examples in the documentation served as a fantastic starting point for me.

    Perhaps this isn’t the best forum for this question, but here goes:

    For another problem I’d like to estimate the parameters in a bivariate Generalized hyperbolic distribution. Since it isn’t one of the defaults, I’d have to figure out the best way to code up this likelihood. Can you or Bob summarize what all is involved? The density requires a modified Bessel’s function. So for this task, would it be worth it to learn to code up custom distributions within Stan, *or* is it possible and would it be easier to access a shared library written in C or C++? In either case, what elements of the distribution will Stan need? density, distribution function, and random number generator?

    Also, the generalized hyperbolic dist can be characterized as mean-variance continuous mixture of the multivariate normal, where the mixing parameter comes from the generalized inverse Gaussian. Might it be preferable to try to code up this characterization in Stan instead?

    • It’d be easiest to code it up directly in Stan. Then you can see how the model works and if you want to go further with it.

      To do your own extension in C++, it depends whether it’s something to add to the Stan library or just a one-off. For the latter, you only need to code the instantiations that you need, but to get any speed bump over doing it in Stan, you’d have to code the gradients with respect to any parameters. For the former, it’d be nice to have all of those things you mention, but at the very least, it’d have to be templated enough to be differentiable in all arguments, would have to have both gradient and higher-order autodiff implementations, and would have to be thoroughly tested. And ideally it’d be vectorized. There’s a Wiki entry on coding new functions,

      a large part of which needs to move to the math repo.

      Yes, you could also try coding up the latent parameter version in Stan. How well it’ll work will probably depend on how much data’s constraining the posterior. That would not be codable as a function in Stan the way we have things set up (at least not in such a way that would encapsulate the latent parameter).

    • It sounds like the continuous mixture model is the way to go, a lot of these generalized distributions are really just closed forms for what in Stan would be more naturally expressed as a hierarchical model.

      In your case, it seems like
      V ~ some_distribution();
      sig ~ some_distribution();
      data ~ normal(a+b*V,sig);


      • I suppose the issue here is that you’ll put this in as your model, but you’ll get out samples of what V and sig are, not of what some parameter in the generalized distribution you’re interested in is.

        How important characterizing your data in terms of the parameters that define the generalized hyperbolic distribution is depends on your application I suppose, but it is worth noting that lots of weird distributions are really just mixtures of other more standard distributions, and the fact that they’ve been worked out in closed form doesn’t necessarily mean that you should go straight there compared to creating your own hierarchical model that makes sense for your context.

        Here’s a post I wrote a few years back about how a gaussian is “really” a mixture of uniforms:

  2. Anonymous says:

    “strangely unrelated regressions”

    Is that “seemingly unrelated regression” or an entirely new beast?

  3. Why doesn’t install.packges() work?

  4. Jim Savage says:

    Great news, and congratulations to the team; it looks like a huge amount of work.

  5. SJ says:

    The Stan Shop needs more of that terrific new logo.

  6. Is there some way to get at the variational functionality from within rstan?

    Also, what does the variational stuff give you as output? Samples? A mean vector and covariance matrix for a multivariate normal ? The manual wasn’t clear. I know this is brand new so hopefully becomes more fully fleshed out in the manual as time goes on.

    • Jonah says:

      It’s only in CmdStan for this release but the plan is to include it in the other interfaces too, hopefully by the next release. If you want to try it out it’s not too hard to get it running in CmdStan. For instance, suppose within my CmdStan directory I have a folder my_models containing logit_model.stan and logit_data.R (where logit_data.R was created using rstan::stan_rdump). I would cd to my CmdStan directory and then run

      make my_models/logit_model
      cd my_models
      ./logit_model variational data file=logit_data.R

      As for the output you get, it will look like what you get when you run mcmc using Stan although the draws won’t actually be from mcmc. But you’ll able to do the same things you would to a posterior sample obtained using mcmc.

  7. areshenk says:

    Beautiful. The Wiener density alone has had me excited for this release, but the black box VB looks very interesting, too.

Leave a Reply