/Bayesian_Workshop

Material for a Bayesian statistics workshop

Primary LanguageRCreative Commons Attribution 4.0 InternationalCC-BY-4.0

Bayesian statistics with R / Statistiques bayésiennes avec R

Olivier Gimenez, 2020

DOI

Learning objectives / Objectifs pédagogiques

  • 🇬🇧 Try and demystify Bayesian statistics, and MCMC methods 🇫🇷 Essayer de démystifier les statistiques bayésiennes, et les méthodes MCMC
  • 🇬🇧 Make the difference between Bayesian and Frequentist analyses 🇫🇷 Faire la différence entre analyses bayésiennes et fréquentistes
  • 🇬🇧 Understand the Methods section of a paper that does Bayesian stuff 🇫🇷 Comprendre la section Méthodes d'un papier qui utilise le bayésien
  • 🇬🇧 Run Bayesian analyses with R (in Jags) 🇫🇷 Implémenter des analyses bayésiennes avec R

Schedule / Programme

🇬🇧 Videos are in French, but you may enable subtitles (or closed captions) by clicking on the ⚙️ icon in Youtube (beware though, R is captioned as glass for some reasons 🍷) 🇫🇷 Vidéos disponibles en français

  1. 🇬🇧 Bayesian inference: Motivation and simple example (video starts here) 🇫🇷 Inférence bayésienne : motivation et exemple simple (la vidéo commence ici)
  2. 🇬🇧 The likelihood (video starts here) 🇫🇷 La vraisemblance (la vidéo commence ici)
  3. 🇬🇧 A detour to explore priors (video starts here and goes on there) 🇫🇷 Un détour par les priors (la vidéo commence ici et continue )
  4. 🇬🇧 Markov chains Monte Carlo methods (MCMC) (video starts here) 🇫🇷 Les méthodes de Monte Carlo par chaînes de Markov (MCMC) (la vidéo commence ici)
  5. 🇬🇧 Bayesian analyses in R with the Jags software (video starts here and goes on there) 🇫🇷 Analyses bayésiennes avec R et le logiciel Jags (la vidéo commence ici et continue )
  6. 🇬🇧 Contrast scientific hypotheses with model selection (WAIC) (video starts here) 🇫🇷 Contraster des hypothèses scientifiques avec la sélection de modèles (WAIC) (la vidéo commence ici)
  7. 🇬🇧 Heterogeneity and multilevel models (aka mixed models) (video starts here and goes on there) 🇫🇷 Hétérogénéité et modèles multiniveaux ou mixtes (la vidéo commence ici et continue )

Slides, videos, code and data / Diapos, vidéos, code et données

  • 🇬🇧 Slides available here 🇫🇷 Diapos disponible ici
  • 🇬🇧 Videos available in French via Youtube (you may enable subtitles or closed captions by clicking on the gear icon; R is captioned as glass for some reasons) 🇫🇷 Vidéos disponibles en français
    • slides 1-80, watch here / diapos 1-80, regardez ici
    • slides 81-131, watch here / diapos 81-131, regardez ici
    • slides 132-171, watch here / diapos 132-171, regardez ici
    • slides 172-end, watch here / diapos 172-fin, regardez ici
  • 🇬🇧 All material prepared in R / Matériel préparé avec R
    • R code available here / code R disponible ici
    • R Markdown used to write reproducible material (source code here) 🇫🇷 R Markdown utilisé pour écrire les diapos (code ici).
  • 🇬🇧 Material available via Github there 🇫🇷 Matériel disponible via Github

Credits / Crédits

How to use this repo? / Comment utiliser ce dossier?

  • 🇬🇧 Click on the Code green button at the top right of the page to create a copy of the repo within your own GitHub account (clone) 🇫🇷 Cliquez sur le bouton vert Code en haut à droite et créer une copie du doossier dans votre compte GitHub (clone)
  • 🇬🇧 Alternately, click on the same green button and choose Download ZIP to download the repo to your computer 🇫🇷 Sinon, cliquez sur le même bouton vert et choisissez Download ZIP pour télécharger le dossier compressé sur votre ordinateur

Requirements / Logiciels à installer

  • 🇬🇧 You need to have R or RStudio installed 🇫🇷 Il vous faut R ou RStudio
  • 🇬🇧 Download Jags from sourceforge and install it 🇫🇷 Téléchargez Jags depuis sourceforge et installez-le.
  • 🇬🇧 Install package R2jags from R or RStudio 🇫🇷 Installez le package R2jags depuis R ou RStudio

Problem / Problème

🇬🇧 If you spot a typo or an error, find a bug, or have trouble running the code, please file an issue or get back to me 🇫🇷 Si vous voyez une faute ou une erreur, ou un bug, n'hésitez pas à remplir un formulaire ou me contacter

Licence / License

🇬🇧 This work is licensed under a Creative Commons Attribution 4.0 International License 🇫🇷 Ce travail est sous license Creative Commons Attribution 4.0 International License

To-do list

  • Short term

    • Mention that besides Jags, Stan and Nimble, there are other software options to fit models in the Bayesian framework that do not need coding. Check out the CRAN Task View: Bayesian Inference.
    • Mention the availability of free Bayesian books: here and Gelman BDA there.
    • Add a plot with several lines from posterior distribution of regression parameters to a plot of mean response function of a covariate; then get the credible interval on the prediction.
    • R 4.0 no longer converts automatically chains of characters in factors when reading file; while it is a good thing, this causes a problem in the plant example on GLMM with older R versions; just need to add an extra step for converting the Sp column into a factor (Sp <- as.factor(Sp)).
    • Say more on prior predictive checks.
    • Say something about confidence, credible and HPD intervals.
    • Add another Metropolis example, with adaptation, with the beta-binomial example, and discuss several levels of acceptance.
    • Add a section on posterior predictive checks, to comply with the 3 steps of a Bayesian analysis as defined by Gelman (set up a probabilistic model, inference and model checking; iterate to improve model).
    • Do all plots with ggplot2; add short introduction to the Tidyverse.
    • Add a short section on sequential analysis (today prior is yesterday posterior).
    • Add an example with Poisson GLM(M) example.
    • In the GLMM section with the plant example, decide to go for number of seeds or log(number of seeds)
    • Explain the WAIC in more details
    • Properly introduce GLMs
  • Mid term

    • Add a section on LOO, and discuss complementarity with WAIC.
    • Add a section on models with varying slopes. Can we use the LKJ prior in Jags and Nimble ?
    • Write a short introduction to Nimble (resp. Stan) and provide both the Jags and Nimble (resp. Stan) codes. Translating Jags code in Nimble is easy. For now, check out training materials and examples.
    • Add a section on population ecology (occupancy models, capture-recapture models). And/or something on hierarchical models, models with hidden variables. Make use of nimbleEcology.
    • Add a section on penalized splines (possibly using package jagam) and spatial analyses.
  • Long term

    • Write a book (whaaaaat?!)