Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2017:76:1.
doi: 10.18637/jss.v076.i01. Epub 2017 Jan 11.

Stan: A Probabilistic Programming Language

Affiliations

Stan: A Probabilistic Programming Language

Bob Carpenter et al. J Stat Softw. 2017.

Abstract

Stan is a probabilistic programming language for specifying statistical models. A Stan program imperatively defines a log probability function over parameters conditioned on specified data and constants. As of version 2.14.0, Stan provides full Bayesian inference for continuous-variable models through Markov chain Monte Carlo methods such as the No-U-Turn sampler, an adaptive form of Hamiltonian Monte Carlo sampling. Penalized maximum likelihood estimates are calculated using optimization methods such as the limited memory Broyden-Fletcher-Goldfarb-Shanno algorithm. Stan is also a platform for computing log densities and their gradients and Hessians, which can be used in alternative algorithms such as variational Bayes, expectation propagation, and marginal inference using approximate integration. To this end, Stan is set up so that the densities, gradients, and Hessians, along with intermediate quantities of the algorithm such as acceptance probabilities, are easily accessible. Stan can be called from the command line using the cmdstan package, through R using the rstan package, and through Python using the pystan package. All three interfaces support sampling and optimization-based inference with diagnostics and posterior analysis. rstan and pystan also provide access to log probabilities, gradients, Hessians, parameter transforms, and specialized plotting.

Keywords: Bayesian inference; Stan; algorithmic differentiation; probabilistic program.

PubMed Disclaimer

Figures

Figure 1:
Figure 1:
Stan program to estimate chance of success in the independent Bernoulli model.
Figure 2:
Figure 2:
Output summary for the Bernoulli estimation model in Figure 1.
Figure 3:
Figure 3:
Hierarchical binomial model with posterior predictive quantities, coded in Stan.

Similar articles

Cited by

References

    1. Betancourt M (2016). “Identifying the Optimal Integration Time in Hamiltonian Monte Carlo.” arXiv:1601.00225 [stat.ME]. URL https://arxiv.org/abs/1601.00225.
    1. Carpenter B, Hoffman MD, Brubaker M, Lee D, Li P, Betancourt M (2015). “The Stan Math Library: Reverse-Mode Automatic Differentiation in C++.” arXiv:1509.07164 [cs.MS]. URL https://arxiv.org/abs/1509.07164.
    1. Chacon S (2009). Pro Git. Apress. doi:10.1007/978-1-4302-1834-0. - DOI
    1. Cohen SD, Hindmarsh AC (1996). “CVODE, A Stiff/Nonstiff ODE Solver in C.” Computers in Physics, 10(2), 138–143.
    1. Driessen V (2010). “A Successful Git Branching Model.” URL http://nvie.com/posts/a-successful-git-branching-model/.

LinkOut - more resources