05-02 · GLM consolidation and preparation for power
Sequence and workload
Complete this after the Week 5 class, before Week 6. Allow about 60 minutes: about 35 minutes working through the explanation plus 25 minutes of reflection and R work. Pause as needed.
The GLMs and modelling deck has three chapters. Work through the deck now, or use the recording when its link is added to the Unit 5 page:
- Model anatomy: conditional responses, score, mean and link.
- Four response mechanisms: effect scales, variation and assumptions.
- Analysis and repeated experiments: fitting, uncertainty and the power question.
You do not need to buy or consult a textbook. Use the deck, your class handout and your saved R script.
1. Model explanation, about 10 minutes
Answer briefly in your own words.
- A Poisson GLM assigns a pen an expected count of 1.95. Why is that valid? Can its observed count be 1.95?
- In Room 1, the control probability is 0.30 and the diet odds ratio is 0.60. Calculate the high-fibre probability using
plogis(qlogis(0.30) + log(0.60)). Is it 0.18? Explain. - A Gamma generator uses shape 25 and scale
mu / 25. What are its mean, variance and coefficient of variation? What changes if shape becomes 9 while the mean stays fixed? - Why does a GLM family describe the response conditional on predictors, rather than requiring the pooled histogram to have that shape?
- A model runs without a warning and reports convergence. What further reasons might make its estimates unreliable?
2. Reproducible R work, about 10 minutes
Open your completed group script in a fresh R session. Run it from the top and verify the design checks.
Run generate_response() twice with the same response seed. Confirm that the resulting response vectors match. Then use one new seed and compare design, mean and response columns.
Choose a single sensitivity change for your group:
| Group | Change | Predict before running |
|---|---|---|
| 1 | Change SD from 60 to 90 | Mean unchanged, more conditional variation |
| 2 | Change Room 1 control probability from 0.30 to 0.15 by setting beta_0 <- qlogis(0.15) |
Same odds ratio, different absolute probability difference |
| 3 | Change Room 1 control expected count from 3 to 1.5 by setting beta_0 <- log(1.5) |
Same count ratio, lower expected counts and Poisson variance |
| 4 | Change shape from 25 to 9 and scale from mu/25 to mu/9 |
Mean unchanged, more relative variation |
Save a copy of the script before editing. Keep the treatment effect and room effects fixed. Use the same response seed for the comparison to make the change reproducible, but remember that one comparison does not establish a power change.
Annotate what you changed, your prediction and what you observed. Restore or retain a clearly labelled copy of the original scenario.
3. Week 6 simulation plan, about five minutes
Bring a short plan stating:
- response, family, link and biologically meaningful effect
- which uncertainty you will vary
- planned analysis, including blocks
- a candidate rule for calling the effect detected
- what you would repeat and what you would hold fixed
Consider this sample-size grid: four rooms with 4, 8, 12 or 16 pens per room. Calculate the total pens and pens per diet. Explain why counting additional pigs inside the existing pens does not create additional independently randomised pens.
We will choose and assess the detection rule together in Week 6. You do not need to program the power loop beforehand.
Submission and readiness
Submit your five short answers, annotated R script or excerpt, and Week 6 plan. Bring one unresolved question.
You are ready for Week 6 if you can reproduce a valid dataset, explain its response support, identify the treatment parameter, fit or diagnose the supplied analysis, and describe what repeated simulated experiments would estimate.