Here are materials for a workshop on Bayesian analysis at the Rotman Research Institute
For this workshop you will need:
- R
- R Studio
- The materials in this repository (click green "Clone or download" button above)
- Some
R
packages, by entering the code below in RStudio
install.packages(c("brms", "rstan", "bridgesampling", "loo", "bayesplot", "coda")) # this might take a while...
This workshop will introduce attendees to Bayesian data analysis and the R
package brms
. brms
stands for 'Bayesian Regression Models using Stan
' and, as the name suggests, it provides a flexible interface to Stan
, which is a powerful program for fitting Bayesian models. brms
can handle a wide range of models and data types and this workshop will cover several example analyses, with a particular focus on (generalized) linear mixed effects models. These example analyses will cover the setting of prior distributions on model parameters, assessing model convergence and fit, and model comparison. The workshop will also introduce the Stan
model language so attendees can start to implement their own bespoke models, as well as better understand what brms
is doing 'under the hood'.
- To give a conceptual understanding of Bayesian data analysis
- Introduce the
brms
package forR
- Work on several example analyses
- specifying the model
- choosing priors
- evaluating convergence
- posterior predictive checks
- model comparison (including Bayes' factors)
- Introduce the
Stan
model language and work through some examples
intro.html
- conceptual introduction to Bayesian analysisbrms.html
- introduction tobrms
with examplesstan.html
- introduction toStan
with examplesmcmc.html
- introduction to MCMC sampling in Bayesian analysis (optional extra)
The .Rmd
files used to create slides are also available (you may need extra packages to knit)
brms-example1.R
- analysis of thesleepstudy
dataset from thelme4
package. Reaction times after different amounts of sleep deprivationbrms-example2.R
- analysis of a hypothetical memory study where two groups recall items under two different conditions. Outcome is recall accuracy (seesim-brms-ex2.R
for code to simulate dataset)brms-example3.R
- analysis of thewine
dataset from theordinal
package. Ordinal ratings of wine betternessstan-example1.R
- analysis of thesleepstudy
dataset withStan
(seestan-models
folder)stan-example2.R
- analysis of two-dimensional recall data that (I think) cannot be handled bybrms
(seesim-recall-2D.R
for code to simulate dataset)
This workshop assumes familiarity with:
- The
R
language - Some probability distributions
- Linear mixed effects models (users of
lme4
will have a head start)
Please send questions/ comments/ suggestions to: [email protected]