Section 11.21

Cluster bootstrap

Definition

The cluster bootstrap is a method for estimating the uncertainty of a statistic, a number computed from data such as a mean, when the data come in clusters: groups whose members may depend on each other, while different groups are independent. Like the ordinary bootstrap §11.19, it builds many artificial data sets by random drawing from the observed data and recomputes the statistic on each. Unlike the ordinary bootstrap, it draws whole clusters, such as sessions or devices, not single measurements. The spread of the recomputed values estimates the uncertainty.

The idea

An experiment records the response times §9.32 of 300 events, 100 in each of three sessions. In one session a queue stayed congested the whole time, so all 100 of its events are slow for one shared reason. If the experiment were repeated, three new sessions would occur, and by chance none, one, two or all three of them could be congested. The uncertainty of the overall mean therefore comes mainly from which sessions happened to occur, and only three sessions occurred.

The ordinary bootstrap draws 300 single events at random from the 300 observed. Every artificial data set then holds about 100 events from each session, so the congested session always supplies about a third of the events and the recomputed means barely vary. The ordinary bootstrap acts as if each event had met congestion by its own independent chance, and so reports too small an uncertainty. The cluster bootstrap copies the way the data were produced: it draws three sessions, and each drawn session brings all of its events along. Some artificial data sets contain the congested session twice and some not at all, which is the variation a repeated experiment would show.

A picture: each session is one card with its 100 events written on it. The ordinary bootstrap cuts the cards into 300 strips and draws strips; the cluster bootstrap draws whole cards. The picture stops at one point. Drawing from three cards can never produce a session unlike all three, so with few clusters the method sees only a small part of the variation that exists between sessions.

How it works

The method needs data in which every row carries the identifier of its cluster, a declared statistic, and a number of repetitions BB, typically a few thousand. Let kk be the number of clusters observed.

  1. Choose the cluster level. A cluster is the largest unit that was sampled or assigned independently of the others: a session, a device, one start-up of a device. Measurements inside one cluster may depend on each other in any way.

  2. Draw cluster identifiers. Draw kk identifiers from the kk observed ones, each draw equally likely to pick any cluster and made with replacement, meaning that a drawn cluster is put back and can be drawn again.

  3. Build the artificial data set, called a resample. Every drawn identifier contributes all rows of its cluster, unchanged. A cluster drawn twice appears twice, so when clusters differ in size, the number of rows varies from resample to resample.

  4. Recompute the statistic on the resample, by exactly the same rule as on the original data.

  5. Repeat steps 2 to 4 BB times.

  6. Read off the uncertainty. The standard deviation §11.14 of the BB recomputed values, their typical distance from their own mean, estimates the standard error §11.15 of the statistic: how far the statistic typically falls from the quantity it estimates. The 2.5th and 97.5th percentiles §11.16 of the BB values form a 95% percentile bootstrap §11.20 interval.

Two choices must be fixed before resampling. First, the weighting of clusters of different sizes. The mean of all events weights each cluster by its number of events; the mean of the cluster means weights every cluster equally. When sizes differ, these are different estimands §11.2 (different quantities to be estimated), and the resampling must recompute the declared one. Second, the structure of the design. If every device was measured under both conditions, as in a paired design §11.7, draw devices and keep both conditions of a drawn device together. If each cluster received only one condition, draw clusters separately within each condition, so that every resample keeps the original number of clusters per condition.

When clusters are nested, such as several sessions on each of several devices, draw at the highest level that is independent, here devices, and keep everything inside a drawn device. The differences between the devices’ data already contain the variation of the sessions and events inside them, so the lower levels need not be drawn again. For a mean, drawing rows inside each drawn cluster as well counts the variation within clusters a second time and makes the estimated uncertainty too large.

Worked example

Three sessions were recorded, each with 100 events. Their mean response times are 1, 2 and 10 milliseconds (ms). Within each session the events spread around the session mean with a standard deviation of 1 ms. The statistic is the mean over all 300 events. Because every session has 100 events, that mean equals the mean of the three session means: (1+2+10)/3=13/3≈4.333(1 + 2 + 10)/3 = 13/3 \approx 4.333 ms.

