Introduction to GLMM and GAMM with R
This course is a hands-on introduction to generalised linear mixed effects models (GLMMs) and generalised additive mixed models (GAMMs) in R. The course begins with an introduction to linear mixed-effects models, including models with nested structures and random intercepts and slopes. Participants will work through several practical exercises to understand how mixed-effects models are fitted and interpreted. We then introduce GLMMs for analysing non-Gaussian data, including Poisson, negative binomial, and Bernoulli responses.
The next part of the course focuses on generalised additive models (GAMs), which provide a flexible way to model non-linear relationships. Through practical examples, participants will learn how to interpret smoothers, perform model selection, and understand interactions between smooth terms. Building on this, we extend the framework to generalised additive mixed models (GAMMs), combining the flexibility of GAMs with the hierarchical structure of mixed-effects models. Examples include hierarchical GAMs and GAMMs for count data.
In the final part of the course, participants will work with GLMMs and GAMMs for different types of response variables, including continuous data with and without zeros, counts, and proportional data. Distributions covered include Tweedie, Gamma, beta, binomial, Poisson, and negative binomial.
All examples are implemented in R, primarily using the mgcv and glmmTMB packages. The course emphasises practical modelling, interpretation of results, and model validation, rather than mathematical derivations.
Course content
Preparation material (in case you are not familiar with the required background knowledge; estimated time: 3 hours)
- Exercise on linear regression (with on-demand video).
- Exercise on Poisson and negative binomial GLMs (with on-demand video).
- Short explanation of DHARMa (with on-demand video).
Monday (linear mixed effects models)
- General introduction.
- Theory presentation on linear mixed-effects models.
- One exercise using one-way nested linear mixed-effects models.
- One exercise using two-way nested linear mixed-effects models.
- One exercise using random intercepts and slopes in a linear mixed-effects model.
Tuesday (GLMM)
- Catch-up session.
- One exercise on a Poisson GLMM.
- One exercise on a negative binomial GLMM.
- One exercise on a Bernoulli GLMM.
Wednesday (GAM)
- Theory presentation on GAMs.
- Two introductory GAM exercises.
- GAM exercise discussing model selection and smoother interactions.
Thursday (GAMM)
- One exercise on Gaussian additive mixed-effects models (GAMs with random effects).
- One exercise using hierarchical GAMs (the GAM equivalent of random-slope models).
- Two exercises on Poisson and negative binomial GAMMs.
Friday (GLMMs and GAMMs)
- One exercise using a Tweedie GLMM or GAMM for the analysis of continuous data (with zeros).
- One exercise using a Gamma GLMM or GAMM for the analysis of continuous data (without zeros).
- One exercise using a beta GLMM or GAMM for the analysis of proportional data.
- Time allowing: one exercise using a binomial GLMM or GAMM for the analysis of proportional data.
Prerequistes
Participants should have working knowledge of R, data exploration, linear regression, and generalised linear models(Poisson and negative binomial). Participants will receive access to the course website two weeks before the course starts. The website contains approximately 3 hours of preparatory material, including exercises, R scripts, and on-demand videos covering:
- Multiple linear regression
- Generalised linear models
- Model validation using DHARMa
Participants who are not familiar with these topics are encouraged to review the preparatory material before the course begins, as there will be limited time during the course to discuss these basic methods.
If you have questions while working through the preparatory material, you can use the course Discussion Board on the website to ask questions before the course starts.