Aarhus University Seal

Generalized additive modelling with R

ECTS credits: 1.5 ECTS

Course parameters:

Language: English

Level of course: PhD Course

Time of year: Autumn 2024 (10 – 12 December 2024)

Capacity limits: 30

Course fee: DKK 350

Objectives of the course:

The course will provide an applied introduction to generalized additive modelling in R for biologists. Most of the statistical methods you are likely to have encountered will have specified fixed functional forms for the relationships between covariates and the response, either implicitly or explicitly. These might be linear effects or involve polynomials, such as x + x2 + x3. Generalized additive models (GAMs) are different; they build upon the generalized linear model by allowing the shapes of the relationships between response and covariates to be learned from the data using splines. Modern GAMs are a general data analysis framework, encompassing many models as special cases, including GLMs and GLMMs, and the variety of splines available to users allows GAMs to be used in surprisingly large situations. In this course we’ll show you how to leverage the power and flexibility of splines to go beyond parametric modelling techniques like GLMs.

Learning outcomes and competences:
At the end of the course, the student should be able to:

  • Understand how GAMs work from a practical viewpoint to learn relationships between covariates and response from the data
  • Be able to fit GAMs in R using the mgcv package
  • Know the differences between the types of splines and when to use them in your models
  • Know how to visualise fitted GAMs and to check the assumptions of the model
  • know how to test specific hypotheses and estimate quantities of interest using fitted models,
  • be able to use the R statistical software and in particular the mgcv, gratia, and marginaleffects packages to fit and analyse generalized additive models.

Compulsory programme:

Active participation in the course including attendance at lectures and completion of computer-based classes and exercises. Completion of short, computer-based assessments testing their understanding of a topic and the practical skills taught. For credit, students must complete a data analysis exercise to be submitted one week after the end of the course (19 December).

Course contents:

The course is based on a series of lectures and computer-based practical classes led by an international expert in generalized additive modelling and who is the author of gratia, an R package for working with GAMs fitted using the mgcv package.

The course covers the following topics:

  • A recap of generalized linear models for data that are not Gaussian
  • Fitting GAMs using mgcv
  • Working with penalized splines to estimate flexible effects of covariates
  • Model diagnostics and assessment
  • Estimating marginal effects and adjusted predictions with GAMs
  • Hypothesis testing using GAMs
  • Displaying model estimates and reporting results


This course is suitable for Phd students (including senior thesis-based MSc students) and researchers working with biological data who want to fit models that allow for nonlinear relationships (effects) of covariates on responses. The course will be of particular interest to PhD candidates and researchers in inter alia biology, animal science, ecology, agriculture, and environmental science. Some prior knowledge of R is required, and some prior knowledge of generalized linear modelling in R would be an advantage.

Name of lecturer:

Assistant Professor Gavin Simpson, Department of Animal and Veterinary Sciences, Aarhus University gavin@anivet.au.dk


Open access teaching resources prepared by the course leader will be supplemented by original literature (papers). Electronic copies of the open access teaching resources will be provided to each participant before the course starts.

Course homepage:


Course assessment:

The course will be assessed through a data analysis exercise (take home) to be submitted by 19 December 2024.


The course is provided by the Department of Animal and Veterinary Sciences, Aarhus University


3 days of teaching in a single block (10 – 12 December 2024). Classes are held from 09.30 to 16.00 each day.


The course will be taught at AU Campus Viborg

Course fee:

DKK 350


Please send an e-mail to Julie Jensen, e-mail jsj@anivet.au.dk no later than 6 December 2024 to register.

If you have any questions, please contact course leader Assistant Professor Gavin Simpson, Department of Animal and Veterinary Sciences, Aarhus University, e-mail: gavin@anivet.au.dk

28257 / i43