Unit 7 — From experimental designs to GLMs

Wednesday 21 October 2026, 12:30–16:00

Choose a GLM for a pen study and explain the fitted diet comparison

We will use the familiar pig-pen study to choose a generalised linear model (GLM), fit it in R, and explain its predictions for the two diets. A separate study will show how a diet difference can change with housing conditions.

No new preparation is required beyond the Week 6 follow-up. Bring your laptop, earlier notes if you have them, and any questions. The opening teaching reviews the experiment and explains what you need for the tasks.

Work in four groups of three. First we will describe what was measured and how diet was assigned. The instructor will explain the formula, family and link, fit a daily-gain example, and show how to read the output. You will then choose models for short study descriptions and analyse your group’s outcome.

Our teaching data contain 64 pens in four rooms, six pigs per pen, and 28 days of follow-up. Diet was assigned to whole pens. For Group 2, the outcome is whether any pig in a pen needed treatment, rather than a separate observation for each pig.

Open the instructor-provided Posit Cloud project for 07-glm-analysis and your assigned group-N-student.R script. All required files are already there.

Class teaching slides Workshop slides Class worksheet Explanation of terms and output

Breaks are 13:40–13:55 and 14:55–15:10. At 15:10–15:30, apply the same steps to a calf study and check another group’s answer. At 15:30–15:45, discuss your project question and which dataset you will use, using your week 42 notes. If your preferred data are unavailable, keep one of the provided studies available so you can continue.

Allow 60–75 minutes to revisit the examples, read selected material from Touchon’s second edition, and write a short explanation of your results.

The first video covers interpretation of the model coefficients:

While the second video focuses on the interaction model:

After-class slides After-class questions and reading

Keep your script, written comparison of the diets, and drawing of animals grouped within pens. We will use them when we introduce individual-animal observations on 28 October.

The instructor-provided 07-glm-analysis Posit Cloud project includes these files and everything needed to render them. To render a single file, open it in Posit Cloud and click Render. To render all six, run quarto render in the project’s Terminal.