Measuring Causal Uncertainty with Cluster Bootstrapping | Humanitarians AI

Fellow Ushasvi Rachel walks through why row-level bootstrap resampling can understate uncertainty when the same product appears across many dates, and how a SKU-level cluster bootstrap in Python addresses it.

4:54 video4 min readWatch on YouTube

HAI Fellow Ushasvi Rachel walks through a methodological refinement to an existing causal analysis project, Causal Couture, which estimates the effect of social engagement on product sales. The prior week's work established the observational effect estimate along with row-level bootstrap uncertainty. This week's addition does not change the causal question; it changes how the uncertainty around that estimate is measured when the underlying data has repeated structure.

The problem with treating every row as independent

The existing validation workflow measured uncertainty by resampling eligible observations, re-estimating the engagement effect on each resample, and building an empirical distribution of those estimates. The data's analytical grain is date by SKU, meaning the same product appears repeatedly across different dates. Treating every date-SKU row as an independently resampled unit overlooks the fact that multiple rows belonging to the same product often share persistent characteristics: baseline demand, historical popularity, engagement behavior, and inventory patterns. When observations within a SKU are related to each other in these ways, independent row resampling can give an incomplete picture of the true uncertainty.

Building the SKU-level cluster bootstrap

To address this, Rachel implemented a new cluster bootstrap procedure in app/api/causal_cluster_bootstrap.py. The key change is what gets resampled: instead of resampling individual date-SKU rows, the procedure resamples entire SKU clusters. It first identifies every unique SKU in the eligible causal analysis dataset, then samples those SKU clusters with replacement. All observations belonging to a sampled SKU are retained together, and a new bootstrap dataset is reconstructed from those clusters before the existing causal estimator re-runs on it. This repeats across bootstrap iterations to produce a new empirical distribution of estimated effects, this time built from resampled products rather than resampled rows.

Avoiding fixed-effect collapse

Because sampling happens with replacement, the same SKU can be selected more than once within a single bootstrap iteration. Each sampled copy of that SKU receives a unique bootstrap cluster identifier so that duplicate copies do not collapse into a single SKU category when the estimator constructs its SKU fixed effects. Without that identifier, resampling the same product twice would effectively be treated as one observation instead of two, undermining the point of the cluster resampling.

Integrating both methods side by side

The new method was integrated into the phase 5 causal validation endpoint without removing the original row-level output. The API response now distinguishes the two: uncertainty refers to the original row-level bootstrap, and cluster_uncertainty refers to the new SKU-level method. Keeping both available makes direct comparison possible. The goal is not to replace one method with the other by default, but to test how sensitive the uncertainty estimate is to the choice of resampling unit. If the row-level and cluster estimates land close together, the effect looks less sensitive to that choice. If the cluster bootstrap produces a substantially wider interval, that gap suggests within-SKU dependence matters and the row-level method may have understated the true uncertainty. A wider interval on its own does not mean the point estimate is wrong; it is a robustness diagnostic, not a correction to the causal identification.

What this method does and does not establish

The cluster bootstrap output reports the number of available SKU clusters, the requested iterations, and the successful estimations, along with the mean effect, median effect, bootstrap standard error, and 95 percent interval. Built-in checks for insufficient clusters or failed samples let the system fail transparently rather than return a misleading number. Rachel documented the comparison guidance and its limits directly in the project's phase 5 cluster bootstrap refinement notes: this comparison does not remove unobserved confounding, does not prove the causal DAG, and does not guarantee treatment positivity. It refines how uncertainty is estimated, which is a distinct question from whether the underlying causal identification is correct.

Key takeaways

  • Row-level bootstrap resampling can understate uncertainty when observations from the same product repeat across dates and share unmeasured characteristics.
  • A SKU-level cluster bootstrap resamples entire products with replacement instead of individual rows, better preserving repeated product structure.
  • Each resampled copy of a SKU needs a unique cluster identifier, or duplicate selections collapse into one category during fixed-effect estimation.
  • The API now reports both uncertainty (row-level) and cluster_uncertainty (SKU-level) so the two can be compared directly.
  • A wider cluster-bootstrap interval flags sensitivity to the resampling unit; it does not by itself prove the row-level estimate was wrong, and it does not address confounding or causal identification.

Who this is for

Analysts and researchers working with causal effect estimates on panel or repeated-unit data, particularly anyone whose bootstrap uncertainty intervals may be too narrow because the resampling unit does not match the data's actual clustering structure.

Chapters

  1. 0:00Recapping Causal Couture's week 6 foundations
  2. 0:22The risk of ignoring repeated product patterns across dates
  3. 0:45Building the cluster bootstrap algorithm in Python
  4. 1:10Using unique bootstrap cluster identifiers to avoid fixed-effect collapse
  5. 1:35Integrating both bootstrap methods into the validation response API
  6. 1:58Documenting method comparisons, limitations, and wider intervals
