CmdStan & Stan 2.31 release candidate

I am happy to announce that the latest release candidates of Cmdstan and Stan are now available on Github!

This release cycle brings algebraic solver functions with variadic arguments, truncation syntax for vectorized sampling statements, quantile functions (inverse-CDFs), complex-valued Schur decomposition for matrices and direct access to the log_prob function and the gradients in CmdStan.

You can find the release candidate for cmdstan here. Instructions for installing are given at the bottom of this post.

Please test the release candidate with your models and report if you experience any problems. We also kindly invite you to test the new features and provide feedback. If you feel some of the new features could be improved or should be changed before the release, please do not hesitate to comment.

The Stan development team appreciates your time and help in making Stan more efficient while maintaining a high level of reliability.

If everything goes according to plan, the 2.31 version will be released in about ten days.

Below are some of the highlights of the new release.

New algebraic solver functions with variadic arguments

The algebraic solver functions were refactored to support variadic arguments, making them simpler to use, similar to how the ODE functions were refactored a few versions ago. The Stan language gains four new functions: solve_powell, solve_powell_tol, solve_newton and solve_newton_tol. The existing algebraic solver functions will be deprecated.

See the updated section on algebraic equation solvers which is currently available here and

Truncation syntax for vectorized sampling statements

This new feature allows statements like

  y ~ normal(mu1, sigma1) T[L, U];

in place of

  for (n in 1 : N) {
    y[n] ~ normal(mu2, sigma2) T[L, U];
  }

In previous versions the truncation syntax was only allowed with non-vectorized sampling statements.

Other new functions

  • quantile functions (inverse-CDFs): std_normal_qf and std_normal_log_qf

See temporary documentation here.

  • complex-valued Schur decomposition for matrices: complex_schur_decompose_t() and complex_schur_decompose_u()

See temporary documentation here.

  • to_int(data real) and to_int(data array[...] real) functions for real-to-int conversion of data variables.

New CmdStan method for calculating log_prob and its gradients

It is now possible to directly call the log_prob function and obtain the gradients with given unconstrained and constrained parameters, similar to the existing rstan’s log_prob and grad_log_prob functionality. User-facing documentation on how to use this functionality will be added shortly. An example call would be something like:

./bernoulli data file=data.json output file=output.csv method=log_prob constrained_params=params.json

or

./bernoulli data file=data.json output file=output.csv method=log_prob unconstrained_params=params.json

where the examples for constrained and unconstrained parameter JSON files for an example model can be seen here and here.

This is intended primarily for diagnostics and is not an efficient way of computing the log probability for tools like new samplers.

Miscellaneous

  • Implicit real-to-boolean conversions are now deprecated. Please use comparison operators to explicitly convert to boolean.
  • compile time errors and warnings have been improved and updated for clarity

How to install?

Download the tar.gz file from the link above, extract it and use it the way you use any Cmdstan release. We also have an online Cmdstan guide available at CmdStan User’s Guide

If you are using cmdstanpy you can install the release candidate using

cmdstanpy.install_cmdstan(version='2.31.0-rc1')

With CmdStanR you can install the release candidate using

cmdstanr::install_cmdstan(version = "2.31.0-rc1", cores = 4)
8 Likes

Just wondering,

y ~ normal(mu1, sigma1) T[L, U];

L and U can be also vectors there or no?

Unfortunately not at the moment, the truncation bounds have to be int or real. See example.

1 Like