-
Notifications
You must be signed in to change notification settings - Fork 556
/
demos.Rmd
123 lines (106 loc) · 10.2 KB
/
demos.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: "Bayesian Data Analysis course - Demos"
date: "Page updated: `r format.Date(file.mtime('demos.Rmd'),'%Y-%m-%d')`"
---
## BDA R demos
The [BDA_R_demos repository](https://github.com/avehtari/BDA_R_demos) contains some R demos and additional notes for the book [Bayesian Data
Analysis, 3rd ed by Gelman, Carlin, Stern, Dunson, Vehtari, and Rubin (BDA3)](http://www.stat.columbia.edu/~gelman/book/).
Currently there are demos for BDA3 Chapters 2, 3, 4, 5, 6, 10, 11 and 12.
Furthermore there are demos for
[RStan](https://github.com/stan-dev/rstan) and
[RStanARM](https://github.com/stan-dev/rstanarm).
The initial demos were originally written for Matlab/Octave by [Aki
Vehtari](http://users.aalto.fi/~ave/) and translated to R by [Markus
Paasiniemi](https://github.com/paasim). Recently more demos have been
added for [RStan](http://avehtari.github.io/BDA_R_demos/demos_rstan/rstan_demo.html),
[CmdStanR](http://avehtari.github.io/BDA_R_demos/demos_rstan/cmdstanr_demo.html)
and [RStanARM](http://avehtari.github.io/BDA_R_demos/demos_rstan/rstanarm_demo.html).
Unless otherwise specified in specific files all code licensed
under BSD-3 and all text, slides and figures licensed under CC-BY-NC 4.0.
See also [Model Selection tutorial](https://avehtari.github.io/modelselection/).
- [ZIP file for all R demos](https://codeload.github.com/avehtari/BDA_R_demos/zip/master)
- [Chapter 2](https://avehtari.github.io/BDA_R_demos/demos_ch2/)
- [2.1: Probability of a girl birth given placenta previa (BDA3 p. 37)](https://avehtari.github.io/BDA_R_demos/demos_ch2/demo2_1.html)
- [2.2: Illustrate the effect of prior in binomial model](https://avehtari.github.io/BDA_R_demos/demos_ch2/demo2_2.html)
- [2.3: Illustrate simulation based inference](https://avehtari.github.io/BDA_R_demos/demos_ch2/demo2_3.html)
- [2.4: Illustrate grid and inverse-cdf sampling](https://avehtari.github.io/BDA_R_demos/demos_ch2/demo2_4.html)
- [Chapter 3](https://avehtari.github.io/BDA_R_demos/demos_ch3)
- [3.1_4: Normal model with unknown mean and variance (BDA3 section 3.2 on p. 64)](https://avehtari.github.io/BDA_R_demos/demos_ch3/demo3_1_4.html)
- [3.5: Estimating the speed of light using normal model BDA3 p. 66](https://avehtari.github.io/BDA_R_demos/demos_ch3/demo3_5.html)
- [3.6: Binomial regression and grid sampling with bioassay data (BDA3 p. 74-)](https://avehtari.github.io/BDA_R_demos/demos_ch3/demo3_6.html)
- [Chapter 4](https://avehtari.github.io/BDA_R_demos/demos_ch4)
- [4.1: Normal approximation for binomial regression model and Bioassay data](https://avehtari.github.io/BDA_R_demos/demos_ch4/demo4_1.html)
- [Chapter 5](https://avehtari.github.io/BDA_R_demos/demos_ch5)
- [5.1: Hierarchical model for Rats experiment (BDA3, p. 102)](https://avehtari.github.io/BDA_R_demos/demos_ch5/demo5_1.html)
- [5.2: Hierarchical model for SAT-example data (BDA3, p. 102)](https://avehtari.github.io/BDA_R_demos/demos_ch5/demo5_2.html)
- [Chapter 6](https://avehtari.github.io/BDA_R_demos/demos_ch6)
- [6.1: Posterior predictive checking of normal model for light data](https://avehtari.github.io/BDA_R_demos/demos_ch6/demo6_1.html)
- [6.2: Posterior predictive checking for independence in binomial trials](https://avehtari.github.io/BDA_R_demos/demos_ch6/demo6_2.html)
- [6.3: Posterior predictive checking of normal model with poor test statistic](https://avehtari.github.io/BDA_R_demos/demos_ch6/demo6_3.html)
- [6.4: Marginal posterior predictive checking with PIT test](https://avehtari.github.io/BDA_R_demos/demos_ch6/demo6_4.html)
- Chapter 7
- See [model selection tutorial](https://github.com/avehtari/modelselection_tutorial)
- [Chapter 10](https://avehtari.github.io/BDA_R_demos/demos_ch10)
- [10.1: Rejection sampling](https://avehtari.github.io/BDA_R_demos/demos_ch10/demo10_1.html)
- [10.2: Importance sampling](https://avehtari.github.io/BDA_R_demos/demos_ch10/demo10_2.html)
- [10.3: Importance sampling with normal distribution as a proposal for Bioassay model](https://avehtari.github.io/BDA_R_demos/demos_ch10/demo10_3.html)
- [Chapter 11](https://avehtari.github.io/BDA_R_demos/demos_ch11)
- [11.1: Gibbs sampling illustration](https://avehtari.github.io/BDA_R_demos/demos_ch11/demo11_1.html)
- [11.2: Metropolis sampling + convergence illustration](https://avehtari.github.io/BDA_R_demos/demos_ch11/demo11_2.html)
- [11.3_4: Metropolis sampling + convergence illustration](https://avehtari.github.io/BDA_R_demos/demos_ch11/demo11_3_4.html)
- [11.5: Diagnostics with posterior and bayesplot packages](https://avehtari.github.io/BDA_R_demos/demos_ch11/demo11_5.html)
- [Chapter 12](https://avehtari.github.io/BDA_R_demos/demos_ch12)
- [12.1: Static Hamiltonian Monte Carlo illustration](https://avehtari.github.io/BDA_R_demos/demos_ch12/demo12_1.html)
- [12.2: NUTS / Dynamic Hamiltonian Monte Carlo illustration](https://avehtari.github.io/BDA_R_demos/demos_ch12/demo12_2.html)
- [CmdStanR, RStan and RStanARM](https://avehtari.github.io/BDA_R_demos/demos_rstan)
- [CmdStanR demos](http://avehtari.github.io/BDA_R_demos/demos_rstan/cmdstanr_demo.html)
- [RStan demos](http://avehtari.github.io/BDA_R_demos/demos_rstan/rstan_demo.html)
- [RStanARM demos](http://avehtari.github.io/BDA_R_demos/demos_rstan/rstanarm_demo.html)
- [Posterior predictive checking](http://avehtari.github.io/BDA_R_demos/demos_rstan/ppc/poisson-ppc.html)
- [Does brain mass predict how much mammals sleep in a day?](http://avehtari.github.io/BDA_R_demos/demos_rstan/sleep.html)
- [Non-linear model for traffic deaths in Finland](http://avehtari.github.io/BDA_R_demos/demos_rstan/trafficdeaths.html)
- [Extreme value analysis and user defined probability functions in Stan](http://mc-stan.org/users/documentation/case-studies/gpareto_functions.html)
## BDA Python demos
[BDA_py_demos repository](https://github.com/avehtari/BDA_py_demos) some Python demos for the book [Bayesian Data
Analysis, 3rd ed by Gelman, Carlin, Stern, Dunson, Vehtari, and Rubin (BDA3)](http://www.stat.columbia.edu/~gelman/book/).
Currently there are demos for BDA3 Chapters 2, 3, 4, 5, 6, 10 and 11. Furthermore, there are demos for [PyStan](https://github.com/stan-dev/pystan).
Demos are in jupyter notebook (.ipynb) format. These can be directly previewed in GitHub without need to install or run anything.
Corresponding demos were originally written for Matlab/Octave by [Aki Vehtari](http://users.aalto.fi/~ave/) and translated to Python by Tuomas Sivula. Some improvements were contributed by Pellervo Ruponen and Lassi Meronen.
- [ZIP file for all Python demos](https://codeload.github.com/avehtari/BDA_py_demos/zip/master)
- [Chapter 2](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch2)
- [2.1: Probability of a girl birth given placenta previa (BDA3 p. 37)](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch2/demo2_1.ipynb)
- [2.2: Illustrate the effect of prior in binomial model](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch2/demo2_2.ipynb)
- [2.3: Illustrate simulation based inference](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch2/demo2_3.ipynb)
- [2.4: Illustrate grid and inverse-cdf sampling](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch2/demo2_4.ipynb)
- [Chapter 3](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch3)
- [3.1_4: Normal model with unknown mean and variance (BDA3 section 3.2 on p. 64)](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch3/demo3_1-4.ipynb)
- [3.5: Estimating the speed of light using normal model BDA3 p. 66](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch3/demo3_5.ipynb)
- [3.6: Binomial regression and grid sampling with bioassay data (BDA3 p. 74-)](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch3/demo3_6.ipynb)
- [Chapter 4](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch4)
- [4.1: Normal approximation for binomial regression model and Bioassay data](https://github.com/avehtari/BDA_py_demos/blob/master/demos_ch4/demo4_1.ipynb)
- [Chapter 5](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch5)
- [5.1: Hierarchical model for Rats experiment (BDA3, p. 102)](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch5/demo5_1.ipynb)
- [5.2: Hierarchical model for SAT-example data (BDA3, p. 102)](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch5/demo5_2.ipynb)
- [Chapter 6](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch6)
- [6.1: Posterior predictive checking of normal model for light data](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch6/demo6_1.ipynb)
- [6.2: Posterior predictive checking for independence in binomial trials](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch6/demo6_2.ipynb)
- [6.3: Posterior predictive checking of normal model with poor test statistic](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch6/demo6_3.ipynb)
- [6.4: Marginal posterior predictive checking with PIT test](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch6/demo6_4.ipynb)
- [Chapter 10](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch10)
- [10.1: Rejection sampling](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch10/demo10_1.ipynb)
- [10.2: Importance sampling](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch10/demo10_2.ipynb)
- [10.3: Importance sampling with normal distribution as a proposal for Bioassay model](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch10/demo10_3.ipynb)
- [Chapter 11](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch11)
- [11.1: Gibbs sampling illustration](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch11/demo11_1.ipynb)
- [11.2: Metropolis sampling + convergence illustration](https://github.com/avehtari/BDA_py_demos/tree/master/demos_ch11/demo11_2.ipynb)
- [PyStan](https://github.com/avehtari/BDA_py_demos/tree/master/demos_pystan)
- [PyStan test installation](https://github.com/avehtari/BDA_py_demos/blob/master/demos_pystan/PyStan_test_installation.ipynb)
- [PyStan demos](https://github.com/avehtari/BDA_py_demos/blob/master/demos_pystan/pystan_demo.ipynb)
### Python requirements
- python 3
- ipython
- numpy
- scipy
- matplotlib 2
- pandas (for some demos)
- pystan (for some demos)