Bayesian_Workshop
Bayesian_Workshop copied to clipboard
Material for a Bayesian statistics workshop
Bayesian statistics with R / Statistiques bayésiennes avec R
Olivier Gimenez, 2020
Learning objectives / Objectifs pédagogiques
- :uk: Try and demystify Bayesian statistics, and MCMC methods :fr: Essayer de démystifier les statistiques bayésiennes, et les méthodes MCMC
- :uk: Make the difference between Bayesian and Frequentist analyses :fr: Faire la différence entre analyses bayésiennes et fréquentistes
- :uk: Understand the Methods section of a paper that does Bayesian stuff :fr: Comprendre la section Méthodes d'un papier qui utilise le bayésien
- :uk: Run Bayesian analyses with
R(in Jags) :fr: Implémenter des analyses bayésiennes avecR
Schedule / Programme
:uk: Videos are in French, but you may enable subtitles (or closed captions) by clicking on the :gear: icon in Youtube (beware though, R is captioned as glass for some reasons :wine_glass:) :fr: Vidéos disponibles en français
- :uk: Bayesian inference: Motivation and simple example (video starts here) :fr: Inférence bayésienne : motivation et exemple simple (la vidéo commence ici)
- :uk: The likelihood (video starts here) :fr: La vraisemblance (la vidéo commence ici)
- :uk: A detour to explore priors (video starts here and goes on there) :fr: Un détour par les priors (la vidéo commence ici et continue là)
- :uk: Markov chains Monte Carlo methods (MCMC) (video starts here) :fr: Les méthodes de Monte Carlo par chaînes de Markov (MCMC) (la vidéo commence ici)
- :uk: Bayesian analyses in R with the Jags software (video starts here and goes on there) :fr: Analyses bayésiennes avec R et le logiciel Jags (la vidéo commence ici et continue là)
- :uk: Contrast scientific hypotheses with model selection (WAIC) (video starts here) :fr: Contraster des hypothèses scientifiques avec la sélection de modèles (WAIC) (la vidéo commence ici)
- :uk: Heterogeneity and multilevel models (aka mixed models) (video starts here and goes on there) :fr: 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
- :uk: Slides available here :fr: Diapos disponible ici
- :uk: Videos available in French via Youtube (you may enable subtitles or closed captions by clicking on the gear icon;
Ris captioned as glass for some reasons) :fr: Vidéos disponibles en français - :uk: All material prepared in
R/ Matériel préparé avecR - :uk: Material available via Github there :fr: Matériel disponible via Github là
Credits / Crédits
-
:uk: 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) :fr: 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).
-
:uk: 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 :fr: 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?
- :uk: Click on the
Codegreen button at the top right of the page to create a copy of the repo within your own GitHub account (clone) :fr: Cliquez sur le bouton vertCodeen haut à droite et créer une copie du doossier dans votre compte GitHub (clone) - :uk: Alternately, click on the same green button and choose
Download ZIPto download the repo to your computer :fr: Sinon, cliquez sur le même bouton vert et choisissezDownload ZIPpour télécharger le dossier compressé sur votre ordinateur
Requirements / Logiciels à installer
- :uk: You need to have
RorRStudioinstalled :fr: Il vous fautRouRStudio - :uk: Download
Jagsfrom sourceforge and install it :fr: TéléchargezJagsdepuis sourceforge et installez-le. - :uk: Install package
R2jagsfromRorRStudio:fr: Installez le packageR2jagsdepuisRouRStudio
Problem / Problème
:uk: 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 :fr: Si vous voyez une faute ou une erreur, ou un bug, n'hésitez pas à remplir un formulaire ou me contacter
Licence / License
:uk: This work is licensed under a Creative Commons Attribution 4.0 International License :fr: Ce travail est sous license Creative Commons Attribution 4.0 International License
To-do list
-
Short term
- Mention that besides
Jags,StanandNimble, 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
JagsandNimble? - Write a short introduction to
Nimble(resp.Stan) and provide both theJagsandNimble(resp.Stan) codes. TranslatingJagscode inNimbleis 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?!)