Full transcript(auto-generated, with timestamps)

Recapping Causal Couture's week 6 foundations

[0:00]I'm Ashes Vi Rachel. Week six established causal couture's first working causal intelligence foundation, observational effect estimation, row-level bootstrap uncertainty, placebo testing, treatment variation diagnostics, stockout analysis, robustness testing, and observational evidence reporting. Week seven focuses on making that foundation more reliable. This week does not introduce a new causal question. Instead, it addresses

The risk of ignoring repeated product patterns across dates

[0:24]One methodological weakness in the existing analysis. How uncertainty is measured around the estimated effect of social engagement on subsequent product sales. Existing validation workflow uses bootstrap resampling. Eligible observations are sampled. The engagement effect is reestimated and this process is repeated to create an empirical distribution of estimates. From that distribution, the system can summarize

Building the cluster bootstrap algorithm in Python

[0:46]The mean effect, median effect, bootstrap standard error, and 95% interval. The analytical grain is date by SKU. The same product can appear repeatedly across different dates. Treating every day TKU row as an independently resampled unit may overlook the fact that multiple observations belong to the same product over time. Those repeated observations may share persistent characteristics, baseline demand, historical popularity,

Using unique bootstrap cluster identifiers to avoid fixed-effect collapse

[1:11]Engagement behavior, inventory patterns, or other product specific factors. These shared features can make observations within one SKU related to one another. This does not make the original rowle bootstrap useless or automatically wrong. It means that relying only on independent row resampling may provide an incomplete picture of uncertainty when observations are naturally clustered within products. To address this limitation, I implemented a new

Integrating both bootstrap methods into the validation response API

[1:36]Skule cluster bootstrap procedure in app/appi/causal_cluster_ootstrap.py. The key change is the resampling unit from an individual date SKU observation to an entire SKU cluster. Procedure first identifies the unique SKUs in the eligible causal analysis dare set. It then samples those SKU clusters with replacement. All eligible observations

Documenting method comparisons, limitations, and wider intervals

[1:58]Belonging to each sampled SKU are retained and a new bootstrap dare set is reconstructed. The existing causal estimator is used to reestimate the engagement effect. This repeats across bootstrap iterations producing an empirical distribution of estimated effects. In the rowle bootstrap, individual rows are sampled independently. In the SKU level cluster bootstrap, entire product clusters are sampled together. The underlying observations remain the same. The resampling unit changes, so repeated product structure is better preserved because sampling occurs with replacement. The same SKU can be selected more than once in a single bootstrap iteration. Each sampled copy receives a unique bootstrap cluster identifier. This prevents duplicate copies from collapsing into one SKU category when the estimator constructs SKU fixed effects. Cluster bootstrap output reports available SKU clusters, requested iterations, and successful estimations. It also reports the mean engagement effect, median effect,

Bootstrap standard error, and 95% interval. Checks for insufficient clusters or successful samples allow the system to fail transparently instead of returning misleading uncertainty estimates. New method was integrated into get/phase 5/causal validation. The original rowle uncertainty output was deliberately preserved. The response now distinguishes uncertainty, meaning the original rowle bootstrap from cluster underscore uncertainty, meaning the new SKU level method. The rest of the phase 5 validation workflow remains intact. Keeping both methods makes comparison possible. The goal is not to replace one approach automatically, but to examine how sensitive the uncertainty assessment is to the choice of resampling unit. This gives the validation framework an additional reliability check. If the rowle and SKU cluster estimates and intervals are reasonably similar, the effect appears less sensitive to the resampling unit. If the cluster bootstrap produces substantially wider uncertainty within SKU dependence

May matter and independent row resampling may understate uncertainty. A wider interval does not automatically mean the estimate is wrong. This comparison is a robustness diagnostic. It does not remove unobserved confounding, prove the causal DAG, guarantee treatment positivity, or establish causality. I documented the method comparison guidance and these analytical limits in doc/phase 5_cluster bootstrap_refinement. MD. After integration, the fast API backend loaded successfully. The updated validation workflow executed correctly. Cluster uncertainty appeared alongside the original analysis and the broader phase 5 pipeline remained intact. At the end of week seven, causal coutur has two complimentary uncertainty approaches. Rowlevel bootstrap and skule level cluster bootstrap. New method better respects repeated product observations and makes sensitivity to within product dependence more transparent. This weak improved causal reliability by refining uncertainty estimation. But improved uncertainty estimation is not the same as improved causal identification.

More from Causal Couture

Humanitarians AI Lyrical Literacy Project