Stan (software)

From testwiki
Jump to navigation Jump to search

Template:Short description Template:Other uses Template:Infobox software

Stan is a probabilistic programming language for statistical inference written in C++.[1] The Stan language is used to specify a (Bayesian) statistical model with an imperative program calculating the log probability density function.[1]

Stan is licensed under the New BSD License. Stan is named in honour of Stanislaw Ulam, pioneer of the Monte Carlo method.[1]

Stan was created by a development team consisting of 52 members[2] that includes Andrew Gelman, Bob Carpenter, Daniel Lee, Ben Goodrich, and others.

Example

A simple linear regression model can be described as yn=α+βxn+ϵn, where ϵnnormal(0,σ). This can also be expressed as ynnormal(α+βXn,σ). The latter form can be written in Stan as the following:

data {
  int<lower=0> N;
  vector[N] x;
  vector[N] y;
}
parameters {
  real alpha;
  real beta;
  real<lower=0> sigma;
}
model {
  y ~ normal(alpha + beta * x, sigma);
}

Interfaces

The Stan language itself can be accessed through several interfaces:

In addition, higher-level interfaces are provided with packages using Stan as backend, primarily in the R language:[3]

  • rstanarm provides a drop-in replacement for frequentist models provided by base R and lme4 using the R formula syntax;
  • brms[4] provides a wide array of linear and nonlinear models using the R formula syntax;
  • prophet provides automated procedures for time series forecasting.

Algorithms

Stan implements gradient-based Markov chain Monte Carlo (MCMC) algorithms for Bayesian inference, stochastic, gradient-based variational Bayesian methods for approximate Bayesian inference, and gradient-based optimization for penalized maximum likelihood estimation.

Automatic differentiation

Stan implements reverse-mode automatic differentiation to calculate gradients of the model, which is required by HMC, NUTS, L-BFGS, BFGS, and variational inference.[1] The automatic differentiation within Stan can be used outside of the probabilistic programming language.

Usage

Stan is used in fields including social science,[8] pharmaceutical statistics,[9] market research,[10] and medical imaging.[11]

See also

  • PyMC is a probabilistic programming language in Python
  • ArviZ a Python library for Exploratory Analysis of Bayesian Models

References

Template:Reflist

Further reading

Template:Statistical software

  1. 1.0 1.1 1.2 1.3 1.4 Stan Development Team. 2015. Stan Modeling Language User's Guide and Reference Manual, Version 2.9.0
  2. Template:Cite news
  3. Template:Cite web
  4. Template:Cite web
  5. Template:Cite journal
  6. Template:Cite journal
  7. Template:Cite journal
  8. Goodrich, Benjamin King, Wawro, Gregory and Katznelson, Ira, Designing Quantitative Historical Social Inquiry: An Introduction to Stan (2012). APSA 2012 Annual Meeting Paper. Available at Template:SSRN
  9. Template:Cite journal
  10. Template:Cite web
  11. Template:Cite journal