09-01 · Check the model
Start here
Bring your Class 8 annotated output and checking list if available. Open the case pages below, or use the matching pages in the supplied 09-model-diagnostics Posit Cloud project. If you run R code, start from the project root.
Required packages: lme4, mgcv, mgcViz, performance, marginaleffects, DHARMa, see, ggplot2, readr, dplyr and tidyr. Each worksheet shows how to install its diagnostic packages if they are missing. The case pages include executed output and plots, so you can work through the questions even if fitting is slow.
Workshop slides Four study cases · Diagnostic report template and recap
If you work with classmates, take turns writing formulas, explaining output and checking the design.
Recall and essential teaching — 12:30–13:10
Compare Class 8 checking lists. Ask who received treatment and which measurements share conditions, whether fitting worked reliably, and whether the model describes the observations. A completed calculation can still give an unsuitable analysis.
A growth residual is observed minus fitted gain. Read its pattern against fitted gain, starting weight and pen. For count models, performance compares observed counts with simulated counts. Explain what each plot compares before describing a concern. Keep reassuring evidence too.
Four cases — 13:55–14:55
Start with whichever case you want to practise. Work through further cases as time permits. Each study uses invented data from four rooms and compares Control with High fibre.
| Case | What you’ll investigate |
|---|---|
| 1. Pen event counts | How does extra variation affect the count ratio and a proposed reduction? |
| 2. Animals sharing pens | What changes when animals in the same pen share a pen effect? |
| 3. Starting weight and growth | Does a straight line describe how gain changes with starting weight? |
| 4. Positive and negative welfare screens | What can you report when the logistic estimate is unreliable? |
Start with the design and starting model. Write the formula and explain the output before opening each solution. Record a concern and a reassuring feature, discuss possible causes, then compare your explanation with a classmate’s.
Use the five-step diagnostic report template to record evidence from a case you worked through. The pages are also references you can return to after class.
Change and check again — 15:10–15:45
After the 14:55–15:10 break, watch the ten-minute shared-pen example. At 15:20, continue with the follow-up analysis in your current case. Explain why it suits the study before revealing the solution. In the event-count case, assess both proposed reductions.
Compare fitting reliability, remaining patterns and the diet estimate with its uncertainty. In the welfare-screen case, consider what you can report directly from the observed screens.
Project check, report and exit — 15:45–16:00
At 15:45, confirm each group’s project question, primary outcome, usable data and documented design. Use the supplied case if essential information is missing.
At 15:50, share a one-minute summary of one case using the five report steps. Name the outcome, who received the diet, what the checks showed and what you can conclude.
For the 15:55 individual exit, imagine all Control welfare screens are positive and all High fibre screens negative. The logistic calculation finishes with almost no unexplained variation. What else must you inspect before trusting its diet estimate?
Complete after-class work and bring the report, animal trajectories and one question to Class 10.
Tool documentation
performance model plots, count-variation check, and marginaleffects comparisons explain the direct package calls.