Slides from my RStanARM tutorial
Back in September, I gave a tutorial on RStanARM to the Madison R userβs group. As I did for my magrittr tutorial, I broke the content down into slide decks. They were:
 How I got into Bayesian statistics
 Some intuitionbuilding about Bayes theorem
 Tour of RStanARM
 Where to learn more about Bayesian statistics
The source code and supporting materials are on Github.
Observations (training data)
The intuitionbuilding section was the most challenging and rewarding, because I had to brush up on Bayesian statistics well enough to informally, handwavily teach about it to a crowd of R users. Like, I have good sense of how to fit these models and interpret them in practice, but thereβs a gulf between understanding something and teaching about it. It was a bit of trial by fire π₯.
One thing I did was work through a toy Bayesian updating demo. Whatβs the mean of some IQ scores, assuming a standard deviation of 15 and a flat prior over a reasonable range values? Cue some plots of how the distribution of probabilities update as new data is observed.
See how the beliefs are updated? See how we retain uncertainty around that most likely value? And so on.
Naturally, I animated the thingβIβll take any excuse to use gganimate.
Someone asked a good question about what advantages these models have over classical ones. I find the models more intuitive^{1}, because posterior probabilities are postdata probabilities. I also find them more flexible. For example, I can use a tdistribution for my error termsβthick tails! If I write the thing in Stan, I can incorporate measurement error into the model. If I put my head down and work really hard, I could even fit one of those gorgeous Gaussian process models. We can fit vanilla regression models or get really, really fancy, but it all kind of emerges nicely from the general framework of writing out priors and a likelihood definition.
Last knitted on 20220527. Source code on GitHub.^{2}

But I was taught the classical models firstβ¦ I sometimes think that these models are only more intuitive because this is my second bite at the apple. This learning came more easily because the first time I learned regression, I was a total novice and had to learn everything. I had learn to about ttest, reductions in variance, collinearity, and what interactions do. Here, I can build off of that prior learning. Maybe if I learn everything againβas what? everything as a neural network?βit will be even more intuitive.Β ↩

.session_info #> β Session info βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ #> setting value #> version R version 4.2.0 (20220422 ucrt) #> os Windows 10 x64 (build 22000) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.utf8 #> ctype English_United States.utf8 #> tz America/Chicago #> date 20220527 #> pandoc NA #> #> β Packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ #> package * version date (UTC) lib source #> assertthat 0.2.1 20190321 [1] CRAN (R 4.2.0) #> cli 3.3.0 20220425 [1] CRAN (R 4.2.0) #> crayon 1.5.1 20220326 [1] CRAN (R 4.2.0) #> emo 0.0.0.9000 20220525 [1] Github (hadley/emo@3f03b11) #> evaluate 0.15 20220218 [1] CRAN (R 4.2.0) #> generics 0.1.2 20220131 [1] CRAN (R 4.2.0) #> git2r 0.30.1 20220316 [1] CRAN (R 4.2.0) #> glue 1.6.2 20220224 [1] CRAN (R 4.2.0) #> here 1.0.1 20201213 [1] CRAN (R 4.2.0) #> highr 0.9 20210416 [1] CRAN (R 4.2.0) #> knitr * 1.39 20220426 [1] CRAN (R 4.2.0) #> lubridate 1.8.0 20211007 [1] CRAN (R 4.2.0) #> magrittr 2.0.3 20220330 [1] CRAN (R 4.2.0) #> purrr 0.3.4 20200417 [1] CRAN (R 4.2.0) #> ragg 1.2.2 20220221 [1] CRAN (R 4.2.0) #> rlang 1.0.2 20220304 [1] CRAN (R 4.2.0) #> rprojroot 2.0.3 20220402 [1] CRAN (R 4.2.0) #> rstudioapi 0.13 20201112 [1] CRAN (R 4.2.0) #> sessioninfo 1.2.2 20211206 [1] CRAN (R 4.2.0) #> stringi 1.7.6 20211129 [1] CRAN (R 4.2.0) #> stringr 1.4.0 20190210 [1] CRAN (R 4.2.0) #> systemfonts 1.0.4 20220211 [1] CRAN (R 4.2.0) #> textshaping 0.3.6 20211013 [1] CRAN (R 4.2.0) #> xfun 0.31 20220510 [1] CRAN (R 4.2.0) #> #> [1] C:/Users/Tristan/AppData/Local/R/winlibrary/4.2 #> [2] C:/Program Files/R/R4.2.0/library #> #> ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Leave a comment