Cluster bootstrap: resample the independent unit
Bootstrap uncertainty depends on what is resampled, not only on how many resamples are requested. If repeated rows belong to the same company, resampling rows independently can break the dependence that the research design needs to preserve. Start by identifying the plausibly independent unit.
The SciPy bootstrap reference describes resampling, interval options and paired index handling. Its paired option does not automatically discover company clusters. A cluster design must explicitly select clusters and retain the appropriate observations within each selected instance.
Define the estimator and cluster
Specify whether the target is an equal-company mean, an equal-row mean or a weighted population quantity. Those targets can differ when companies contribute different numbers of observations. The resampling unit and statistic must match the sampling design and target.
For a simple one-way cluster bootstrap, assume sampled clusters are suitably independent and representative. Sample the original number of cluster identifiers with replacement. For every selected cluster, carry its associated rows together, preserving their internal measurements and time order where relevant.
Assign a resample-instance identifier. A company selected twice contributes two cluster instances; deduplicating by its original company identifier would erase a legitimate repeated draw. Keep original identity for traceability and instance identity for constructing the bootstrap dataset.
Hypothetical three-company panel
Assume three fictional companies each contribute two observations. Company A has 1 and 1, B has 5 and 5, and C has 9 and 9. The equal-company mean and equal-row mean are both 5 here because sizes match.
| Company | Two observations | Company mean |
|---|---|---|
| A | 1, 1 | 1 |
| B | 5, 5 | 5 |
| C | 9, 9 | 9 |
One cluster resample selects A, A and C. Its rows are 1, 1, 1, 1, 9 and 9, with mean 22/6, about 3.6667. Another selects A, C and C, yielding 1, 1, 9, 9, 9 and 9, with mean 38/6, about 6.3333.
An ordinary row resample could take one A row, two B rows and three C rows independently. That breaks the two-row grouping. In this toy setup, rows inside a company are perfectly dependent, so pretending all six provide independent information changes the bootstrap distribution.
The three-company example is for checking the mechanics, not evidence that three clusters provide a reliable confidence interval. Thousands of computational resamples do not create additional independent companies or repair an unrepresentative original sample.
Preserve the target when sizes differ
For an equal-company mean, calculate the mean within each sampled company instance and then average the instance means. For an equal-row mean, combine the sampled rows according to that estimator. Cluster size can be informative, so the choice is substantive rather than a software optimization.
For paired before/after outcomes within a company, carry both sides together and recompute the difference inside each draw. Sampling the two columns independently would destroy the match. Likewise, keep numerator and denominator together when resampling a company-level ratio calculation.
Record the random generator setup, resample count, statistic, cluster rule and interval method. A reproducible seed helps reproduce a run; it does not establish validity. Increasing the resample count primarily reduces simulation noise conditional on the observed data and chosen scheme.
Check the distribution for degeneracy and instability, particularly with few clusters or extreme concentration. A common date shock can create dependence across companies, so a one-way company bootstrap may still miss an important source of uncertainty. More complex dependence requires a justified design rather than blindly adding another label.
The deliverable is a documented resampling scheme with a small inspectable draw and the target statistic. Recheck after changing identifiers, cluster definitions, weights or panel structure. Treat bootstrap intervals as assumption-dependent estimates, not guarantees from a library call.
Inspect one realized draw before trusting the full simulation. Verify the selected cluster-instance count, retained row sets, duplicated-instance handling and final statistic. A zero-row cluster or an identifier collision can silently change the estimator while still allowing a numerical interval to be returned.
FAQ
Does setting paired=True automatically make a cluster bootstrap?
No. It preserves corresponding indices across arrays; clusters still need an explicit resampling construction.
Can more bootstrap draws compensate for very few companies?
No. More draws improve computational approximation, not the number or representativeness of independent original units.