Class 9: report and prepare for repeated measurements
Gavin Simpson
Aarhus University
Wednesday, 4 November 2026
After class: 60–75 minutes
25 minutes: the recording or these slides.
25–35 minutes: targeted Touchon reading.
10–15 minutes: finish your report and draw animal trajectories.
Bring your report, sketch and one question to Class 10.
Five steps in the diagnostic report
Study and starting model. Say how researchers assigned the diets and what they measured.
Evidence and possible causes. Identify a concern, a reassuring feature and two possible explanations.
Action and reason. Explain the change you chose.
Recheck. Compare the new output with the original.
Biological conclusion and limitation. Say what the evidence supports and what remains uncertain.
Pen counts in four rooms
Researchers assigned diets to pens, then counted treatment events once per pen over the same follow-up time. In the model, diet compares the diets and room allows the four rooms to differ.
# A tibble: 2 × 4
room pen diet events
<fct> <chr> <fct> <dbl>
1 R1 R1-P01 Control 1
2 R1 R1-P02 Control 1
Two models for the same pen counts
Both models estimate the expected count for each diet and room. The Poisson model sets the count variance equal to the expected count. The negative-binomial model lets counts vary more around that expectation.
R averages the room predictions for each diet, then takes the log of the High fibre mean divided by the Control mean. transform = "exp" returns the estimate and interval to the ratio scale.
Both estimates suggest fewer events under High fibre. The Poisson interval lies below 1, while the wider interval here includes 1. Under the model that allows extra variation, the evidence also allows equal expected counts.
Does the negative-binomial model allow enough variation?
# Overdispersion test (using simulated residuals)
dispersion ratio = 0.868
p-value = 0.78
iterations = 500 asks for 500 simulated datasets. set.seed() makes that check repeatable. The ratio is close to 1, which gives little evidence of extra variation beyond what this model allows. Reopen the pen-count case to compare the residual plots.
Welfare screens show complete separation
The welfare-screen case has animals housed separately, one screen per animal. Read the observed table before trusting the logistic output.
# A tibble: 2 × 3
diet positive negative
<chr> <int> <int>
1 Control 12 0
2 High fibre 0 12
All 12 Control animals screened positive. All 12 High fibre animals screened negative. Diet perfectly predicts the observed screens, a pattern called complete separation. An ordinary logistic fit can report convergence even though it has no finite room-adjusted diet estimate. Report the observed rates and their intervals.
Repeated gain measurements in two pens
Researchers assigned one diet to each pen. They recorded each animal’s gain in grams per day (gain_g_day) at weeks 0–3. The data contain six animals and four measurements per animal.
Sketch these three trajectories at weeks 0–3. Label the axes with week and gain (g/day), then mark each animal’s pen and diet.
Animal trajectories by pen and diet
Each point is an observed gain. Each line connects measurements from the same animal. The panel headings give the pen and its diet. With one pen per diet, differences between pens could reflect diet or other conditions shared within each pen.
Follow the five steps in the diagnostic report handout and bring your report and sketch to Class 10. Which points come from the same animal? Which animals share a pen? Write one question about whether the diet difference changes over time, and suggest why nearby measurements from one animal might be alike.
In Touchon’s second edition, revisit model checking in Chapter 7 or 8. For the starting-weight case, revisit mean relationships in Chapter 6. Then read the introduction to repeated measurements in Chapter 9.