Gaussian linear mixed model Created 2026-10-06 Updated 2026-10-14
A Gaussian linear mixed model combines fixed effects, random effects with a normal distribution, and independent Gaussian noise. For and independently, its marginal distribution is with . The random effects induce dependence among observations sharing their design columns. A random-intercept linear mixed model and a random-slope linear mixed model are special cases.
Past exam of the mathematics course of the University of Cambridge 2016 iii Paper 206 1 e Solution Created 2026-10-03 Updated 2026-10-06
The fitted formula and coefficient table describe a random-slope linear mixed model:with random effects independent of the errors. There is a common fixed intercept, a population slope , and a laboratory random slope deviation . In
tumour1, the three laboratory slopes are unrelated unknown fixed coefficients. Here they are modelled as draws from a common normal distribution; estimated laboratory deviations are shrunk toward zero. After integrating out , observations in laboratory have covariance , so they are marginally dependent even when their conditional errors are independent.The displayed command contains a source inconsistency:
size ~ 1 + (0 + days | lab) would impose zero population slope and could not produce the displayed fixed days coefficient. The output corresponds to size ~ days + (0 + days | lab). Its estimates are , and . The estimated daily increase averaged over the laboratory population isbecause .A random slope is appropriate if these laboratories can reasonably be viewed as exchangeable representatives of a larger population and the goal includes population inference or predictions for other laboratories. If these particular three laboratories are the whole set of interest, or have systematic differences incompatible with exchangeability, laboratory-specific fixed slopes are preferable. Only three groups give weak information about between-laboratory variance; the mixed model does not itself resolve possible nonlinear growth. Its population mean is distinct from a realized finite-group average .
Past exam of the mathematics course of the University of Cambridge 2016 iii Paper 206 1 f Solution 2026-10-06
Retain the random-slope linear mixed model of part (e), but replace the within-laboratory independent error covariance by continuous-time autoregressive residual correlation:Errors from different laboratories remain independent and are independent of the random slopes. The resulting marginal covariance within laboratory isThe exponential decay applies to the conditional errors, not the entire marginal correlation, which also contains the shared random slope.
Use Here
nlme, since lme4::lmer does not fit this general residual correlation structure. With a data frame containing the observed variables, suitable code islibrary(nlme)
dat <- data.frame(size = size, days = days, lab = lab)
dat <- dat[order(dat$lab, dat$days), ]
tumour_cor <- lme(size ~ days,
random = ~ 0 + days | lab,
correlation = corCAR1(form = ~ days | lab),
data = dat, method = "REML")corCAR1 estimates , the error correlation one day apart; correlation at separation is . This works for noninteger or unequally spaced days. At equally spaced integer days, corAR1(form = ~ days | lab) gives the corresponding discrete-time construction when its parameter is positive. Distinct times within each error series are required: separate tumours with repeated day values should have separate series identifiers or an additional independent-error component, rather than being assigned perfectly correlated errors. The continuous-time autoregressive residual correlation documentation describes the grouping and continuous-time conventions: stat.ethz.ch/R-manual/R-patched/library/nlme/html/corCAR1.html. The fixed days term here follows the fitted output rather than the inconsistent command in part (e). Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 4 a Solution Created 2026-10-03 Updated 2026-10-05
The random-slope linear mixed model iswith independence between the random effects and errors. The estimates areIncubators are treated as exchangeable representatives of possible growth environments, so a random slope permits their growth rates to differ while estimating a population mean growth rate. The formula
0+hours deliberately removes a random intercept: larvae are assigned only after hatching, so it is reasonable to assume no incubator-specific baseline at time zero. Random assignment supports this common-baseline assumption in expectation; it does not prove that observed initial sizes or other baseline differences are exactly identical.For a new incubator, no observations are available to estimate its realized random slope, and its mean effect is zero. Under squared-error loss the best prediction integrates over that effect and the residual error:This is the plug-in conditional expectation given the population parameters, rather than a prediction using a fitted effect from one of the four existing incubators. Ignoring parameter-estimation uncertainty, the prediction variance for a new individual is ; it is not just the uncertainty in the population mean.
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))