This is a Turing Workshop on how to do Bayesian Statistics. The Workshop is heavily based on tutorials available at storopoli.io/Bayesian-Julia. If you want you can see the YouTube video from the recorded workshop at Stuttgart Julia Programming Language Meetup Group.
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.
$$\underbrace{P(\theta \mid y)}{\text{Posterior}} = \frac{\overbrace{P(y \mid \theta)}^{\text{Likelihood}} \cdot \overbrace{P(\theta)}^{\text{Prior}}}{\underbrace{P(y)}{\text{Normalizing Costant}}}$$
- Julia
- Turing
- Author
- How to use the content?
- What about other Turing tutorials?
- How to cite
- Books
- License
Julia is a fast dynamic-typed language that just-in-time (JIT) compiles into native code using LLVM. It "runs like C but reads like Python", meaning that is blazing fast, easy to prototype and read/write code. It is multi-paradigm, combining features of imperative, functional, and object-oriented programming. I won't cover Julia basics and any sort of data manipulation using Julia in the tutorials, instead please take a look into the following resources which cover most of the introduction to Julia and how to work with tabular data in Julia:
- Julia Documentation: Julia documentation is a very friendly and well-written resource that explains the basic design and functionality of the language.
- Thinking Julia: introductory beginner-friendly book that explains the main concepts and functionality behind the Julia language.
- Julia High Performance: book by two of the creators of the Julia Language (Avik Sengupta and Alan Edelman), it covers how to make Julia even faster with some principles and tricks of the trade.
- An Introduction DataFrames: the package
DataFrames.jl
provides a set of tools for working with tabular data in Julia. Its design and functionality are similar to those ofpandas
(in Python) anddata.frame
,data.table
anddplyr
(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 introducesDataFrames.jl
made by one of its core contributors Bogumił Kamiński.
Turing is a 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.
José Eduardo Storopoli, PhD - Lattes CV - ORCID - https://storopoli.io
I would like to thank Stuttgart Julia Programming Language Meetup Group and Juliane Weilbach for the opportunity to present the first version of this Workshop.
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 social scientists and PhD candidates in social sciences. I chose to provide an intuitive approach rather than focusing on rigorous mathematical formulations. I've made it to be how I would have liked to be introduced to Bayesian statistics.
Just access storopoli.io/Turing-Workshop and click on Edit or run this notebook
and then click on binder
!
To configure a local environment:
- Download and install Julia
- Clone the repository from GitHub:
git clone https://github.com/storopoli/Turing-Workshop.git
- Access the directory:
cd Turing-Workshop
- Run the Pluto Notebook by typing in the Julia REPL:
using Pluto Pluto.run(notebook="Turing_Workshop.jl")
Despite not being the only Turing tutorial that exists, this workshop aims to introduce Bayesian inference along with how to use Julia and Turing. Here is a (not complete) list of other Turing tutorials:
- Official Turing Tutorials: tutorials on how to implement common models in Turing
- Statistical Rethinking - Turing Models: Julia versions of the Bayesian models described in Statistical Rethinking Edition 1 (McElreath, 2016) and Edition 2 (McElreath, 2020)
- Håkan Kjellerstrand Turing Tutorials: a collection of Julia Turing models
To cite these tutorials, please use:
Storopoli (2021). Workshop of Bayesian Statistics with Julia and Turing. https://storopoli.io/Turing-Workshop.
Or in BibTeX format (LaTeX):
@misc{storopoli2021turingworkshop,
author = {Storopoli, Jose},
title = {Workshop of Bayesian Statistics with Julia Turing},
url = {https://storopoli.io/Turing-Workshop},
year = {2021}
}
This content is licensed under Creative Commons Attribution-ShareAlike 4.0 Internacional.