Online self-study course 4: Introduction to Generalised Additive Models in R
Introduction to Generalised Additive Models in R
GAMs, GAMMs, spatial and spatio-temporal modelling
Course format:
- Self-study course.
- On-demand access to all video content online within a 12-month period.
- Daily interaction on the Discussion Board for detailed questions.
- Live chat for quick queries.
- Course fee includes a 1-hour video chat with instructors for personalized questions and data assistance.
This online course provides a practical introduction to generalised additive models (GAMs) and generalised additive mixed-effects models (GAMMs) using the mgcv package in R. It begins with the fundamental ideas behind smoothers and gradually progresses to hierarchical, spatial and spatio-temporal models.
The course consists of seven self-paced modules (representing about 60 hours of work). Short theory presentations are combined with extensive hands-on exercises based on real ecological, environmental, biological, aquaculture and fisheries datasets. Participants receive annotated R solution code, downloadable datasets and on-demand videos explaining the statistical analyses, modelling decisions and interpretation of the results. All videos can be watched online at any time and as often as required during the 12-month access period.
Participants also receive:
- access to an online discussion board for questions and interaction with the instructors and other participants;
- downloadable course material, datasets and annotated R scripts; and
- a one-hour individual online consultation with one or both instructors to discuss their own data or statistical questions.
The consultation must be used within 12 months of receiving access to the course website. It is provided as a single session at a mutually convenient time.
What will you learn?
Participants will learn how to:
- understand the basic principles of smoothers and GAMs;
- fit, interpret and visualise GAMs and GAMMs;
- model non-linear relationships between a response variable and explanatory variables;
- select suitable basis dimensions and assess smoother complexity;
- include random effects and hierarchical dependency structures;
- model interactions involving smoothers;
- analyse continuous, count, proportional and binary response variables;
- carry out model selection and model validation;
- use DHARMa and other diagnostic tools to identify model problems;
- detect and model residual spatial dependency;
- fit and interpret spatial and spatio-temporal GAMs; and
- use specialised spatial smoothers for irregular study areas and geographical barriers.
The course is strongly applied and focuses on developing practical modelling skills rather than mathematical derivations.
Course content
Module 1 — Introduction to GAMs
The first module provides a short revision of data exploration and multiple linear regression before introducing the main ideas behind generalised additive models. Singing-whale data are used to demonstrate how smoothers can represent non-linear relationships and how a GAM can be extended from one covariate to multiple covariates. Topics include:
- revision of data exploration and multiple linear regression;
- introduction to smoothers and GAMs;
- fitting a GAM with one smoother;
- fitting GAMs with multiple explanatory variables; and
- interpreting and visualising estimated smoothers.
Module 2 — Gaussian GAMs and GAMMs
This module examines GAMs for continuous response variables and introduces generalised additive mixed-effects models. A short revision of linear mixed-effects models is followed by applications involving grouped and repeated observations. Topics include:
- Gaussian GAMs;
- revision of linear mixed-effects models;
- random effects and dependency between observations;
- Gaussian GAMMs; and
- combining smooth effects and random effects.
Module 3 — GAMs for count data
This module introduces GAMs for count data. Queen conch data are used to compare Poisson and negative binomial models and to demonstrate how non-linear covariate effects can be incorporated. Topics include:
- Poisson GLMs and GAMs;
- overdispersion;
- negative binomial GLMs and GAMs;
- choosing between Poisson and negative binomial distributions; and
- model validation for count data.
Module 4 — GAMMs for count, binary and proportional data
This module extends GAMMs to more complex response variables and hierarchical datasets. Applications include spider species richness, minke-whale diving behaviour, cowbird occurrence and temporal trends in illegal elephant killing. Topics include:
- Poisson and negative binomial GAMMs;
- Bernoulli GAMMs;
- binomial models for proportional count data;
- smooth temporal trends;
- random effects; and
- nested hierarchical structures.
Module 5 — Beta, Gamma and Tweedie GAMMs
This module introduces additional distributions for continuous and semi-continuous response variables. Applications include grassland plant evenness, barn-owl behaviour and fisheries catch-per-unit-effort. Topics include:
- beta GAMs for proportional data;
- Gamma GAMMs for positive continuous data;
- Tweedie GAMMs for data containing zeros and positive continuous values;
- nested and crossed random effects; and
- conditional, marginal and population-level fitted values.
Module 6 — Spatial GAMs
This module introduces the analysis of spatial data using GAMs. The exercises cover Gaussian, count, binary and proportional spatial data from river, plant, fisheries and coral-reef studies. Topics include:
- detecting residual spatial dependency;
- two-dimensional and tensor-product smoothers;
- spatial Gaussian, negative binomial, Bernoulli and beta GAMs;
- adaptive and Gaussian process smoothers;
- model comparison and spatial prediction;
- spatial diagnostics and variograms;
- working with spatial data using the sf package; and
- soap-film smoothers for irregular study areas containing barriers.
Module 7 — Spatio-temporal GAMs
The final module extends spatial GAMs to data collected repeatedly through time. Applications include sea-turtle biomass, Canadian owl counts, eulachon fisheries data and coral disease. Topics include:
- combining spatial structure with temporal trends;
- spatio-temporal smoothers and interactions;
- Gamma spatio-temporal GAMs;
- Poisson and negative binomial spatio-temporal GAMs;
- Tweedie spatio-temporal GAMs;
- Bernoulli spatio-temporal GAMs; and
- an additional (bonus) exercise involving GAMs for areal data (without video).
Statistical distributions covered
Throughout the course, GAMs and GAMMs are applied using:
- Gaussian distributions;
- Poisson distributions;
- negative binomial distributions;
- Bernoulli and binomial distributions;
- beta distributions;
- Gamma distributions; and
- Tweedie distributions.
Background knowledge
Participants should have a working knowledge of R and a basic understanding of regression and generalised linear models. The course includes short revisions of multiple linear regression and linear mixed-effects models, but it does not provide a complete introduction to every statistical distribution used in the later modules.
Participants who are unfamiliar with GLMs and distributions such as the binomial, negative binomial, beta, Gamma or Tweedie are advised to complete our introductory course, "Data Exploration, Regression, GLM and GAM", first.