I am very happy to announce that a release candidate for the next release of Cmdstan is now available on Github.
You can find it here: https://github.com/stan-dev/cmdstan/releases/tag/v2.24.0-rc1
There was a total of 147 pull requests merged for this release, code was contributed by 17 developers:
@Adam_Haber , @andrjohns, @bbbales2, @Bob_Carpenter, @charlesm93, Christopher22 , @simon, HaoZeke, @IvanYashchuk , @mitzimorris , @nhuurre, @peterwicksstringfield, @rybern, @serban-nicusor, @SteveBronder, @tadej and myself.
Also huge thanks to everyone that contributed with code reviews to what will certainly be a great release.
We just need a bit of your help. Please try the release candidate out, play with new features or just compile and run your exisiting models. And let us know what you think. Your time and help is very much appreciated by everyone at the Stan development team.
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 now have an online Cmdstan guide available at https://mc-stan.org/docs/2_24/cmdstan-guide/
If you are using cmdstanpy, make sure you point to the folder where you extracted the tar.gz file with
With cmdstanr you can install the release candidate using
install_cmdstan(release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.24.0-rc1/cmdstan-2.24.0-rc1.tar.gz", cores = 4)
And then select the RC with
set_cmdstan_path(file.path(Sys.getenv("HOME"), ".cmdstanr", "cmdstan-2.24.0-rc1"))
This release comes with a lot of new functions. Some of them already have online documentation which is linked below. Other will get documented in time for the release.
If you have any questions, do not hesitate to ask.
A new ODE interface
The new ODE interface is intended to make it easier to specify the ODE RHS by avoiding packing and unpacking schemes required with the old interface. It is important to switch to the new interfaces because the old interfaces are significantly slower than they were previously (we have seen up to 30%)
The new functions are:
vector ode_bdf(F f, vector y0, real t0, real times, ...) vector ode_adams(F f, vector y0, real t0, real times, ...) vector ode_rk45(F f, vector y0, real t0, real times, ...) vector ode_bdf_tol(F f, vector y0, real t0, real times, real rel_tol, real abs_tol, int max_num_steps, ...) vector ode_adams_tol(F f, vector y0, real t0, real times, real rel_tol, real abs_tol, int max_num_steps, ...) vector ode_rk45_tol(F f, vector y0, real t0, real times, real rel_tol, real abs_tol, int max_num_steps, ...)
There will also be a case study available shortly that will be linked here once its online.
Functions for Hidden Markov Models with a discrete latent variable
matrix hmm_hidden_state_prob(matrix, matrix, vector) int hmm_latent_rng(matrix, matrix, vector) real hmm_marginal(matrix, matrix, vector)
Elementwise pow operator and matrix power function
The .^ operator now supports elementwise pow. The following examples are now all supported:
vector .^ vector row_vector .^ row_vector matrix .^ matrix int .^ matrix matrix .^ int matrix .^ real vector .^ real vector .^ vector int .^ matrix row_vector .^ real row_vector .^ real ...
A new matrix matrix_power is also available with the signature:
matrix matrix_power(matrix, int)
The Newton solver is available via
vector algebra_solver_newton((vector, vector, data real, data int) => vector, vector, vector, real, int) vector algebra_solver_newton((vector, vector, data real, data int) => vector, vector, vector, real, int, real, real, real)
Support for the multinomial logit distribution
real multinomial_logit_log(int, vector) real multinomial_logit_lpmf(int, vector) int multinomial_logit_rng(vector, int)
T reverse(T) , where T is vector, row_vector or an array of any type
T lambert_w0(T), for any T
T lambert_w1(T), for any T
Construction utility functions
matrix identity_matrix(int) real linspaced_array(int, real, real); row_vector linspaced_row_vector(int, real, real); vector linspaced_vector(int, real, real) int one_hot_int_array(int, int); real one_hot_array(int, int); row_vector one_hot_row_vector(int, int); vector one_hot_vector(int, int) int ones_int_array(int); real ones_array(int); row_vector ones_row_vector(int); vector ones_vector(int) vector uniform_simplex(int) int zeros_int_array(int); real zeros_array(int); row_vector zeros_row_vector(int); vector zeros_vector(int)
Integer division operator
A new integer division operator was added:
%/%. Dividing integer numbers with the
/ operator will warn.
You can now run a pedantic check on your model that warns you about potential issues in your Stan program. For more details see here. A more readable form of documentation will be available at release time.
You can enable it by adding a
--warn-pedantic flag to STANCFLAGS.
Experimental optimization mode
There is also an experimental mode that will try to optimize your Stan model if possible. This can be enabled by adding the
--O flag to STANCFLAGS. A provisional documentation for the feature is currently available at
--O flag currently runs all listed optimizations.
Non-scalar values in lower, upper, offset and multiplier
Non-scalar values are now allowed in lower, upper, offset and multiplier transforms if the value has the same type and size as the declared variable.
real L[K]; real U[K]; vector<lower = L, upper = U>[K] alpha;
Faster compile times and easier handling of threading
If you are using the
g++ C++ compiler, the Stan models should now compile ~50% faster. If you are using the
clang C++ compiler, the models should compile ~20% faster than with Cmdstan 2.23.
On Linux and macOS this speedup is available out of the box. On Windows, if you are using the toolchain available with RTools 4.0, you have to add
make/local file. This speedup is unfortunately not available with RTools 3.5 on Windows.
A new and improved stansummary
- added option of returning custom quantiles
- separate summaries for sampler and model params
- a lot of minor improvements for stability and maintainability
Given that there were 147 pull requests merged since the last release, I may have missed some of the new features. If you want to highlight any of them, feel free to post here.