Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

storopoli/Bayesian-Statistics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bayesian Statistics

CC BY-SA 4.0

Bayesian for Everyone!

Bayesian for Everyone!

This repository holds slides and code for a full Bayesian statistics graduate course.

Bayesian statistics is an approach to inferential statistics based on Bayes' theorem, where available knowledge about parameters in a statistical model is updated with the information in observed data. The background knowledge is expressed as a prior distribution and combined with observational data in the form of a likelihood function to determine the posterior distribution. The posterior can also be used for making predictions about future events.

Bayesian statistics is a departure from classical inferential statistics that prohibits probability statements about parameters and is based on asymptotically sampling infinite samples from a theoretical population and finding parameter values that maximize the likelihood function. Mostly notorious is null-hypothesis significance testing (NHST) based on p-values. Bayesian statistics incorporate uncertainty (and prior knowledge) by allowing probability statements about parameters, and the process of parameter value inference is a direct result of the Bayes' theorem.

Content

The whole content is a set of several slides found at the latest release (382 slides). Here is a brief table of contents:

  1. What is Bayesian Statistics?
  2. Common Probability Distributions
  3. Priors
  4. Bayesian Workflow
  5. Bayesian Linear Regression
  6. Bayesian Logistic Regression
  7. Bayesian Ordinal Regression
  8. Bayesian Regression with Count Data: Poisson Regression
  9. Robust Bayesian Regression
  10. Bayesian Sparse Regression
  11. Hierarchical Models
  12. Markov Chain Monte Carlo (MCMC) and Model Metrics
  13. Model Comparison: Cross-Validation and Other Metrics

Probabilistic Programming Languages (PPLs)

Along with slides for the content, this repository also holds Stan code and also Turing code for all models. Stan and Turing represents, respectively, the present and future of probabilistic programming languages.

All model files are tested in GitHub Actions against the latest Stan and Julia/Turing versions.

Stan

Stan (Carpenter et al., 2017) Stan is a state-of-the-art platform for statistical modeling and high-performance statistical computation. Thousands of users rely on Stan for statistical modeling, data analysis, and prediction in the social, biological, and physical sciences, engineering, and business.

Stan models are specified in its own language (similar to C++) and compiled into an executable binary that can generate Bayesian statistical inferences using a high-performance Markov Chain Montecarlo (MCMC).

You can find Stan models for all the content discussed in the slides at stan/ folder.

Turing

Turing (Ge, Xu & Ghahramani, 2018) is an ecosystem of Julia packages for Bayesian Inference using probabilistic programming. Models specified using Turing are easy to read and write — models work the way you write them. Like everything in Julia, Turing is fast.

You can find Turing models for all the content discussed in the slides at turing/ folder.

Datasets

  • kidiq (linear regression): data from a survey of adult American women and their children (a subsample from the National Longitudinal Survey of Youth). Source: Gelman and Hill (2007).
  • wells (logistic regression): a survey of 3200 residents in a small area of Bangladesh suffering from arsenic contamination of groundwater. Respondents with elevated arsenic levels in their wells had been encouraged to switch their water source to a safe public or private well in the nearby area and the survey was conducted several years later to learn which of the affected residents had switched wells. Source: Gelman and Hill (2007).
  • esoph (ordinal regression): data from a case-control study of (o)esophageal cancer in Ille-et-Vilaine, France. Source: Breslow and Day (1980).
  • roaches (Poisson regression): data on the efficacy of a pest management system at reducing the number of roaches in urban apartments. Source: Gelman and Hill (2007).
  • duncan (robust regression): data from occupation's prestige filled with outliers. Source: Duncan (1961).
  • sparse_regression (sparse regression): simulated data from the glmnet R package. Source: Tay, Narasimhan and Hastie (2023).
  • cheese (hierarchical models): data from cheese ratings. A group of 10 rural and 10 urban raters rated 4 types of different cheeses (A, B, C and D) in two samples. Source: Boatwright, McCulloch and Rossi (1999).

Author

Jose Storopoli, PhD - ORCID - https://storopoli.io

