Skip to content

Commit ab55626

Browse files
committed
update readme, minor edits
1 parent 78f6f43 commit ab55626

18 files changed

+251
-20
lines changed

06_issues.Rmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ theta0 = initValue
114114
theta = c(theta0, rep(NA, nsim))
115115
116116
for (t in 2:nsim) {
117-
thetaStar = rnorm(1, theta[-1], sd)
117+
thetaStar = rnorm(1, theta[t-1], sd)
118118
u = runif(1)
119119
r = exp(logPosterior_thetaStar - logPosterior_theta0)
120-
theta[t] = ifelse(u<=r, thetaStar, theta[-1])
120+
theta[t] = ifelse(u<=r, thetaStar, theta[t-1])
121121
}
122122
```
123123

LICENSE.md

+177
Large diffs are not rendered by default.

README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1-
# bayesian-basics
1+
# Bayesian Basics
22

3-
Raw files for a document that introduces Bayesian data analysis. While the focus is on concepts, demonstration is primarily via Stan, though BUGS, JAGS, and some raw R code is also available for those interested. [link to doc](https://m-clark.github.io/bayesian-basics/)
3+
This is a document that introduces Bayesian data analysis. It serves as a practical and applied introduction to Bayesian approaches for the uninitiated. The goal is to provide just enough information in a brief format to allow one to feel comfortable exploring Bayesian data analysis for themselves, assuming they have the requisite context to begin with.
4+
5+
6+
After a conceptual introduction, a fully visible by-hand example is provided using the binomial distribution. After that, the document proceeds to introduce fully Bayesian analysis with the standard linear regression model, as that is the basis for most applied statistics courses and is assumed to be most familiar to the reader. Model diagnostics, model enhancements, and additional modeling issues are then explored. Supplemental content in the appendix provides more technical detail if desired, and includes a maximum likelihood refresher, an overview of programming options in Bayesian analysis, the same regression model using BUGS and JAGS, and 'by-hand' code for the model using the Metropolis-Hastings and Hamiltonian Monte Carlo algorithms. [link to doc](https://m-clark.github.io/bayesian-basics/)
7+
8+
Contents:
9+
10+
- The Bayesian Idea
11+
- A by-hand example
12+
- A standard regression model
13+
- Diagnostics
14+
- Model enhancements
15+
- Common issues encountered
16+
- An appendix with some more detailed code exposition
17+
18+
19+
<img src="img/priorpost.png" style="display:block; margin: 0 auto;">
20+
21+
22+
There is a [shiny app to play with](https://micl.shinyapps.io/prior2post/) also.

docs/Bayesian-Basics.epub

2 Bytes
Binary file not shown.

docs/a-hands-on-example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/appendix.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/final-thoughts.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">
@@ -229,7 +229,7 @@ <h1 class="title"><span style="font-size:250%; font-style:italic; font-family:&#
229229
<h4 class="author"><em><div class="title">
230230
<span style="font-size:150%; font-variant:small-caps; font-style:normal; font-family:&#39;Roboto&#39;">Michael Clark</span><br><br> <img src="img/signature-acronym.png" style="width:30%; padding:10px 0;"> <br> <img src="img/ARC-acronym-signature.png" style="width:21%; padding:10px 0;">
231231
</div></em></h4>
232-
<h4 class="date"><em>2018-05-11</em></h4>
232+
<h4 class="date"><em>2018-05-17</em></h4>
233233
</div>
234234
<div id="section" class="section level1">
235235
<h1></h1>

docs/introduction.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/issues.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">
@@ -299,10 +299,10 @@ <h3>Metropolis</h3>
299299
theta =<span class="st"> </span><span class="kw">c</span>(theta0, <span class="kw">rep</span>(<span class="ot">NA</span>, nsim))
300300

301301
<span class="cf">for</span> (t <span class="cf">in</span> <span class="dv">2</span><span class="op">:</span>nsim) {
302-
thetaStar =<span class="st"> </span><span class="kw">rnorm</span>(<span class="dv">1</span>, theta[<span class="op">-</span><span class="dv">1</span>], sd)
302+
thetaStar =<span class="st"> </span><span class="kw">rnorm</span>(<span class="dv">1</span>, theta[t<span class="op">-</span><span class="dv">1</span>], sd)
303303
u =<span class="st"> </span><span class="kw">runif</span>(<span class="dv">1</span>)
304304
r =<span class="st"> </span><span class="kw">exp</span>(logPosterior_thetaStar <span class="op">-</span><span class="st"> </span>logPosterior_theta0)
305-
theta[t] =<span class="st"> </span><span class="kw">ifelse</span>(u<span class="op">&lt;=</span>r, thetaStar, theta[<span class="op">-</span><span class="dv">1</span>])
305+
theta[t] =<span class="st"> </span><span class="kw">ifelse</span>(u<span class="op">&lt;=</span>r, thetaStar, theta[t<span class="op">-</span><span class="dv">1</span>])
306306
}</code></pre></div>
307307
<p>One can see the <a href="appendix.html#metropolis-hastings-example">Metropolis-Hastings Example</a> to see the Metropolis algorithm applied to our regression problem.</p>
308308
</div>

docs/model-enhancements.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/model-exploration.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/preface.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/references.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/regression-models.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
<meta name="date" content="2018-05-11">
27+
<meta name="date" content="2018-05-17">
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
3030
<meta name="apple-mobile-web-app-capable" content="yes">

docs/search_index.json

+2-2
Large diffs are not rendered by default.

img/priorpost.png

148 KB
Loading

packages.bib

+35
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,34 @@ @Manual{R-base
66
year = {2018},
77
url = {https://www.R-project.org/},
88
}
9+
@Manual{R-bbmle,
10+
title = {bbmle: Tools for General Maximum Likelihood Estimation},
11+
author = {Ben Bolker and R Development Core Team},
12+
year = {2017},
13+
note = {R package version 1.0.20},
14+
url = {https://CRAN.R-project.org/package=bbmle},
15+
}
16+
@Manual{R-bindrcpp,
17+
title = {bindrcpp: An 'Rcpp' Interface to Active Bindings},
18+
author = {Kirill Müller},
19+
year = {2018},
20+
note = {R package version 0.2.2},
21+
url = {https://CRAN.R-project.org/package=bindrcpp},
22+
}
923
@Manual{R-bookdown,
1024
title = {bookdown: Authoring Books and Technical Documents with R Markdown},
1125
author = {Yihui Xie},
1226
year = {2018},
1327
note = {R package version 0.7},
1428
url = {https://CRAN.R-project.org/package=bookdown},
1529
}
30+
@Manual{R-coda,
31+
title = {coda: Output Analysis and Diagnostics for MCMC},
32+
author = {Martyn Plummer and Nicky Best and Kate Cowles and Karen Vines and Deepayan Sarkar and Douglas Bates and Russell Almond and Arni Magnusson},
33+
year = {2016},
34+
note = {R package version 0.19-1},
35+
url = {https://CRAN.R-project.org/package=coda},
36+
}
1637
@Manual{R-dplyr,
1738
title = {dplyr: A Grammar of Data Manipulation},
1839
author = {Hadley Wickham and Romain Francois and Lionel Henry and Kirill Müller},
@@ -76,6 +97,20 @@ @Manual{R-rmarkdown
7697
note = {R package version 1.9},
7798
url = {https://CRAN.R-project.org/package=rmarkdown},
7899
}
100+
@Manual{R-rstan,
101+
title = {rstan: R Interface to Stan},
102+
author = {Jiqiang Guo and Jonah Gabry and Ben Goodrich},
103+
year = {2018},
104+
note = {R package version 2.17.3},
105+
url = {https://CRAN.R-project.org/package=rstan},
106+
}
107+
@Manual{R-StanHeaders,
108+
title = {StanHeaders: C++ Header Files for Stan},
109+
author = {Ben Goodrich and Andrew Gelman and Bob Carpenter and Matt Hoffman and Daniel Lee and Michael Betancourt and Marcus Brubaker and Jiqiang Guo and Peter Li and Allen Riddell and Marco Inacio and Mitzi Morris and Jeffrey Arnold and Rob Goedman and Brian Lau and Rob Trangucci and Jonah Gabry and Alp Kucukelbir and Robert Grant and Dustin Tran and Michael Malecki and Yuanjun Gao},
110+
year = {2018},
111+
note = {R package version 2.17.2},
112+
url = {https://CRAN.R-project.org/package=StanHeaders},
113+
}
79114
@Manual{R-stringr,
80115
title = {stringr: Simple, Consistent Wrappers for Common String Operations},
81116
author = {Hadley Wickham},

0 commit comments

Comments
 (0)