{"id":16705516,"url":"https://github.com/storopoli/bayesian-julia","last_synced_at":"2025-04-09T15:05:35.414Z","repository":{"id":40002073,"uuid":"354795379","full_name":"storopoli/Bayesian-Julia","owner":"storopoli","description":"Bayesian Statistics using Julia and Turing","archived":true,"fork":false,"pushed_at":"2024-11-02T04:04:23.000Z","size":9930,"stargazers_count":169,"open_issues_count":7,"forks_count":30,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T15:05:29.688Z","etag":null,"topics":["bayesian-statistics","julia","turing","tutorials"],"latest_commit_sha":null,"homepage":"https://storopoli.github.io/Bayesian-Julia","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc-by-sa-4.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/storopoli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"storopoli"}},"created_at":"2021-04-05T10:22:13.000Z","updated_at":"2025-04-04T18:30:40.000Z","dependencies_parsed_at":"2023-01-31T00:45:54.448Z","dependency_job_id":"65792a46-750b-4f78-bc50-966689a157c7","html_url":"https://github.com/storopoli/Bayesian-Julia","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storopoli%2FBayesian-Julia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storopoli%2FBayesian-Julia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storopoli%2FBayesian-Julia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storopoli%2FBayesian-Julia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/storopoli","download_url":"https://codeload.github.com/storopoli/Bayesian-Julia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055284,"owners_count":21040157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian-statistics","julia","turing","tutorials"],"created_at":"2024-10-12T19:30:37.682Z","updated_at":"2025-04-09T15:05:35.392Z","avatar_url":"https://github.com/storopoli.png","language":"Julia","funding_links":["https://github.com/sponsors/storopoli"],"categories":[],"sub_categories":[],"readme":"# Bayesian Statistics using Julia and Turing\n\n[![CC BY-SA\n4.0](https://img.shields.io/badge/License-CC%20BY--SA%204.0-lightgrey.svg)](http://creativecommons.org/licenses/by-sa/4.0/)\n\n\u003cdiv class=\"figure\" style=\"text-align: center\"\u003e\n\n\u003cimg src=\"images/bayes-meme.jpg\" alt=\"Bayesian for Everyone!\" width=\"500\" /\u003e\n\u003cp class=\"caption\"\u003e\nBayesian for Everyone!\n\u003c/p\u003e\n\n\u003c/div\u003e\n\nWelcome to the repository of tutorials on how to do **Bayesian Statistics** using [**Julia**](https://www.julialang.org) and [**Turing**](http://turing.ml/).\nTutorials are available at [storopoli.io/Bayesian-Julia](https://storopoli.io/Bayesian-Julia).\n\n**Bayesian statistics** is an approach to inferential statistics based on Bayes' theorem,\nwhere available knowledge about parameters in a statistical model is updated with the information in observed data.\nThe 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.\nThe posterior can also be used for making predictions about future events.\n\n**Bayesian statistics** is a departure from classical inferential statistics that prohibits probability statements about parameters and\nis based on asymptotically sampling infinite samples from a theoretical population and finding parameter values that maximize the likelihood function.\nMostly notorious is null-hypothesis significance testing (NHST) based on *p*-values.\nBayesian statistics **incorporate uncertainty** (and prior knowledge) by allowing probability statements about parameters,\nand the process of parameter value inference is a direct result of the **Bayes' theorem**.\n\n## Table of Contents\n\n   * [Julia](#julia)\n   * [Turing](#turing)\n   * [Author](#author)\n   * [How to use the content?](#how-to-use-the-content)\n   * [Tutorials](#tutorials)\n   * [What about other Turing tutorials?](#what-about-other-turing-tutorials)\n   * [How to cite](#how-to-cite)\n   * [References](#references)\n      * [Books](#books)\n      * [Academic Papers](#academic-papers)\n         * [Primary](#primary)\n         * [Auxiliary](#auxiliary)\n   * [License](#license)\n\n## Julia\n\n[**Julia**](https://www.julialang.org) is a fast dynamic-typed language that just-in-time (JIT) compiles into native code using LLVM.\nIt [\"runs like C but reads like Python\"](https://www.nature.com/articles/d41586-019-02310-3),\nmeaning that is *blazing* fast, easy to prototype and to read/write code.\nIt is multi-paradigm, combining features of imperative, functional, and object-oriented programming.\nI won't cover Julia basics and any sort of data manipulation using Julia in the tutorials,\ninstead please take a look into the following resources which covers most of the introduction to Julia and how to work with tabular data in Julia:\n\n* [**Julia Documentation**](https://docs.julialang.org/): Julia documentation is a very friendly and well-written resource that explains the basic design and functionality of the language.\n* [**Julia Data Science**](https://juliadatascience.io): open source and open access book on how to do Data Science using Julia.\n* [**Thinking Julia**](https://benlauwens.github.io/ThinkJulia.jl/latest/book.html): introductory beginner-friendly book that explains the main concepts and functionality behind the Julia language.\n* [**Julia High Performance**](https://www.amazon.com/Julia-High-Performance-Avik-Sengupta/dp/178829811X): book by two of the creators of the Julia Language ([Avik Sengupta](https://www.linkedin.com/in/aviks) and [Alan Edelman](http://www-math.mit.edu/~edelman/)), it covers how to make Julia even faster with some principles and tricks of the trade.\n* [**An Introduction DataFrames**](https://github.com/bkamins/Julia-DataFrames-Tutorial): the package [`DataFrames.jl`](https://dataframes.juliadata.org/stable/) provides a set of tools for working with tabular data in Julia. Its design and functionality are similar to those of `pandas` (in Python) and `data.frame`, `data.table` and `dplyr` (in R), making it a great general purpose data science tool, especially for those coming to Julia from R or Python.This is a collection of notebooks that introduces `DataFrames.jl` made by one of its core contributors [Bogumił Kamiński](https://github.com/bkamins).\n\n## Turing\n\n[**Turing**](http://turing.ml/) is an ecosystem of Julia packages for Bayesian Inference using [probabilistic programming](https://en.wikipedia.org/wiki/Probabilistic_programming).\nModels specified using Turing are easy to read and write — models work the way you write them. Like everything in Julia, Turing is [fast](https://arxiv.org/abs/2002.02702).\n\n## Author\n\nJose Storopoli, PhD - [*Lattes* CV](http://lattes.cnpq.br/2281909649311607) - [ORCID](https://orcid.org/0000-0002-0559-5176) - \u003chttps://storopoli.io\u003e\n\n## How to use the content?\n\nThe content is licensed under a very permissive Creative Commons license (CC BY-SA).\nYou are mostly welcome to contribute with [issues](https://www.github.com/storopoli/Bayesian-Julia/issues) and [pull requests](https://github.com/storopoli/Bayesian-Julia/pulls).\nMy hope is to have **more people into Bayesian statistics**. The content is aimed towards social scientists and PhD candidates in social sciences.\nI chose to provide an **intuitive approach** rather than focusing on rigorous mathematical formulations.\nI've made it to be how I would have liked to be introduced to Bayesian statistics.\n\nTo configure a local environment:\n\n1. Download and install [Julia](https://www.julialang.org/downloads/)\n2.  Clone the repository from GitHub:\n    `git clone https://github.com/storopoli/Bayesian-Julia.git`\n3.  Access the directory: `cd Bayesian-Julia`\n4.  Activate the environment by typing in the Julia REPL:\n    ```julia\n    using Pkg\n    Pkg.activate(\".\")\n    Pkg.instantiate()\n    ```\n\n## Tutorials\n\n1. [**Why Julia?**](https://storopoli.io/Bayesian-Julia/pages/01_why_Julia/)\n2. [**What is Bayesian Statistics?**](https://storopoli.io/Bayesian-Julia/pages/02_bayes_stats/)\n3. [**Common Probability Distributions**](https://storopoli.io/Bayesian-Julia/pages/03_prob_dist/)\n4. [**How to use Turing**](https://storopoli.io/Bayesian-Julia/pages/04_Turing/)\n5. [**Markov Chain Monte Carlo (MCMC)**](https://storopoli.io/Bayesian-Julia/pages/05_MCMC/)\n6. [**Bayesian Linear Regression**](https://storopoli.io/Bayesian-Julia/pages/06_linear_reg/)\n7. [**Bayesian Logistic Regression**](https://storopoli.io/Bayesian-Julia/pages/07_logistic_reg/)\n8. [**Bayesian Ordinal Regression**](https://storopoli.io/Bayesian-Julia/pages/08_ordinal_reg/)\n9. [**Bayesian Regression with Count Data**](https://storopoli.io/Bayesian-Julia/pages/09_count_reg/)\n10. [**Robust Bayesian Regression**](https://storopoli.io/Bayesian-Julia/pages/10_robust_reg/)\n11. [**Multilevel Models (a.k.a. Hierarchical Models)**](https://storopoli.io/Bayesian-Julia/pages/11_multilevel_models/)\n12. [**Computational Tricks with Turing (Non-Centered Parametrization and QR Decomposition)**](https://storopoli.io/Bayesian-Julia/pages/12_Turing_tricks/)\n13. [**Epidemiological Models using ODE Solvers in Turing**](https://storopoli.io/Bayesian-Julia/pages/13_epi_models/)\n\n## Datasets\n\n- `kidiq` (linear regression): data from a survey of adult American women and their children\n   (a subsample from the National Longitudinal Survey of Youth).\n   Source: Gelman and Hill (2007).\n- `wells` (logistic regression): a survey of 3200 residents in a small area of Bangladesh suffering\n   from arsenic contamination of groundwater.\n   Respondents with elevated arsenic levels in their wells had been encouraged to switch their water source\n   to a safe public or private well in the nearby area\n   and the survey was conducted several years later to\n   learn which of the affected residents had switched wells.\n   Source: Gelman and Hill (2007).\n- `esoph` (ordinal regression): data from a case-control study of (o)esophageal cancer in Ille-et-Vilaine, France.\n   Source: Breslow and Day (1980).\n- `roaches` (Poisson regression): data on the efficacy of a pest management system at reducing the number of roaches in urban apartments.\n   Source: Gelman and Hill (2007).\n- `duncan` (robust regression): data from occupation's prestige filled with outliers.\n   Source: Duncan (1961).\n- `cheese` (hierarchical models): data from cheese ratings.\n   A group of 10 rural and 10 urban raters rated 4 types of different cheeses (A, B, C and D) in two samples.\n   Source: Boatwright, McCulloch and Rossi (1999).\n\n## What about other Turing tutorials?\n\nDespite not being the only Turing tutorial that exists, this tutorial aims to introduce Bayesian inference along with how to use Julia and Turing.\nHere is a (not complete) list of other Turing tutorials:\n\n1. [**Official Turing Tutorials**](https://turing.ml/dev/tutorials/): tutorials on how to implement common models in Turing\n2. [**Statistical Rethinking - Turing Models**](https://statisticalrethinkingjulia.github.io/TuringModels.jl/): Julia versions of the Bayesian models described in *Statistical Rethinking* Edition 1 (McElreath, 2016) and Edition 2 (McElreath, 2020)\n3. [**Håkan Kjellerstrand Turing Tutorials**](http://hakank.org/julia/turing/): a collection of Julia Turing models\n\nI also have a free and opensource graduate course on Bayesian Statistics with Turing and Stan code.\nYou can find it at [`storopoli/Bayesian-Statistics`](https://github.com/storopoli/Bayesian-Statistics).\n\n## How to cite\n\nTo cite these tutorials, please use:\n\n    Storopoli (2021). Bayesian Statistics with Julia and Turing. https://storopoli.io/Bayesian-Julia.\n\nOr in BibTeX format (LaTeX):\n\n    @misc{storopoli2021bayesianjulia,\n      author = {Storopoli, Jose},\n      title = {Bayesian Statistics with Julia and Turing},\n      url = {https://storopoli.io/Bayesian-Julia},\n      year = {2021}\n    }\n\n## References\n\nThe references are divided in **books**, **papers**, **software**, and **datasets**.\n\n### Books\n\n* Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., \u0026 Rubin, D. B. (2013). *Bayesian Data Analysis*. Chapman and Hall/CRC.\n* McElreath, R. (2020). *Statistical rethinking: A Bayesian course with examples in R and Stan*. CRC press.\n* Gelman, A., Hill, J., \u0026 Vehtari, A. (2020). *Regression and other stories*. Cambridge University Press.\n* Brooks, S., Gelman, A., Jones, G., \u0026 Meng, X.-L. (2011). *Handbook of Markov Chain Monte Carlo*. CRC Press. \u003chttps://books.google.com?id=qfRsAIKZ4rIC\u003e\n    * Geyer, C. J. (2011). Introduction to markov chain monte carlo. In S. Brooks, A. Gelman, G. L. Jones, \u0026 X.-L. Meng (Eds.), *Handbook of markov chain monte carlo*.\n\n### Academic Papers\n\n* van de Schoot, R., Depaoli, S., King, R., Kramer, B., Märtens, K., Tadesse, M. G., Vannucci, M., Gelman, A., Veen, D., Willemsen, J., \u0026 Yau, C. (2021). Bayesian statistics and modelling. *Nature Reviews Methods Primers*, *1*(1, 1), 1–26. \u003chttps://doi.org/10.1038/s43586-020-00001-2\u003e\n* Gabry, J., Simpson, D., Vehtari, A., Betancourt, M., \u0026 Gelman, A. (2019). Visualization in Bayesian workflow. *Journal of the Royal Statistical Society: Series A (Statistics in Society)*, *182*(2), 389–402. \u003chttps://doi.org/10.1111/rssa.12378\u003e\n* Gelman, A., Vehtari, A., Simpson, D., Margossian, C. C., Carpenter, B., Yao, Y., Kennedy, L., Gabry, J., Bürkner, P.-C., \u0026 Modr’ak, M. (2020, November 3). *Bayesian Workflow*. \u003chttp://arxiv.org/abs/2011.01808\u003e\n* Benjamin, D. J., Berger, J. O., Johannesson, M., Nosek, B. A., Wagenmakers, E.-J., Berk, R., Bollen, K. A., Brembs, B., Brown, L., Camerer, C., Cesarini, D., Chambers, C. D., Clyde, M., Cook, T. D., De Boeck, P., Dienes, Z., Dreber, A., Easwaran, K., Efferson, C., … Johnson, V. E. (2018). Redefine statistical significance. *Nature Human Behaviour*, *2*(1), 6–10. \u003chttps://doi.org/10.1038/s41562-017-0189-z\u003e\n* McShane, B. B., Gal, D., Gelman, A., Robert, C., \u0026 Tackett, J. L. (2019). Abandon Statistical Significance. *American Statistician*, *73*, 235–245. \u003chttps://doi.org/10.1080/00031305.2018.1527253\u003e\n* Amrhein, V., Greenland, S., \u0026 McShane, B. (2019). Scientists rise up against statistical significance. *Nature*, *567*(7748), 305–307. \u003chttps://doi.org/10.1038/d41586-019-00857-9\u003e\n* van de Schoot, R., Kaplan, D., Denissen, J., Asendorpf, J. B., Neyer, F. J., \u0026 van Aken, M. A. G. (2014). A Gentle Introduction to Bayesian Analysis: Applications to Developmental Research. *Child Development*, *85*(3), 842–860. \u003chttps://doi.org/10.1111/cdev.12169\u003e\n\n### Software\n\n* Bezanson, J., Edelman, A., Karpinski, S., \u0026 Shah, V. B. (2017). Julia: A fresh approach to numerical computing. SIAM Review, 59(1), 65–98.\n* Ge, H., Xu, K., \u0026 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\n* Tarek, M., Xu, K., Trapp, M., Ge, H., \u0026 Ghahramani, Z. (2020). DynamicPPL: Stan-like Speed for Dynamic Probabilistic Models. ArXiv:2002.02702 [Cs, Stat]. http://arxiv.org/abs/2002.02702\n* Xu, K., Ge, H., Tebbutt, W., Tarek, M., Trapp, M., \u0026 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\n* Revels, J., Lubin, M., \u0026 Papamarkou, T. (2016). Forward-Mode Automatic Differentiation in Julia. ArXiv:1607.07892 [Cs]. http://arxiv.org/abs/1607.07892\n\n### Datasets\n\n-   Boatwright, P., McCulloch, R., \u0026 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.\n-   Breslow, N. E. \u0026 Day, N. E. (1980). **Statistical Methods in Cancer Research. Volume 1: The Analysis of Case-Control Studies**. IARC Lyon / Oxford University Press.\n-   Duncan, O. D. (1961). A socioeconomic index for all occupations. Class: Critical Concepts, 1, 388–426.\n-   Gelman, A., \u0026 Hill, J. (2007). **Data analysis using regression and\n    multilevel/hierarchical models**. Cambridge university press.\n\n## License\n\nThis content is licensed under [Creative Commons Attribution-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).\n\n[![CC BY-SA 4.0](https://licensebuttons.net/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoropoli%2Fbayesian-julia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoropoli%2Fbayesian-julia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoropoli%2Fbayesian-julia/lists"}