Stan from Julia (Julia v1.x and up)



A package to run Stan's cmdstan executable from Julia.

Documentation Build Status


For more info on Stan, please go to http://mc-stan.org.

The Julia package CmdStan.jl is based on Stan's command line interface, 'cmdstan'.

The 'cmdstan' interface needs to be installed separatedly. Please see cmdstan installation for further details.

The location of the cmdstan executable and related programs is now obtained from the environment variable JULIA_CMDSTAN_HOME. This used to be CMDSTAN_HOME.

Right now versioninfo() will show its setting (if defined).


Release 5.0.0 of CmdStan.jl is a major level update as it breaks several examples. The simplest way to revert back to the pre-5.0.0 behavior is to use the output_format=:array option in the call to StanModel().

By default a call to stan() will now return an MCMCChains.Chains object (which has been derived from the Mamba.Chains object). The Chains object has facilities for summarizing, diagnostics, plotting and further processing.

Release 5.1.1 contains:

  1. Fixed an issue with save_warmup in Variational (thanks to fargolo).
  2. Fixed a documentation issue in rel_path_cmdstan.
  3. Enabled specifying data and init using an existing file.

Release 5.1.0 contains:

  1. Support for retrieving stansummary data (read_summary()).
  2. Support for using mktempdir() (might improve issue #47).
  3. Fixed handling of save_warmup.
  4. Read all optimization iterations (thanks to sdewaele).
  5. Several other minor documentation and type definition updates.
  6. Fixeda bug related to Array{Dict} inputs to init and data (thanks to sdewaele).
  7. Added a test to compare Stan's ESS values with MCMCChains ESS values.
  8. Updated all examples to have a single Dict as data input (suggested by sdewaele).

CmdStan.jl has been tested on cmdstan v2.19.1.


  • STABLEdocumentation of the most recently tagged version.
  • DEVELdocumentation of the in-development version.

Questions and issues

Question and contributions are very welcome, as are feature requests and suggestions. Please open an issue if you encounter any problems or have a question.


There is no shortage of good books on Bayesian statistics. A few of my favorites are:

  1. Bolstad: Introduction to Bayesian statistics

  2. Bolstad: Understanding Computational Bayesian Statistics

  3. Gelman, Hill: Data Analysis using regression and multileve,/hierachical models

  4. McElreath: Statistical Rethinking

  5. Gelman, Carlin, and others: Bayesian Data Analysis

  6. Lee, Wagenmakers: Bayesian Cognitive Modeling

  7. Kruschke:Doing Bayesian Data Analysis

and a great read (and implemented in DynamicHMC.jl):

  1. Betancourt: A Conceptual Introduction to Hamiltonian Monte Carlo

CmdStan.jl and several other Julia based mcmc packages are used in StatisticalRethinking.jl

First Commit


Last Touched

17 days ago


312 commits