How to use the content?

The content is licensed under a very permissive Creative Commons license (CC BY-SA). You are mostly welcome to contribute with issues and pull requests. My hope is to have more people into Bayesian statistics. The content is aimed towards PhD candidates in applied sciences. I chose to provide an intuitive approach along with some rigorous mathematical formulations. I've made it to be how I would have liked to be introduced to Bayesian statistics.

If you want to build the slides locally without having to worry with Typst packages, install Nix and run:

nix build github:storopoli/Bayesian-Statistics

References

The references are divided in books, papers, software, and datasets.

Books

  • Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian Data Analysis. Chapman and Hall/CRC.
  • McElreath, R. (2020). Statistical rethinking: A Bayesian course with examples in R and Stan. CRC press.
  • Gelman, A., Hill, J., & Vehtari, A. (2020). Regression and other stories. Cambridge University Press.
  • Brooks, S., Gelman, A., Jones, G., & Meng, X.-L. (2011). Handbook of Markov Chain Monte Carlo. CRC Press. http://books.google.com?id=qfRsAIKZ4rIC
    • Geyer, C. J. (2011). Introduction to markov chain monte carlo. In S. Brooks, A. Gelman, G. L. Jones, & X.-L. Meng (Eds.), Handbook of markov chain monte carlo.

Papers

The papers section of the references are divided into required and complementary.

Required

Complementary

Software

  • Carpenter, B., Gelman, A., Hoffman, M. D., Lee, D., Goodrich, B., Betancourt, M., Brubaker, M., Guo, J., Li, P., & Riddell, A. (2017). Stan : A Probabilistic Programming Language. Journal of Statistical Software, 76(1). https://doi.org/[10.18637/jss.v076.i01](https://doi.org/10.18637/jss.v076.i01)
  • Ge, H., Xu, K., & Ghahramani, Z. (2018). Turing: A Language for Flexible Probabilistic Inference. International Conference on Artificial Intelligence and Statistics, 1682–1690. http://proceedings.mlr.press/v84/ge18b.html
  • Tarek, M., Xu, K., Trapp, M., Ge, H., & Ghahramani, Z. (2020). DynamicPPL: Stan-like Speed for Dynamic Probabilistic Models. ArXiv:2002.02702 [Cs, Stat]. http://arxiv.org/abs/2002.02702
  • Xu, K., Ge, H., Tebbutt, W., Tarek, M., Trapp, M., & Ghahramani, Z. (2020). AdvancedHMC.jl: A robust, modular and efficient implementation of advanced HMC algorithms. Symposium on Advances in Approximate Bayesian Inference, 1–10. http://proceedings.mlr.press/v118/xu20a.html

Datasets

  • Boatwright, P., McCulloch, R., & Rossi, P. (1999). Account-level modeling for trade promotion: An application of a constrained parameter hierarchical model. Journal of the American Statistical Association, 94(448), 1063–1073.
  • Breslow, N. E. & Day, N. E. (1980). Statistical Methods in Cancer Research. Volume 1: The Analysis of Case-Control Studies. IARC Lyon / Oxford University Press.
  • Duncan, O. D. (1961). A socioeconomic index for all occupations. Class: Critical Concepts, 1, 388–426.
  • Tay JK, Narasimhan B, Hastie T (2023). Elastic Net Regularization Paths for All Generalized Linear Models. Journal of Statistical Software, 106(1), 1–31. doi:10.18637/jss.v106.i01.
  • Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. Cambridge university press.

How to cite

To cite this course, please use:

Storopoli (2022). Bayesian Statistics: a graduate course. https://github.com/storopoli/Bayesian-Statistics.

Or in BibTeX format ($\LaTeX$):

@misc{storopoli2022bayesian,
  author = {Storopoli, Jose},
  title = {Bayesian Statistics: a graduate course},
  url = {https://github.com/storopoli/Bayesian-Statistics},
  year = {2022}
}

License

This content is licensed under Creative Commons Attribution-ShareAlike 4.0 International.

CC BY-SA 4.0