Concept map / HLM
Share
Partial pooling in multilevel models
Compare school means estimated separately, estimated together, and estimated with partial pooling.
1Nine schools, three ways to estimate their means
Nine schools take the same test. School A tested 3 students; Schools H and I tested 40 each. A mean of three scores swings a lot by chance, so small schools tend to land at the top or the bottom of a ranking.
You can keep each school’s own mean (no pooling), give every school the overall mean (complete pooling), or take a weighted average of the two (partial pooling), the same compromise a posterior mean strikes between data and prior. Change τ, the spread between schools, and σ, the spread of students within a school, and watch which estimates shift most.
School A has 3 students and a raw mean of 65.6. Its weight is 0.43, so partial pooling keeps 43% of the gap between 65.6 and the overall mean of 49.4. It reports 56.3, a move of 9.3 points.
More controls
The sliders stretch the same students. New schools draws a fresh set.
2Four students or forty: which school comes out ahead?
Two schools score above the overall mean of 50. The small school tested 4 students and has a raw mean of 62. The large school tested 40 and has 58. Take τ = 5 and σ = 10, as in the lab. On raw means the small school ranks first. Which school has the higher estimate after partial pooling?
3The weight is the reliability of a school mean
A school's weight λ compares two variances. One is τ², how much the schools truly differ. The other is σ² / n, how noisy a mean of n students is. Few students make the noise term big and the weight small. Read this way, λ is the reliability of the school mean: the share of the spread in raw means, for schools of that size, that reflects real differences.
School A: 25.00 / (25.00 + 100.00 / 3) = 25.00 / 58.33 = 0.43
School A: 0.43 × 65.6 + 0.57 × 49.4 = 56.3. Point at a symbol to light up its part of the chart in section 1.
All nine weights, and the intraclass correlation
Drop the n and the same two variances give the intraclass correlation: τ² / (τ² + σ²) = 25.00 / 125.00 = 0.20. So 20% of the score variance lies between schools. It is the weight a school would get from one student, and the correlation between two students from the same school.
The lab treats τ and σ as known and takes them from the sliders. A real analysis estimates them. From these students, a simple method of moments gives τ ≈ 3.0 and σ ≈ 9.9. The overall mean is an average of the school means, each weighted by how precisely it is known.
A common misreading is that pooling punishes small schools. It pulls them toward the middle from either side, so a three-student school with a low raw mean is pulled up as far as one with an equally high mean is pulled down.
4Regression lines are pulled too
Schools can differ in slope as well as level. Give each student a number of study hours and fit one line per school, as on the regression page. A random-slopes model then pulls each school's line toward the average line, and lines fitted to a handful of students move most.
Show the regression lines
Fitted to its own 3 students, School A's line rises 2.03 points per hour of study. The average line rises 1.54. Partial pooling gives it 1.54, which cuts its distance from the average slope from 0.49 to 0.00.
Line heights and student scores still use τ = 5.0 and σ = 10.0 from section 1. With a height and a slope per school the weight becomes a 2 × 2 matrix, so the two are pulled together. The rule has not changed: few students or noisy scores mean a strong pull.
5Check yourself
The tasks use the controls in section 1 and tick themselves when you meet them.
- Select School A (3 students) and move the sliders until its weight reaches 0.75. Three students are then mostly believed.Now: School A (3 students) has weight 0.43; τ = 5.0, σ = 10.0
- Select School H or I (40 students each) and, with τ above zero, push its weight below 0.50. Now even 40 students count for less than the overall mean.Now: School A (3 students) has weight 0.43; τ = 5.0, σ = 10.0
- With partial pooling on, find a setting where the estimates put two schools in a different order from their raw means. New schools, under More controls, draws a fresh set to try.Now: The order of the schools is the same before and after shrinkage
6Fit the same model with lme4
The snippet simulates nine schools with the page’s sizes, τ = 5 and σ = 10, and fits them with lmer(). The printed weights match section 3, from 0.43 for School A to 0.91 for H and I. Nine schools give little to estimate a spread from, so the fitted τ and σ can land some way from 5 and 10.
Fit a random-intercept model with lme4Show the code
library(lme4)
# Nine schools with the page's sample sizes
set.seed(30)
n <- c(3, 4, 6, 8, 12, 18, 25, 40, 40)
school <- factor(rep(LETTERS[1:9], n))
# Overall mean 50, tau = 5 between schools, sigma = 10 within
effect <- rnorm(9, 0, 5)
score <- 50 + effect[school] + rnorm(sum(n), 0, 10)
# Random-intercept model: estimated tau and sigma
fit <- lmer(score ~ 1 + (1 | school))
print(VarCorr(fit), comp = "Std.Dev.", digits = 2)
# The weight on each school's own mean at tau = 5, sigma = 10
round(setNames(5^2 / (5^2 + 10^2 / n), LETTERS[1:9]), 2)
# Intraclass correlation at the same values
5^2 / (5^2 + 10^2)
# Raw school means beside the partial-pooling estimates
raw <- tapply(score, school, mean)
round(cbind(n, raw, pooled = coef(fit)$school[, 1]), 1)Uses lme4. Install once with install.packages(c("lme4")).
What partial pooling does
- Each partial-pooling estimate is a weighted average of the school’s own mean and the overall mean.
- The weight is τ² / (τ² + σ² / n), the reliability of the school mean. At τ = 5 and σ = 10, School A’s 3 students earn a weight of 0.43 and the 40 students at H or I earn 0.91.
- Schools with different weights move different distances, so pooling can reorder a ranking. In the prediction, a 4-student school at 62 ends at 56.0, below a 40-student school at 58 that ends at 57.3.
- Drop the n and the same variances give the intraclass correlation, τ² / (τ² + σ²): the share of score variance that lies between schools. It is 0.20 at the default settings.
- The same pull works on regression slopes, and on people. The ability estimation page pulls a person’s score toward the population in the same way, with item responses in place of student scores.
Recommended reading
- Data Analysis Using Regression and Multilevel/Hierarchical ModelsAndrew Gelman and Jennifer HillChapter 12, multilevel linear models and partial pooling