Cluster bootstrap. Draw three session identifiers with replacement. The draw 1, 1, 3 copies session 1 twice and session 3 once; the resample has 300 events and mean (1+1+10)/3=4(1 + 1 + 10)/3 = 4 ms. The draw 3, 3, 3 gives (10+10+10)/3=10(10 + 10 + 10)/3 = 10 ms. The draw 1, 2, 3 reproduces 4.333 ms. To find the spread of all such results, note that the resample mean is the average of three independent draws from the session means 1, 2 and 10. Their distances from 4.333 are −10/3-10/3, −7/3-7/3 and 17/317/3, whose squares 100/9100/9, 49/949/9 and 289/9289/9 average to (438/9)/3=146/9≈16.22 ms2(438/9)/3 = 146/9 \approx 16.22 \text{ ms}^2. This average squared distance from the mean is the variance of one draw. The average of three independent draws has one third of that variance, 146/27≈5.41 ms2146/27 \approx 5.41 \text{ ms}^2, so the cluster bootstrap standard error is 5.41≈2.33\sqrt{5.41} \approx 2.33 ms.

Ordinary bootstrap. Draw 300 single events from the 300. With equal session sizes, the variance of all 300 events around 4.333 ms is the variance of the session means plus the variance within sessions: 146/9+12=155/9≈17.22 ms2146/9 + 1^2 = 155/9 \approx 17.22 \text{ ms}^2. The mean of 300 independent draws has variance 17.22/300≈0.0574 ms217.22/300 \approx 0.0574 \text{ ms}^2, so the ordinary bootstrap standard error is 0.0574≈0.24\sqrt{0.0574} \approx 0.24 ms, about 2.33/0.24≈9.72.33/0.24 \approx 9.7 times smaller than the cluster bootstrap value.

For a claim about sessions in general, 2.33 ms is the value that matches how the data were produced, because a repeated experiment draws new sessions; 0.24 ms ignores that. Yet 2.33 ms rests on three sessions only. Three clusters allow just 10 distinct resamples, the combinations of three sessions with repetition allowed. The smallest resample mean, 1 ms, and the largest, 10 ms, each have probability 1/27≈3.7%1/27 \approx 3.7\% among the 33=273^3 = 27 equally likely ordered draws, which is more than 2.5%. So the 2.5th and 97.5th percentiles of the resample means are 1 ms and 10 ms: the interval says only “between the fastest and the slowest session”. More repetitions only revisit the same 10 combinations.

Unequal sizes. Suppose instead that session 3 has only 1 event. The mean over all events is (100×1+100×2+1×10)/201=310/201≈1.54(100 \times 1 + 100 \times 2 + 1 \times 10)/201 = 310/201 \approx 1.54 ms, while the mean of the session means is still 4.333 ms. The draw 1, 1, 3 now gives (200×1+1×10)/201=210/201≈1.04(200 \times 1 + 1 \times 10)/201 = 210/201 \approx 1.04 ms for the event mean, but (1+1+10)/3=4(1 + 1 + 10)/3 = 4 ms for the mean of session means. The two statistics answer different questions, and the resampling must recompute the one declared in advance.

Stated precisely

Let the data consist of kk clusters with data sets D1,…,DkD_1, \dots, D_k, and let θ̂=s(D1,…,Dk)\hat\theta = s(D_1, \dots, D_k) be the statistic, where ss is the rule that computes it. One resample draws indices I1,…,IkI_1, \dots, I_k independently, each equally likely to be any of 1,…,k1, \dots, k, and computes θ̂*=s(DI1,…,DIk)\hat\theta^* = s(D_{I_1}, \dots, D_{I_k}). The bootstrap distribution is the distribution of θ̂*\hat\theta^* over these random draws, with the data held fixed; BB repetitions approximate it.

