CATE & the Resource Curse — Interactive Lab

A pedagogical companion to Causal Machine Learning and the Resource Curse with Stata 19 ↗ Back to the post

From ATE to CATE — and why heterogeneity matters

Does mining help or hurt local development? The headline answer is an ATE — a single number, averaged over every district in the sample. But the post's central claim is sharper: the effect of mining on nighttime lights is not the same everywhere. It depends on institutional quality. Stata 19's cate command lets us trace this dependence as a function τ(x) — the Conditional Average Treatment Effect.

This app lets you turn the dials yourself. In four tabs you will: visualise the ATE → GATE → CATE → IATE hierarchy with a small animation; explore the actual GATE estimates from the post's six binary contrasts; simulate how institutional moderation can flip findings depending on the DGP; and audit the §7 ATE table against the known ground truth.

One ATE, many CATEs — a chalkboard view

The animation below contrasts a constant treatment effect (steel-blue line, every unit gets the same lift) with a conditional treatment effect (orange curve, τ varies with institutional quality x). When the orange curve is flat, ATE = CATE = GATE for every group. When it slopes, the post's institutional-moderation finding becomes visible.

Tab 2

GATE Explorer

Six GATE estimates from the post. Pick a contrast (NTL 1v0, NTL 3v1, Conflict 1v0…) and a grouping variable (executive constraints or quality of government quartiles). Reproduce the post's §8 plots.

Tab 3

Heterogeneity Simulator

Slide the moderation strength θ and watch the GATE curve tilt. Run 100 small panels to see how often the heterogeneity test rejects homogeneity. Stress-test the §8 chi-squared.

Tab 4

ATE Forest Plot

The §7 ATE table, interactively. Toggle the NTL contrasts and the Conflict outcomes, compare PO / AIPW / Naive against the known ground truth, and see how close cross-fit estimates land.

Glossary (open a card if a term is unfamiliar)

ATE
Average Treatment Effect — the single number you would report in a press release. Headline result, but hides every subgroup pattern.
CATE — τ(x)
Conditional Average Treatment Effect. A function of covariates x, not a number. Where τ(x) bends with x, treatment helps some units more than others.
GATE
Group Average Treatment Effect. The CATE averaged over a pre-specified subgroup (e.g. each level of exec_constraints). Tested with estat gatetest.
IATE
Individualised ATE — one effect per observation, τ(x_i). Visualised with categraph histogram and categraph iateplot.
PO estimator
Partialing-Out. Residualises y and d against (x, w), then regresses one residual on the other. Robust to extreme propensities.
AIPW estimator
Augmented Inverse-Propensity Weighting. Doubly robust: stays consistent if either the outcome model or the propensity model is right.
Cross-fitting
Sample-splitting that prevents nuisance-model overfitting. xfolds(5) in the post means each fold's nuisance predictions come from a model trained on the other four.
Heterogeneity test
A formal χ² test of constant treatment effects (Chernozhukov et al. 2006). Rejection licenses CATE / GATE interpretation. The post's NTL 1v0 test gives χ²(1) = 53.05.

Three findings the app helps you see

  • Finding 1 — Mining lifts nighttime lights. §7 reports five well-identified ATEs spanning 0.149 to 0.611 log-NTL. Forest-plot tab (4) shows them next to the ground-truth column.
  • Finding 2 — Price effects are non-linear. NTL 2v1 (medium vs low prices) is essentially zero (−0.011, p = 0.90); NTL 3v1 (high vs low) is large and significant (0.405). The step from low to medium does nothing; the step to high does a lot.
  • Finding 3 — Institutions moderate mining, not prices. The mining-effect GATEs slope clearly with executive constraints (χ²(5) = 96.90); the price-effect GATEs by QoG are flat (χ²(3) = 5.81, p = 0.121). Tab 2 lets you switch between them.

GATE Explorer — heterogeneity by institutions

The post estimates six GATE patterns. Pick one and see the per-group estimates, their 95% CIs, and the formal χ² heterogeneity test. The contrast between the NTL 1v0 by exec_con panel (steep, χ² = 96.9) and the NTL 3v1 by qog_cat panel (flat, χ² = 5.8) is the picture behind Finding 3.

Pick a GATE panel

Each option reproduces one of the §8 GATE plots — using the actual point estimates and SEs from the post's Stata output.
heterogeneity χ²
df =
p-value
estat gatetest
verdict
at α = 0.05
groups
prespecified

