Skip to content

Materials for RTC workshop on Bayesian analysis with brms and stan

Notifications You must be signed in to change notification settings

romeopenheiro/bayes-workshop

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Workshop: Bayesian analysis with R using brms and Stan

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...

Description

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'.

Objectives

  1. To give a conceptual understanding of Bayesian data analysis
  2. Introduce the brms package for R
  3. Work on several example analyses
    • specifying the model
    • choosing priors
    • evaluating convergence
    • posterior predictive checks
    • model comparison (including Bayes' factors)
  4. Introduce the Stan model language and work through some examples

Materials

Slides

  • intro.html - conceptual introduction to Bayesian analysis
  • brms.html - introduction to brms with examples
  • stan.html - introduction to Stan with examples
  • mcmc.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)

Examples

  • brms-example1.R - analysis of the sleepstudy dataset from the lme4 package. Reaction times after different amounts of sleep deprivation
  • brms-example2.R - analysis of a hypothetical memory study where two groups recall items under two different conditions. Outcome is recall accuracy (see sim-brms-ex2.R for code to simulate dataset)
  • brms-example3.R - analysis of the wine dataset from the ordinal package. Ordinal ratings of wine betterness
  • stan-example1.R - analysis of the sleepstudy dataset with Stan (see stan-models folder)
  • stan-example2.R - analysis of two-dimensional recall data that (I think) cannot be handled by brms (see sim-recall-2D.R for code to simulate dataset)

Prerequisites

This workshop assumes familiarity with:

  • The R language
  • Some probability distributions
  • Linear mixed effects models (users of lme4 will have a head start)

Contact

Please send questions/ comments/ suggestions to: [email protected]

About

Materials for RTC workshop on Bayesian analysis with brms and stan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 99.9%
  • R 0.1%