Bayesian statistics with R / Statistiques bayésiennes avec R
Olivier Gimenez, 2020
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 withR
(in Jags)🇫🇷 Implémenter des analyses bayésiennes avecR
Schedule / Programme
R
is captioned as glass for some reasons
🇬🇧 Bayesian inference: Motivation and simple example (video starts here)🇫🇷 Inférence bayésienne : motivation et exemple simple (la vidéo commence ici)🇬🇧 The likelihood (video starts here)🇫🇷 La vraisemblance (la vidéo commence ici)🇬🇧 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 là)🇬🇧 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)🇬🇧 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 là)🇬🇧 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)🇬🇧 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 là)
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🇬🇧 All material prepared inR
/ Matériel préparé avecR
🇬🇧 Material available via Github there🇫🇷 Matériel disponible via Github là
Credits / Crédits
-
🇬🇧 Many slides are from a workshop we used to run a loooong time ago with Ruth King, Byron Morgan and Steve Brooks. I also re-used or adapted slides by Richard McElreath (16-20, 90-91, 166, 186), Kerrie Mengersen (16-20, 81), Francisco Rodriguez Sanchez (79-80; from the Stan manual), Jim Albert and Jingchen Hu (93-99), Tristan Marh (22), Jason Matthiopoulos (31-39, 196), a paper by Michael McCarthy and Pip Masters (71-73), Andrés Lopez-Sepulcre (126) and John Kruschke' book cover (61)🇫🇷 Plusieurs diapos sont tirées d'un workshop que nous organisions il y a bien longtemps avec Ruth King, Byron Morgan et Steve Brooks. J'ai aussi utilisé et adapté des diapos de Richard McElreath (16-20, 90-91, 166, 186), Kerrie Mengersen (16-20, 81), Francisco Rodriguez Sanchez (79-80; from the Stan manual), Jim Albert and Jingchen Hu (93-99), Tristan Marh (22), Jason Matthiopoulos (31-39, 196), un papier de Michael McCarthy et Pip Masters (71-73), Andrés Lopez-Sepulcre (126) et la couverture du livre de John Kruschke (61). -
🇬🇧 The sources for the images are: James Kulich for slide 13, Matt Buck for slide 21, xkcd for slide 29 and Mike West for slide 194🇫🇷 Les sources des images sont : James Kulich pour la diapo 13, Matt Buck pour la diapo 21, xkcd pour la diapo 29 et Mike West pour la diapo 194
How to use this repo? / Comment utiliser ce dossier?
🇬🇧 Click on theCode
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 vertCode
en haut à droite et créer une copie du doossier dans votre compte GitHub (clone)🇬🇧 Alternately, click on the same green button and chooseDownload ZIP
to download the repo to your computer🇫🇷 Sinon, cliquez sur le même bouton vert et choisissezDownload ZIP
pour télécharger le dossier compressé sur votre ordinateur
Requirements / Logiciels à installer
🇬🇧 You need to haveR
orRStudio
installed🇫🇷 Il vous fautR
ouRStudio
🇬🇧 DownloadJags
from sourceforge and install it🇫🇷 TéléchargezJags
depuis sourceforge et installez-le.🇬🇧 Install packageR2jags
fromR
orRStudio
🇫🇷 Installez le packageR2jags
depuisR
ouRStudio
Problem / Problème
Licence / License
To-do list
-
Short term
- Mention that besides
Jags
,Stan
andNimble
, 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 theTidyverse
. 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
- Mention that besides
-
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
andNimble
? - Write a short introduction to
Nimble
(resp.Stan
) and provide both theJags
andNimble
(resp.Stan
) codes. TranslatingJags
code inNimble
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?!)