Stan from Julia (Julia v1.0, v1.1 and v1.2)



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.

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.

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().

Release 5.2.3

  1. Fixed an issue in running read_samples from the REPL (thanks to Graydon Marz).

Release 5.2.2

  1. Made sure by default no files are created in Julia's package directory.
  2. Removed some DataFrame update warnings.

Release 5.2.1 contains:

  1. Fixed an issue with read_diagnose.jl which failed on either linux or osx because of slightly different .csv file layout.

Release 5.2.0 contains:

  1. Specified Julia 1 dependency in Project
  2. Updates from sdewaele to fix resource busy or locked error messages
  3. Thanks to Daniel Coutinho an issue was fixed which made running CmdStan using Atom bothersome.
  4. Contains a fix in diagnostics testing

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.
  4. Support for Stan's include facility (thanks to Chris Fisher).

CmdStan.jl tested on cmdstan v2.20.0.

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 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

7 days ago


367 commits