Common components for a family of wrapper packages using Stan's cmdstan executable from Julia.
Author StanJulia
0 Stars
Updated Last
5 Months Ago
Started In
July 2019

StanBase v4

Project Status Build Status


This package contains common components and methods for several packages wrapping Stan's cmdstan executable.

The actual Stan methods supported, e.g. stan_sample(), stan_optimize(), etc., are in StanSample.jl, StanOptimize.jl, StanVariational.jl, StanDiagnose.jl and generated_quantities (included in StanSample.jl).

A new package, DiffEqBayesStan.jl is available to focus on DifferentialEquations and Stan.

Another package, StanQuap.jl, provides a quadratic approximation using StanOptimize.jl and StanSample.jl which I have used in the early chapters of StatisticalRethinking.

These six application packages support all features and options currently available in the cmdstan executable.


This package is registered. Install it with:

pkg> add StanBase

although the intention is that users of Stan's cmdstan executable will never have to install StanBase.jl, they can simply install any of the application packages listed here.

This and all the method packages need a working cmdstan installation, the path of which you should specify in an evironment variable CMDSTAN, e.g. in your ~/.julia/config/startup.jl have a line like:

ENV["CMDSTAN"] = expanduser("~/.../cmdstan/") # replace with your path

This package is structured somewhat similar to Tamas Papp's StanRun.jl package.


Martrix input data is not handled properly in v6.4, please use v6.5

StanBase.jl v4 supports Stan.jl v9 and StanSample v6 which by default use C++ level threads (and chains). This has major consequences for StanSample.jl and Stan.jl (explained in the documentation of Stan.jl v9 and in the on-line help in StanSample.jl v6). As such StanBase.jl v4 is a breaking update.

StanBase.jl versions < v4.0.0 used StanDump.jl to create data.R and init.R files. It is no longer clear if .R files will be supported in future version of cmdstan. Certainly with cmdstan-2.28.2 I have seen error messages when using init.R files. Hence version 4 uses by default JSON.jl for this purpose. I have added a positional use_json=true argument to e.g. stan_sample().

StanBase v4.7.0 drops support for creating R files (Thanks to Andrew Radcliffe).