Stan (software)

From The Right Wiki
Jump to navigationJump to search
Stan
Original author(s)Stan Development Team
Initial releaseAugust 30, 2012 (2012-08-30)
Written inC++
Operating systemUnix-like, Microsoft Windows, Mac OS X
PlatformIntel x86 - 32-bit, x64
TypeStatistical package
LicenseNew BSD License
Websitemc-stan.org

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

  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. "Development Team". stan-dev.github.io. Retrieved 2024-11-21.
  3. Gabry, Jonah. "The current state of the Stan ecosystem in R". Statistical Modeling, Causal Inference, and Social Science. Retrieved 25 August 2020.
  4. "BRMS: Bayesian Regression Models using 'Stan'". 23 August 2021.
  5. Hoffman, Matthew D.; Gelman, Andrew (April 2014). "The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo". Journal of Machine Learning Research. 15: pp. 1593–1623.
  6. Kucukelbir, Alp; Ranganath, Rajesh; Blei, David M. (June 2015). "Automatic Variational Inference in Stan". 1506 (3431). arXiv:1506.03431. Bibcode:2015arXiv150603431K. {{cite journal}}: Cite journal requires |journal= (help)
  7. Zhang, Lu; Carpenter, Bob; Gelman, Andrew; Vehtari, Aki (2022). "Pathfinder: Parallel quasi-Newton variational inference". Journal of Machine Learning Research. 23 (306): 1–49.
  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 SSRN 2105531
  9. Natanegara, Fanni; Neuenschwander, Beat; Seaman, John W.; Kinnersley, Nelson; Heilmann, Cory R.; Ohlssen, David; Rochester, George (2013). "The current state of Bayesian methods in medical product development: survey results and recommendations from the DIA Bayesian Scientific Working Group". Pharmaceutical Statistics. 13 (1): 3–12. doi:10.1002/pst.1595. ISSN 1539-1612. PMID 24027093. S2CID 19738522.
  10. Feit, Elea (15 May 2017). "Using Stan to Estimate Hierarchical Bayes Models". Retrieved 19 March 2019.
  11. Gordon, GSD; Joseph, J; Alcolea, MP; Sawyer, T; Macfaden, AJ; Williams, C; Fitzpatrick, CRM; Jones, PH; di Pietro, M; Fitzgerald, RC; Wilkinson, TD; Bohndiek, SE (2019). "Quantitative phase and polarization imaging through an optical fiber applied to detection of early esophageal tumorigenesis". Journal of Biomedical Optics. 24 (12): 1–13. arXiv:1811.03977. Bibcode:2019JBO....24l6004G. doi:10.1117/1.JBO.24.12.126004. PMC 7006047. PMID 31840442.

Further reading

External links