For the mean of cluster means, θ̂=c‾=1k∑i=1kci\hat\theta = \bar c = \frac{1}{k}\sum_{i=1}^{k} c_i, where cic_i is the mean of cluster ii, the variance of the bootstrap distribution has a closed form: Var*(θ̂*)=1k⋅1k∑i=1k(ci−c‾)2=k−1k⋅sc2k,\mathrm{Var}^*(\hat\theta^*) = \frac{1}{k}\cdot\frac{1}{k}\sum_{i=1}^{k}(c_i - \bar c)^2 = \frac{k-1}{k}\cdot\frac{s_c^2}{k}, where Var*\mathrm{Var}^* means variance over the random draws and sc2=1k−1∑i=1k(ci−c‾)2s_c^2 = \frac{1}{k-1}\sum_{i=1}^{k}(c_i - \bar c)^2 is the usual sample variance of the cluster means. The usual estimate of the variance of a mean of kk independent values is sc2/ks_c^2/k; the bootstrap value is smaller by the factor (k−1)/k(k - 1)/k, which is 2/32/3 for k=3k = 3. In the worked example sc2=(438/9)/2≈24.33s_c^2 = (438/9)/2 \approx 24.33, so 23×24.33/3≈5.41 ms2\frac{2}{3} \times 24.33/3 \approx 5.41 \text{ ms}^2, the value found above.

The cluster bootstrap estimates the sampling variation of θ̂\hat\theta correctly when three assumptions hold.

  1. Independent clusters. No state, such as a shared device, a shared warm cache or a shared measurement campaign, links two clusters. Inside a cluster any dependence is allowed.

  2. Clusters from one population. The clusters were obtained in the same way from the population of clusters that the claim is about.

  3. Many clusters. The justification is a limit argument in which the number of clusters kk grows. It gives no guarantee for a fixed small kk, however many rows each cluster holds.

Limits and common mistakes

Rows do not replace clusters. Three sessions with 100,000 events each are still three independent draws of whatever varies between sessions. A larger BB only computes the bootstrap distribution more exactly; it adds no information.

Few clusters give intervals that are too narrow and coarse. The factor (k−1)/k(k - 1)/k shrinks the variance, and kk clusters allow only (2k−1k)\binom{2k-1}{k} distinct resamples, where (ab)\binom{a}{b} is the number of ways to choose bb items from aa: 10 for k=3k = 3, 126 for k=5k = 5.

The wrong cluster level hides dependence. If all sessions ran on one device and the state of the device affects the results, a claim about devices in general rests on one device, and no resampling scheme can estimate the variation between devices from it. Treating dependent rows as independent units is pseudoreplication §11.6: the ordinary bootstrap on clustered rows commits it, and so does a cluster bootstrap at too low a level.

The cluster bootstrap measures sampling uncertainty only. It does not remove a systematic error, confounding §11.10 by a third factor that affects both the condition and the outcome, or sampling bias §14.31 in how the sessions were chosen.

It is not the block bootstrap §18.5.6. The block bootstrap draws stretches of consecutive observations from one long time series, in which dependence fades with distance in time. The cluster bootstrap needs clusters that are known in advance and independent of each other.

Questions answered

How many independent clusters are available?

The number of independent clusters is the number of top-level units that were sampled or assigned independently of each other, not the number of measured rows. To find it, ask of any two measurements whether they share state that could make both high or both low: the same session, the same device, the same start-up, the same build. The largest group that is still independent of the other groups is the cluster, and the count of those groups is the sample size that governs uncertainty and the number of units a cluster bootstrap draws from.

Three sessions of 100 events each give three clusters, not 300. If the three sessions also ran on one device, a claim about devices in general rests on one cluster. Report the count, the size of every cluster and how the levels nest. With few clusters a cluster bootstrap can give only a coarse interval that is too narrow: three clusters allow just 10 distinct resamples.

Related entries: Experimental unit (§11.3), Pseudoreplication (§11.6), Blocking (§11.9), Bootstrap (§11.19), Percentile bootstrap (§11.20), Standard error (§11.15).