What to look for

  • Slope direction. NTL 1v0 by exec_con drops monotonically from 0.275 (group 1) to 0.051 (group 6) — the mining effect shrinks as institutions strengthen. In the simulated DGP, weaker governance leaves more room for mining-led growth.
  • Flat vs sloped. Compare NTL 3v1 by QoG quartile (flat, χ²(3) = 5.81, p = 0.12) against NTL 1v0 by QoG quartile (steep, χ²(3) = 69.19, p < 0.001). Institutions systematically moderate the mining effect, not the price premium.
  • Conflict 1v0 panel. Range 0.033–0.106 across exec_con levels, χ²(5) = 5.00, p = 0.42. The test cannot reject homogeneity — mining raises conflict, but not differentially by institutions.

Heterogeneity Simulator — DGP with tunable moderation

Simulate a small resource-curse panel with a known data-generating process. Pick the ATE baseline τ₀ and the institutional-moderation slope θ. When θ ≠ 0, units with stronger institutions get a systematically different treatment effect, so the heterogeneity test should reject. When θ = 0, every unit gets τ₀ and rejection is a false positive. Run 100 simulations to see how often that happens.

Each fictional panel has n district-years. The post uses 2,700 for the 1v0 contrast.
The post's NTL 1v0 ground truth is 0.25. The Stata 19 cross-fit estimate (AIPW) is 0.149.
τ(x) = τ₀ + θ · (institutions − 3.5). Negative θ ⇒ stronger institutions, smaller mining effect (the post's §8 pattern).
Idiosyncratic noise on log-NTL. Larger σ ⇒ noisier estimates ⇒ harder to detect heterogeneity.

Truth Implied GATE by exec_con

τ(x) at each of the 6 institutional levels (analytic, no estimation noise)

τ(1)
τ(2)
τ(3)
τ(4)
τ(5)
τ(6)

Estimate Cross-fit GATE (one panel)

Sample mean of y(1) − y(0) within each exec_con cell, after randomising treatment 50/50

GATE(1)
GATE(2)
GATE(3)
GATE(4)
GATE(5)
GATE(6)
heterogeneity χ²
df = 5
p-value
single panel
ATE estimate
truth = τ₀
reject H₀ (homog.)?
at α = 0.05

What to look for

  • θ = 0 ⇒ flat curve. The cross-fit GATE bars should look noisy around τ₀. The χ² test should rarely exceed the 95% critical value (≈ 11.07 for df = 5). Anything more is sample-size dependent noise.
  • θ < 0 ⇒ downward slope. The §8 finding. Lower exec_con groups have larger GATEs; the heterogeneity test should reject for most random seeds.
  • Noise σ matters. Crank σ up: even strong moderation (θ = ±0.10) becomes hard to detect when n = 100. This is the small-sample warning the post gives for the within-mining price comparisons.

Sampling distribution over 100 panels

Single runs are noisy. Re-simulate the same parameters 100 times to see the bias-variance picture and the empirical rejection rate of the χ² test.

ATE Forest Plot — §7 estimates vs ground truth

These numbers come straight from §7 of the post — the same Stata 19 cate po / cate aipw output. Each estimator is plotted with its 95% CI for every NTL and Conflict contrast. The dashed orange column on the right shows the known ground-truth ATE from the DGP, so you can audit how close cross-fit Stata estimates land.

What to look for

  • Toggle Conflict outcomes off to focus on the NTL contrasts. PO and AIPW agree on direction for every contrast and overlap on most. The largest gap is NTL 3v1 (PO 0.595 vs AIPW 0.405), where the within-mining n = 300 limits precision.
  • Hover any point for SE, 95% CI, and the number of CATE variables the estimator used (always 10 — the catevarlist in §6.2).
  • Compare against ground truth. NTL 1v0 truth = 0.25, AIPW estimate = 0.149 (under-shoot). NTL 3v0 truth = 0.55, AIPW = 0.611 (slight over-shoot). Both are within a few SEs of the truth — random forests + 5-fold cross-fitting are not perfect on n = 2,700.

Outcomes

Methods

Subpopulation ATEs (estat ate)

The post's §9.3 splits the sample by exec_constraints to ask: "what is the average mining effect specifically in weakly-governed districts?" The answer is striking — three times larger than in strongly-governed districts.

Weak institutions (exec_con ≤ 2)

n558
ATE0.297
SE0.022
95% CI[0.255, 0.339]

Strong institutions (exec_con ≥ 4)

n1,526
ATE0.092
SE0.016
95% CI[0.062, 0.123]

Connecting the four tabs

  • Tab 1's animation showed the abstract picture: τ(x) constant vs τ(x) sloped.
  • Tab 2's GATE explorer made that picture concrete using the post's six §8 panels — and showed which contrasts have monotone slopes and which do not.
  • Tab 3's simulator stress-tested the heterogeneity test on a known DGP — confirming that the §8 χ² = 96.9 is well above what θ = 0 produces, even on a small n = 300 panel.
  • This forest plot closes the loop: every binary contrast in §7, all estimators, against the known ground truth. Together they reproduce the post's three findings without rerunning Stata.