Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 4 d Solution Created 2026-10-03 Updated 2026-10-05
Add a location-specific random intercept to the random-slope linear mixed model:Take the location effects, incubator slopes and individual errors to be mutually independent, with the original variances and . The random intercept models variation already present at hatching because of the origin of the eggs. Because larvae are subsequently assigned to incubators, location and incubator are crossed random effects, not automatically nested groups. The corresponding code isThe resulting covariance between two observations contains if they share a location and if they share an incubator. If the three named locations themselves are the only populations of interest, use a fixed location factor instead:Choosing between these interpretations depends on the inferential target; with only three locations, a location variance component will be weakly estimated.
fly.model.loc <- lmer(size ~ hours + (0+hours|incubator) + (1|location))fly.model.loc.fixed <- lmer(size ~ hours + location + (0+hours|incubator))