Quiz: hierarchical models
Short questions to test your understanding of hierarchical (multilevel) models: replicates, pooling, shrinkage, and the random-effects formulation. Try each on paper first, then open the answer.
Q1. In one sentence, what is the difference between a biological replicate and a technical replicate?
One gives you a new independent unit; the other remeasures a unit you already had.
A biological replicate is an independent biological unit (a different patient, animal, or independently grown culture) and captures between-unit variation; a technical replicate is the same unit measured again (a split sample, a re-sequenced library) and captures only measurement noise.
Q2. A paper reports “n = 300 cells from 3 mice, p < 0.001” for a difference between two mouse strains. What is the relevant sample size for the between-strain claim, and what is this error called?
Which number limits your ability to generalise to new mice?
The relevant sample size is 3 (the mice), not 300. Treating the 300 cells as independent units is pseudoreplication; it overstates the effective sample size, so standard errors are too small and the p-value is too optimistic.
Q3. Name the three ways to handle grouped data and say, in a few words, what each assumes.
Two are extremes (between-group variance of 0 or infinity); one is the middle.
Complete pooling — one mean for everyone (assumes groups are identical, \(\tau^2 = 0\)). No pooling — a separate independent mean per group (assumes groups tell you nothing about each other, \(\tau^2 = \infty\)). Partial pooling — each group estimate is a compromise between its own mean and the grand mean (\(\tau^2\) estimated from the data); this is the hierarchical model.
Q4. In partial pooling, which groups shrink most toward the grand mean, and why?
Look at how the weight \(w = \dfrac{n/\sigma^2}{n/\sigma^2 + 1/\tau^2}\) depends on the number of measurements \(n\).
Groups with few (or noisy) measurements shrink most. A small \(n\) makes the worth of the group’s own data, \(n/\sigma^2\), small, so the weight \(w\) on its own mean is small and it leans on the grand mean. Data-rich groups have \(w\) near 1 and barely move.
Q5. A group has \(n = 3\) measurements with mean \(\bar y = 12\). The grand mean is \(\hat\mu = 6\), \(\sigma^2 = 6\), \(\tau^2 = 1\). Compute the partial-pooling estimate.
Compute \(n/\sigma^2\) and \(1/\tau^2\), form \(w\), then estimate \(= w\,\bar y + (1-w)\,\hat\mu\).
\(n/\sigma^2 = 3/6 = 0.5\); \(1/\tau^2 = 1\). So \(w = \dfrac{0.5}{0.5 + 1} = \dfrac{0.5}{1.5} = \tfrac13\). Then estimate \(= \tfrac13\cdot 12 + \tfrac23\cdot 6 = 4 + 4 = 8\). The estimate (8) sits between the group mean (12) and the grand mean (6), closer to 6 because the group carries relatively little information.
Q6. A random-effects model splits each measurement into an overall mean plus two levels of variation. Name the two levels, say which part is the fixed effect and which the random effect, and what the two variances \(\sigma^2\) and \(\tau^2\) measure.
One part is a single number for the whole dataset; one is a draw per group.
The two levels are the patient (group) level and the measurement level. The overall mean is the fixed effect (one number). Each group’s offset from it is the random effect, a draw from a shared distribution whose spread is the between-group variance \(\tau^2\) (biological). The noise of repeated measurements around a group’s own value has the within-group variance \(\sigma^2\) (technical).
In symbols (optional): \(y_{ij} = \mu + b_i + \varepsilon_{ij}\) with \(b_i \sim \mathcal N(0,\tau^2)\) and \(\varepsilon_{ij} \sim \mathcal N(0,\sigma^2)\).
Q7. The intraclass correlation is \(\text{ICC} = \tau^2/(\tau^2+\sigma^2)\). If \(\tau^2 = 9\) and \(\sigma^2 = 1\), compute it and say what it means for your effective sample size.
ICC near 1 means measurements within a group are almost redundant.
\(\text{ICC} = 9/(9+1) = 0.9\). Most variance is between groups and within-group measurements are highly correlated (redundant), so your effective sample size is close to the number of groups, not the total number of measurements. To gain power you need more groups, not more measurements per group.
Q8. What does the R formula y ~ treatment + (1 | patient) specify, and is it different in lme4 versus brms?
Left of the bar = what varies by group; right of the bar = the grouping factor.
It specifies a fixed effect of treatment (the population-level question) plus a random intercept (1 | patient) — one offset per patient, all drawn from a shared distribution with spread \(\tau\). The formula is identical in lme4::lmer (frequentist) and brms::brm (Bayesian, via Stan); brms additionally places priors on all parameters and returns a full posterior.
Q9. From the Bayesian viewpoint, what is a random effect?
The patient offsets are all drawn from one shared distribution — what role does that distribution play?
A random effect is a prior on the group-level parameters: the shared distribution of the group offsets is a prior on them, and because its width \(\tau\) is estimated from the data it is an adaptive (hierarchical) prior. Partial pooling is exactly the posterior compromise between each group’s data and this learned prior.