The decision
You have a job-training programme, a pool of survey respondents who did not take part, and a propensity-score model. Before you act on the number it gives, you want to know whether that kind of model can be trusted. Most of the time you cannot check. Here you can, because the National Supported Work (NSW) demonstration was a randomised experiment: 260 men were randomised out of the programme, and their earnings give an experimental answer to compare against. The study asks, as a decision: if I had only a survey comparison group, would a propensity-score estimate have told me the right thing, and how would I have known?
Concretely, three questions, in order. First, do the published Dehejia-Wahba numbers come back out of the authors' own files? Second, how far does a naive comparison of trainees with survey men miss the experimental answer? Third, do 1999-vintage propensity-score estimators recover it on a first comparison group (PSID-1), and does the one chosen there carry, with its covariate list unchanged, to a second group (CPS-1) that was sealed until the end?
Takeaways
- The files are the paper's files, but four targets do not reproduce. Every unadjusted value, every sample size and the whole experimental row come back within one dollar. The four misses are exactly the comparison-group adjusted estimates and their standard errors, against targets transcribed from the working paper alone.
- The naive contrast is not just wrong, it has the wrong sign, on both comparison groups, by more than the benchmark's own size.
- Propensity methods did not clearly recover the benchmark on PSID-1. Three estimators on one score spread over more than the benchmark itself. On the sealed CPS-1 lane the selected estimator lands within the registered band once, which is consistency, not validation.
How the study is built
Two registered tracks, each a set of pre-registered cells rather than a search: reproduction counts how many published targets a cell misses by more than one dollar, and att records one propensity-score estimate of the effect of NSW on 1978 earnings, with its bootstrap range. Seven predictions (P1 to P7) were registered with arithmetic rules before any evidence existed, and the notary adjudicated each. There is no frontier to climb here, so there is no "best model"; the question is what the audit shows. The claim totals and the referee's verdict are in the evidence block of section 5, copied from the records.
You already know the core idea
If you have trained a domain classifier to tell target rows from source rows and then reweighted the source rows to look like the target, you have done the core of propensity weighting for the effect on the treated. The target population is the 185 men who took the programme. The source is 2,490 survey men (PSID-1) or 15,992 (CPS-1) who did not. What we cannot observe is what the trainees would have earned without training; the survey men, reweighted or matched to look like the trainees, stand in for it.
The answer key, and the identity that frames the audit
The estimand is the average effect on the treated (ATT), and the experiment supplies a benchmark for it:
The study's registered quantity is the gap, an estimator's estimate minus the experimental one, computed in the same run. Every estimator has the form , so the trainees' outcomes cancel and the gap reduces to a pure prediction error:
In words: can survey men, weighted or matched on the trainees' covariates, predict what the randomised-out controls earned? That reframing is why the audit is meaningful. It tests the counterfactual directly.
Identification, and what must hold
Propensity methods rest on selection on observables and overlap. Given the covariates, treatment is unrelated to untreated earnings, and the score stays below one on the trainees' support:
Selection on observables cannot be checked from the data; the benchmark checks it from outside. Overlap can be checked, and the study pins two diagnostics for it with every estimate: the largest single weight share, and the number of comparison men used. Specification matters too, which is what Smith and Todd showed.
Three ways to borrow survey men
Odds-weighted IPW on common support (comparison men scored inside the trainees' range, Table 3 note g) weights each man by :
Doubly robust AIPW adds an outcome model (OLS on the comparison men) and corrects its average error with the same weights. It is consistent if either the score or the regression is right:
One-nearest-neighbour matching with replacement gives each trainee the single closest survey man on the score; it is weighting with integer weights:
What the interval is, and is not
Every att cell reports a percentile bootstrap of 500 draws that resamples trainees and comparison men separately and re-fits the logit in each draw, but holds the 260 experimental controls fixed. So it is a range for the ATT estimate with the benchmark held fixed, not a range for the gap. For matching, the standard bootstrap is not valid at all (Abadie and Imbens), so that range is descriptive only. The registered rules read only point gaps, so no verdict depends on an interval.
Three pinned files, three lanes
The data are Dehejia's own NBER files, each pinned by sha256 and checked at the DATA gate: the NSW experimental sample (185 treated and 260 control men), PSID-1 (2,490 survey men) and CPS-1 (15,992). The split is predefined: the lanes are the design, so nothing is partitioned by a seed. NSW is the training lane, PSID-1 the development lane, and CPS-1 the sealed test lane; the sealed lane's 1978 earnings were never examined during development. All three have exactly the published sample sizes, and the PSID-1 and CPS-1 earnings means agree with Dehejia-Wahba's Table 1, a file-identity check.
The value-pattern check and its gotchas
Every column was inspected by value, never by dtype. The indicators hold only 0 and 1; there are no sentinels, no string-coded values and no missing entries in any lane. Earnings are non-negative with exact zeros that mean "not working" rather than "missing", and zero mass is large in the experiment (about three in four trainee-sample men have zero 1974 earnings). Two further points matter downstream. First, treat is zero for every PSID-1 and CPS-1 row: the treated group is always the NSW 185, so a model must pool them with the lane's comparison men, and the lanes are not self-contained treatment-control datasets. Second, the leakage audit passed (8 of 8 index-table checks), after a harness defect in the dataframe mode, which could not reproduce a predefined split under a scalar task, was fixed in the framework rather than waived.
Why the study exists: the comparison groups are unlike the trainees
The ranked cautions are the object of study. Comparison men differ from trainees by more than 0.8 standard deviations on six of eight covariates before any adjustment: for PSID-1 the standardized mean differences include -1.84 in married, -1.77 in re75, -1.72 in re74 and 1.48 in black, and CPS-1 differs by 2.43 in black. The NSW treated-versus-control row, by contrast, is balanced as randomisation predicts. Earnings are heavy-tailed, so means are outlier-sensitive, and with only 185 treated men every estimate is noisy. Nothing is trimmed in prepare.py; common support is a specification choice made later, in the estimator.
The call
The data card's decision is GO, with cautions: the three lanes carry the exact published sizes, fixed provenance, no missingness, no sentinels and a split that reproduces from the contract alone. The hazards (imbalance, zero-heavy earnings, small treated n) are disclosed as warnings and travel into the method and experiments as things to measure.
How to read this journey
Both tracks are registered: each run is a pre-registered cell that the notary measures, never a keep that beats an incumbent. So there is no climbing frontier here, and the trajectories below show cells in the order they ran, with the sealed confirmation cell marked separately. The table at the end of the section is generated from the run manifests.
Phase 1: the anchor (reproduction, development lane)
The first cell, E0001, reproduced Table 3 columns (1) and (2) and Table 1's sizes on the NSW and PSID-1 lanes. It missed two targets, the PSID-1 adjusted estimate and its standard error, and the notary refuted P1. That was foreseen at the METHOD gate, where reading Table 3 beside Table 2 showed that the NSW adjusted value matches one Table 2 column while the comparison-group values match another. The predictions were deliberately left as registered, and the reproduction cell gained never-counted diagnostic rows that show which regression each printed value corresponds to. The anchor's STOP rule fired only for an unexplained miss, so the study proceeded.
Phase 2: the estimators (att, PSID-1)
Four registered cells ran on PSID-1: IPW (E0002, P2), 1-NN matching (E0005, P4), AIPW (E0006, P3) and IPW without any 1974-earnings term (E0007, P5). Two run ids, E0003 and E0004, are driver-error crashes with no scientific content: a foreground tool timeout killed the run, and a re-launch on the restored cell was killed. They spent two of the four slots and forced a recorded budget re-record before the evidence it enabled. The notary then selected the sealed estimator by the registered rule, smallest absolute gap among P2 to P4, which chose AIPW. The selection was written down as a dated decision before any sealed access.
An operator error in the experimenter's checkout also removed filed evidence commits while E0005 was finishing and misnumbered the next cell. The lead killed that run before it printed a number, reset to the fully filed E0005, and the AIPW cell ran as E0006. Every leftover is preserved under incidents/ and the killed run is not evidence.
Phase 3: sealed confirmation (CPS-1)
Each track holds one sealed access, taken after a mandatory dry run. The sealed reproduction cell (E0008) and the sealed AIPW cell (E0009) are separate evidence from everything above. The first sealed att dry run hit the old 900-second limit on PSID-1 data under load (exit 124), so the budget was raised before the real run, which took far longer than the old limit. Without the dry run the track's only sealed access would most likely have been spent on a timeout. Both sealed runs are single draws; neither was re-executed, and the exact re-executions on record are of development cells.
The ledger
Tracks: reproduction — targets_outside_tolerance (lower is better) · att — att_usd (higher is better)
| Exp | Track | Kind | Metric | Status | Description |
|---|---|---|---|---|---|
| E0001 | reproduction | development | 2 | measured | anchor: reproduce DW (1999) Table 3 columns (1)-(2) and Table 1 sizes on the development lane; registered cell measured |
| E0002 | att | development | 3038.435574 | measured | estimators: ipw dw_psid 500 reps, adjudicates P2; registered cell measured |
| E0003 | att | development | NA | crash | recovered interrupted run with no terminal record |
| E0004 | att | development | NA | crash | estimators: match dw_psid 500 reps, adjudicates P4 (rerun after E0003 was interrupted by the driver's tool timeout); process exit code 143 |
| E0005 | att | development | 560.281374 | measured | estimators: match dw_psid 500 reps, adjudicates P4 (E0003/E0004 were driver errors); registered cell measured |
| E0006 | att | development | 2683.81822 | measured | estimators: aipw dw_psid 500 reps, adjudicates P3; registered cell measured |
| E0007 | att | development | -15.330317 | measured | estimators: ipw no_re74 500 reps, adjudicates P5; registered cell measured |
| E0008 | reproduction | final_test | 2 | measured | sealed CPS-1 reproduction of DW Table 3 cols (1)-(2) and Table 1 size; registered cell measured |
| E0009 | att | final_test | 1327.53819 | measured | sealed CPS-1: AIPW dw_psid 500 reps, the cell selected at E0006; registered cell measured |
The evidence behind every verdict
Verdicts below cite claims by id. The block here is generated from the lock and the study state, so the counts, strengths, errata and the referee's verdict are records, not prose.
- claims
31locked inclaims.lock- by strength
- confirmed
7· exploratory24 - by class
- empirical-description
14· mechanism-interpretation5· procedural-verdict1· research-discipline11 - errata
11of31claims tagged ·9erratum record(s) in the lock- locked at
407a9432e754· klein2.2.0- label
- confirmed
- referee
- PASS-WITH-NOTES —
klein-referee round 2 (Claude Code subagent, model: claude-opus-5-5)· independent of the experimenter: yes
The naive contrast is far off, and the experiment row reproduces
The first finding is LaLonde's lesson in one row: the naive difference in means against PSID-1 is -15204.78, against an experimental 1794.34, the wrong sign and a miss larger than the benchmark itself; against the sealed CPS-1 lane it is -8497.52 (claim C2). The two panels below put every design on one axis, then show how well each published target reproduces.
The reproduction verdict is mixed but precise. Of the registered targets, 9 of 11 on the development lane and 3 of 5 on the sealed lane reproduce, and the four misses are exactly the comparison-group adjusted values and their standard errors, against targets transcribed from the NBER working paper alone (claim C30). The classical OLS standard-error formula matches on every target that can be checked, so the worry that the paper used a different formula did not materialise. The likeliest reason for the misses, an exploratory reading found at METHOD, is that the working paper's Table 3 column (2) appears to mix two Table 2 columns (claim C10). That reading rests on one transcription, and the confirmed content is only the measured equalities and misses (claim C26). A transcription error in those four values would read as a miss, and only a second source can rule that out.
Propensity estimators on PSID-1: one of three lands in the band
With the Dehejia-Wahba logit, only AIPW lands within the registered 1000 dollars of the benchmark, with gaps of +1244.09 for IPW, -1234.06 for 1-NN matching and +889.48 for AIPW (claim C23). IPW and matching miss by almost the same amount on opposite sides, and the three estimates span 560.28 to 3038.44, wider than the benchmark itself (claim C31). The bootstrap ranges all contain the benchmark, but they hold the experimental controls fixed and the matching one is no valid interval, so containment is not evidence that an estimator recovers it. On weights, what was measured is the largest single weight share (0.135 for IPW and AIPW, 0.146 for matching) and 56 distinct matched men, not an effective sample size, so this study says the weights are concentrated, not that an estimate rests on a few people (claim C7).
Carried to the sealed lane
The selected AIPW estimator, with the PSID-1 covariate list unchanged and its logit and outcome model re-fit on CPS-1, estimates an ATT of 1327.54 with a bootstrap range from -129.17 to 2835.62, a gap of -466.80 against the benchmark (claim C29). That is within the band, once, for an estimator chosen using the development answer key, and the range does not exclude zero. Its largest weight share fell to 0.0426. The strength of this claim means one sealed run plus an exact re-execution of a development cell of the same pipeline, never a replicated sealed result.
Surprises
- Which sign the misses take. The method card expected every out-of-band PSID-1 gap to be negative. IPW's was positive, so that prior fell. Of the card's eight staked priors, 7 held (claim C9).
- P5 could not have failed for the reason it was written. It asked whether IPW without 1974 earnings misses by more than 1000 dollars, but IPW with them already did, so the rule would have been supported even had 1974 earnings been irrelevant (claim C13). The cell also did more than drop one covariate: it removed three terms, added a 1975 flag and moved the support from 1146 to 1092 men, so the shift from 3038.44 to -15.33 belongs to that whole specification change (claim C22). Whether 1974 earnings alone is load-bearing is open.
- Matching reproduced the paper's control count but not its estimate (56 men, but 560.28 where the paper prints a much higher figure). Unresolved; no mechanism is claimed.
- The sealed gap is smaller than the development gap and of the other sign. Better CPS-1 overlap is only one candidate: the pre-weighting balance points both ways, and one sealed draw cannot separate any mechanism from luck (claim C28).
What a decision-maker should take from this
The estimand is the average effect of the programme on 1978 earnings for the men who took it. The experimental answer is 1794.34, and every propensity row rests on selection on observables plus overlap, which this study does not test. With only PSID-1 you could not have told which of three estimates was right, so report the set, not one number. With the larger CPS-1 pool, the selected estimator agrees with the benchmark once, which is consistency and not validation. Changing the score's specification moved the answer by more than the benchmark's size, so the result depends on the specification, and this study ran one specification per estimator. What would change the conclusions: a placebo outcome that does not come out near zero, a specification family in which the CPS-1 gap leaves the band, or an interval that also resamples the experimental controls. Two controls are worth naming honestly: the NSW experimental reproduction is the positive control, and no placebo (negative) control was run. The four PSID-1 att cells are a family of four comparisons with no family-wise adjustment, so they stay exploratory; the sealed cells and the deterministic reproduction counts are not families.
The cell you edit: analyze.py, as it ran at E0009
The whole mutable surface is one file, and a cell only chooses: which estimator, which propensity specification, how many bootstrap draws. The library computes. Because the notary restores the file after every registered cell, the listing below is the file as the sealed AIPW cell (E0009) executed it, read from that run's recorded candidate commit, not whatever is on disk now. Its CELL block reads AIPW with the PSID-1 specification, the one selected on development.
analyze.py · executed by E0009 (final_test, track att) at commit ac09d5612389 · sha256 bfd29a47da94…
"""One registered cell (the mutable surface of study 23).
A cell CHOOSES — the library (lib/lalonde.py) computes. Two tracks:
* `reproduction` — recompute Dehejia & Wahba's Table 3 columns (1)-(2) for the
lane being evaluated and count the published targets missed by more than the
registered tolerance. The table of every target is pinned.
* `att` — one propensity-score estimate of the effect of NSW on 1978 earnings,
using the NSW treated men against the lane's NON-experimental comparison group,
with a percentile-bootstrap interval; `att_gap_usd` is its distance from the
experimental estimate computed in the same run from the NSW controls.
Lanes come from the contract's predefined split: development = PSID-1, the sealed
final test = CPS-1. The notary sets KLEIN_EVALUATION_KIND; a cell never picks it.
"""
from __future__ import annotations
import os
import sys
import time
from pathlib import Path
import numpy as np
sys.path.insert(0, str(Path(__file__).resolve().parent))
from lib import lalonde # noqa: E402
from kleinlib.data import load_partition # noqa: E402
from kleinlib.eval import evaluate_estimate, evaluate_table # noqa: E402
SMOKE = os.environ.get("KLEIN_SMOKE") == "1"
EXPERIMENT_ID = os.environ.get("KLEIN_EXPERIMENT_ID") or ("SMOKE" if SMOKE else None)
TRACK = os.environ.get("KLEIN_TRACK") or ("reproduction" if SMOKE else None)
# ---- the cell -----------------------------------------------------------------
CELL = {
"estimator": "aipw", # att track: ipw | aipw | match
"spec": "dw_psid", # att track: a key of lalonde.PROPENSITY
"reps": 500, # att track: bootstrap draws (each re-fits the propensity model)
}
# -------------------------------------------------------------------------------
def main() -> None:
if EXPERIMENT_ID is None or TRACK is None:
raise SystemExit("run through `klein run-one` (or KLEIN_SMOKE=1 for a shape check)")
t0 = time.time()
fit, comparison, fit_y, comparison_y = load_partition(target="re78")
fit = lalonde.features(fit.assign(re78=fit_y))
comparison = lalonde.features(comparison.assign(re78=comparison_y))
nsw = fit[fit["sample"] == "nsw"]
treated, controls = nsw[nsw["treat"] == 1], nsw[nsw["treat"] == 0]
lane = str(comparison["sample"].iloc[0]) # psid1 on development, cps1 when sealed
experimental = float(treated["re78"].mean() - controls["re78"].mean())
if TRACK == "reproduction":
targets = lalonde.TARGETS["development" if lane == "psid1" else "final_test"]
measured: dict[str, float] = {}
if lane == "psid1":
measured.update({f"nsw_{k}": v for k, v in lalonde.contrast(treated, controls).items()})
measured.update({"n_nsw_treated": len(treated), "n_nsw_control": len(controls)})
measured.update({f"{lane}_{k}": v for k, v in lalonde.contrast(treated, comparison).items()})
measured[f"n_{lane}"] = len(comparison)
rows = []
for name, printed in targets.items():
value = measured.get(name)
ok = value is not None and abs(value - printed) <= lalonde.TOLERANCE
rows.append({"target": name, "published": printed, "reproduced": value,
"abs_diff": None if value is None else abs(value - printed),
"tolerance": lalonde.TOLERANCE, "status": "ok" if ok else "missed"})
missed = sum(r["status"] == "missed" for r in rows)
# Diagnostic rows (never counted): which Table 2 Panel C column each lane's
# published "adjusted" value actually is (lib/lalonde.py:ADJUSTMENT_ALL).
lanes = [("nsw", controls), (lane, comparison)] if lane == "psid1" else [(lane, comparison)]
for name, group in lanes:
panel = lalonde.PANEL_C[name]
values = {"col4_note_a": lalonde.contrast(treated, group)["adjusted"],
**lalonde.diagnostics(treated, group)}
for spec, value in values.items():
for column, printed in panel.items():
rows.append({"target": f"diag_{name}_{spec}_vs_{column}", "published": printed,
"reproduced": value, "abs_diff": abs(value - printed),
"tolerance": lalonde.TOLERANCE,
"status": "diagnostic"})
path = lalonde.write_table(f"tables/reproduction_{lane}.tsv", list(rows[0]), rows)
evaluate_table(
path, missed, exp_id=EXPERIMENT_ID, metric_name="targets_outside_tolerance",
metric_goal="lower", rows=len(rows), study_dir=".", t0=t0,
extra={"targets": sum(r["status"] != "diagnostic" for r in rows), "experimental_att": experimental},
)
return
if TRACK == "att":
estimate = lalonde.att(treated, comparison, estimator=CELL["estimator"], spec=CELL["spec"])
reps = 20 if SMOKE else int(CELL["reps"])
draws = lalonde.bootstrap(treated, comparison, estimator=CELL["estimator"], spec=CELL["spec"], reps=reps)
low, high = (float(q) for q in np.quantile(draws, [0.025, 0.975]))
path = lalonde.write_table(
f"tables/att_{EXPERIMENT_ID}.tsv",
["lane", "estimator", "spec", "att", "ci_low", "ci_high", "experimental_att", "gap",
"n_treated", "n_controls_used", "max_weight_share", "reps", "bootstrap_seed"],
[{"lane": lane, "estimator": CELL["estimator"], "spec": CELL["spec"], "att": estimate.att,
"ci_low": low, "ci_high": high, "experimental_att": experimental,
"gap": estimate.att - experimental, "n_treated": estimate.n_treated,
"n_controls_used": estimate.n_controls_used, "max_weight_share": estimate.max_weight_share,
"reps": reps, "bootstrap_seed": lalonde.BOOTSTRAP_SEED}],
)
if not SMOKE:
print(f"artifact: {path.relative_to(lalonde.study_dir()).as_posix()}")
evaluate_estimate(
estimate.att, min(low, estimate.att), max(high, estimate.att), estimate.n_treated,
exp_id=EXPERIMENT_ID, metric_name="att_usd", metric_goal="higher", study_dir=".", t0=t0,
extra={"att_gap_usd": estimate.att - experimental, "experimental_att": experimental,
"n_controls_used": estimate.n_controls_used,
"max_weight_share": estimate.max_weight_share},
)
return
raise SystemExit(f"unknown track {TRACK!r}")
if __name__ == "__main__":
main()
Three things in it are worth stealing. The lane is read from the data (comparison["sample"]) rather than passed in, so the same cell runs on PSID-1 and, sealed, on CPS-1 without an edit. The reproduction branch computes the registered targets and also never-counted diagnostic rows that show which published column each value matches. And the att branch pins its table with an artifact: line and prints the point, the bootstrap range and the gap-bearing extras (att_gap_usd, n_controls_used, max_weight_share) so the notary can adjudicate predictions on the printed block. The reproduction cell as it ran at E0001 differs only in CELL, which the reproduction track ignores:
analyze.py · executed by E0001 (development, track reproduction) at commit 28d1f9f0ded2 · sha256 6ffecc753f09…
"""One registered cell (the mutable surface of study 23).
A cell CHOOSES — the library (lib/lalonde.py) computes. Two tracks:
* `reproduction` — recompute Dehejia & Wahba's Table 3 columns (1)-(2) for the
lane being evaluated and count the published targets missed by more than the
registered tolerance. The table of every target is pinned.
* `att` — one propensity-score estimate of the effect of NSW on 1978 earnings,
using the NSW treated men against the lane's NON-experimental comparison group,
with a percentile-bootstrap interval; `att_gap_usd` is its distance from the
experimental estimate computed in the same run from the NSW controls.
Lanes come from the contract's predefined split: development = PSID-1, the sealed
final test = CPS-1. The notary sets KLEIN_EVALUATION_KIND; a cell never picks it.
"""
from __future__ import annotations
import os
import sys
import time
from pathlib import Path
import numpy as np
sys.path.insert(0, str(Path(__file__).resolve().parent))
from lib import lalonde # noqa: E402
from kleinlib.data import load_partition # noqa: E402
from kleinlib.eval import evaluate_estimate, evaluate_table # noqa: E402
SMOKE = os.environ.get("KLEIN_SMOKE") == "1"
EXPERIMENT_ID = os.environ.get("KLEIN_EXPERIMENT_ID") or ("SMOKE" if SMOKE else None)
TRACK = os.environ.get("KLEIN_TRACK") or ("reproduction" if SMOKE else None)
# ---- the cell -----------------------------------------------------------------
CELL = {
"estimator": "ipw", # att track: ipw | aipw | match
"spec": "dw_psid", # att track: a key of lalonde.PROPENSITY
"reps": 500, # att track: bootstrap draws (each re-fits the propensity model)
}
# -------------------------------------------------------------------------------
def main() -> None:
if EXPERIMENT_ID is None or TRACK is None:
raise SystemExit("run through `klein run-one` (or KLEIN_SMOKE=1 for a shape check)")
t0 = time.time()
fit, comparison, fit_y, comparison_y = load_partition(target="re78")
fit = lalonde.features(fit.assign(re78=fit_y))
comparison = lalonde.features(comparison.assign(re78=comparison_y))
nsw = fit[fit["sample"] == "nsw"]
treated, controls = nsw[nsw["treat"] == 1], nsw[nsw["treat"] == 0]
lane = str(comparison["sample"].iloc[0]) # psid1 on development, cps1 when sealed
experimental = float(treated["re78"].mean() - controls["re78"].mean())
if TRACK == "reproduction":
targets = lalonde.TARGETS["development" if lane == "psid1" else "final_test"]
measured: dict[str, float] = {}
if lane == "psid1":
measured.update({f"nsw_{k}": v for k, v in lalonde.contrast(treated, controls).items()})
measured.update({"n_nsw_treated": len(treated), "n_nsw_control": len(controls)})
measured.update({f"{lane}_{k}": v for k, v in lalonde.contrast(treated, comparison).items()})
measured[f"n_{lane}"] = len(comparison)
rows = []
for name, printed in targets.items():
value = measured.get(name)
ok = value is not None and abs(value - printed) <= lalonde.TOLERANCE
rows.append({"target": name, "published": printed, "reproduced": value,
"abs_diff": None if value is None else abs(value - printed),
"tolerance": lalonde.TOLERANCE, "status": "ok" if ok else "missed"})
missed = sum(r["status"] == "missed" for r in rows)
# Diagnostic rows (never counted): which Table 2 Panel C column each lane's
# published "adjusted" value actually is (lib/lalonde.py:ADJUSTMENT_ALL).
lanes = [("nsw", controls), (lane, comparison)] if lane == "psid1" else [(lane, comparison)]
for name, group in lanes:
panel = lalonde.PANEL_C[name]
values = {"col4_note_a": lalonde.contrast(treated, group)["adjusted"],
**lalonde.diagnostics(treated, group)}
for spec, value in values.items():
for column, printed in panel.items():
rows.append({"target": f"diag_{name}_{spec}_vs_{column}", "published": printed,
"reproduced": value, "abs_diff": abs(value - printed),
"tolerance": lalonde.TOLERANCE,
"status": "diagnostic"})
path = lalonde.write_table(f"tables/reproduction_{lane}.tsv", list(rows[0]), rows)
evaluate_table(
path, missed, exp_id=EXPERIMENT_ID, metric_name="targets_outside_tolerance",
metric_goal="lower", rows=len(rows), study_dir=".", t0=t0,
extra={"targets": sum(r["status"] != "diagnostic" for r in rows), "experimental_att": experimental},
)
return
if TRACK == "att":
estimate = lalonde.att(treated, comparison, estimator=CELL["estimator"], spec=CELL["spec"])
reps = 20 if SMOKE else int(CELL["reps"])
draws = lalonde.bootstrap(treated, comparison, estimator=CELL["estimator"], spec=CELL["spec"], reps=reps)
low, high = (float(q) for q in np.quantile(draws, [0.025, 0.975]))
path = lalonde.write_table(
f"tables/att_{EXPERIMENT_ID}.tsv",
["lane", "estimator", "spec", "att", "ci_low", "ci_high", "experimental_att", "gap",
"n_treated", "n_controls_used", "max_weight_share", "reps", "bootstrap_seed"],
[{"lane": lane, "estimator": CELL["estimator"], "spec": CELL["spec"], "att": estimate.att,
"ci_low": low, "ci_high": high, "experimental_att": experimental,
"gap": estimate.att - experimental, "n_treated": estimate.n_treated,
"n_controls_used": estimate.n_controls_used, "max_weight_share": estimate.max_weight_share,
"reps": reps, "bootstrap_seed": lalonde.BOOTSTRAP_SEED}],
)
if not SMOKE:
print(f"artifact: {path.relative_to(lalonde.study_dir()).as_posix()}")
evaluate_estimate(
estimate.att, min(low, estimate.att), max(high, estimate.att), estimate.n_treated,
exp_id=EXPERIMENT_ID, metric_name="att_usd", metric_goal="higher", study_dir=".", t0=t0,
extra={"att_gap_usd": estimate.att - experimental, "experimental_att": experimental,
"n_controls_used": estimate.n_controls_used,
"max_weight_share": estimate.max_weight_share},
)
return
raise SystemExit(f"unknown track {TRACK!r}")
if __name__ == "__main__":
main()
The estimator library
The estimators live outside the mutable surface on purpose, so a cell's diff can never be "changed the estimator". Note the design choices: an unpenalised logit on standardised columns (a logit is invariant to rescaling), common support applied to comparison men only so the estimand stays the ATT over all 185 trainees, weight-concentration reported with every estimate, and a bootstrap that re-fits the score in each draw with a fixed seed.
lib/lalonde.py · current file at build (outside the mutable surface) · sha256 eb4d167f0c63…
"""Study 23's library: the published targets, the estimators, and the table writer.
Outside the mutable surface on purpose (AGENTS.md: library code changes rarely,
deliberately, never as part of a cell's diff). A cell in analyze.py only CHOOSES:
which lane, which estimator, which propensity specification.
Everything here is deterministic given the prepared table: unpenalized logits on
standardized columns (a logit is invariant to rescaling its regressors, so the
scores are the textbook ones), closed-form OLS, and a bootstrap with a fixed seed.
"""
from __future__ import annotations
import os
from collections.abc import Iterable, Mapping, Sequence
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
BOOTSTRAP_SEED = 20261103
# ------------------------------------------------------------------ published targets
#: Dehejia & Wahba (1999, JASA 94(448)) Table 3, columns (1) "unadjusted" and (2)
#: "adjusted" — identical in NBER working paper w6586 (1998), Table 3. 1982 dollars,
#: standard errors in parentheses there. Table 1 gives the sample sizes.
#: Column (2) is least squares of RE78 on a constant, the treatment indicator, age,
#: age^2, educ, nodegree, black, hisp, RE74, RE75 (Table 3 note a).
TARGETS: dict[str, dict[str, float]] = {
"development": {
"nsw_unadjusted": 1794, "nsw_unadjusted_se": 633,
"nsw_adjusted": 1672, "nsw_adjusted_se": 638,
"psid1_unadjusted": -15205, "psid1_unadjusted_se": 1154,
"psid1_adjusted": 731, "psid1_adjusted_se": 886,
"n_nsw_treated": 185, "n_nsw_control": 260, "n_psid1": 2490,
},
"final_test": {
"cps1_unadjusted": -8498, "cps1_unadjusted_se": 712,
"cps1_adjusted": 972, "cps1_adjusted_se": 550,
"n_cps1": 15992,
},
}
#: |reproduced - printed| allowed: the paper prints whole dollars, so +-1 covers its
#: rounding (0.5) and the float storage of 1982-dollar earnings in the .dta files.
TOLERANCE = 1.0
ADJUSTMENT = ["age", "age2", "education", "nodegree", "black", "hispanic", "re74", "re75"]
#: DIAGNOSTICS, never targets. Table 3's column (2) is not one regression: its NSW value
#: (1,672) equals Table 2 Panel C column (4) — note a's covariates — while its PSID-1 (731)
#: and CPS-1 (972) values equal Panel C column (5), "all pre-treatment covariates"
#: (found at the METHOD gate, method_card.md). The reproduction cell prints both
#: regressions beside the registered targets so the run shows which is which; the
#: column-(5) covariate list is not printed in the paper, so two readings are tried.
ADJUSTMENT_ALL = {
"all_married": ADJUSTMENT + ["married"],
"all_married_u": ADJUSTMENT + ["married", "u74", "u75"],
}
#: Table 2 Panel C, columns (4) and (5), for the diagnostics' comparison column.
PANEL_C = {
"nsw": {"col4": 1672, "col5": 1655},
"psid1": {"col4": 218, "col5": 731},
"cps1": {"col4": 739, "col5": 972},
}
#: Propensity specifications. `dw_psid` is Table 3 note c (the PSID-1 logit);
#: `no_re74` drops every 1974-earnings term (the DW 1999 section 5 / Smith & Todd 2005
#: sensitivity: is two years of pre-program earnings what makes it work?).
PROPENSITY: dict[str, list[str]] = {
"dw_psid": ["age", "age2", "education", "educ2", "married", "nodegree", "black", "hispanic",
"re74", "re75", "re74sq", "re75sq", "u74_black"],
"no_re74": ["age", "age2", "education", "educ2", "married", "nodegree", "black", "hispanic",
"re75", "re75sq", "u75"],
}
def features(frame: pd.DataFrame) -> pd.DataFrame:
"""The derived columns every specification draws from (all pre-treatment)."""
out = frame.copy()
out["age2"] = out["age"] ** 2
out["educ2"] = out["education"] ** 2
out["re74sq"] = out["re74"] ** 2
out["re75sq"] = out["re75"] ** 2
out["u74"] = (out["re74"] == 0).astype(int)
out["u75"] = (out["re75"] == 0).astype(int)
out["u74_black"] = out["u74"] * out["black"]
return out
# ------------------------------------------------------------------ least squares
def ols_treat(y: np.ndarray, t: np.ndarray, X: np.ndarray | None = None) -> tuple[float, float]:
"""Coefficient on t and its classical (homoskedastic) standard error."""
columns = [np.ones_like(t, dtype=float), t.astype(float)]
if X is not None:
columns += [X[:, j].astype(float) for j in range(X.shape[1])]
design = np.column_stack(columns)
beta, *_ = np.linalg.lstsq(design, y, rcond=None)
resid = y - design @ beta
dof = len(y) - design.shape[1]
sigma2 = float(resid @ resid) / dof
cov = sigma2 * np.linalg.inv(design.T @ design)
return float(beta[1]), float(np.sqrt(cov[1, 1]))
def diagnostics(treated: pd.DataFrame, comparison: pd.DataFrame) -> dict[str, float]:
"""The column-(5) candidates: OLS coefficient on treat under each ADJUSTMENT_ALL list."""
both = pd.concat([treated, comparison])
y = both["re78"].to_numpy(float)
t = both["treat"].to_numpy(int)
return {name: ols_treat(y, t, both[cols].to_numpy(float))[0] for name, cols in ADJUSTMENT_ALL.items()}
def contrast(treated: pd.DataFrame, comparison: pd.DataFrame) -> dict[str, float]:
both = pd.concat([treated, comparison])
y = both["re78"].to_numpy(float)
t = both["treat"].to_numpy(int)
unadj, unadj_se = ols_treat(y, t)
adj, adj_se = ols_treat(y, t, both[ADJUSTMENT].to_numpy(float))
return {"unadjusted": unadj, "unadjusted_se": unadj_se, "adjusted": adj, "adjusted_se": adj_se}
# ------------------------------------------------------------------ propensity estimators
@dataclass(frozen=True)
class Estimate:
att: float
n_treated: int
n_controls_used: int
max_weight_share: float # the largest single control weight / total control weight
def propensity(treated: pd.DataFrame, comparison: pd.DataFrame, spec: str) -> tuple[np.ndarray, np.ndarray]:
columns = PROPENSITY[spec]
both = pd.concat([treated, comparison])
X = StandardScaler().fit_transform(both[columns].to_numpy(float))
t = both["treat"].to_numpy(int)
model = LogisticRegression(penalty=None, max_iter=20000, tol=1e-10).fit(X, t)
score = model.predict_proba(X)[:, 1]
return score[: len(treated)], score[len(treated):]
def att(treated: pd.DataFrame, comparison: pd.DataFrame, *, estimator: str, spec: str) -> Estimate:
e1, e0 = propensity(treated, comparison, spec)
y1 = treated["re78"].to_numpy(float)
y0 = comparison["re78"].to_numpy(float)
# Common support, Table 3 note g: comparison units inside the treated score range.
keep = (e0 >= e1.min()) & (e0 <= e1.max())
e0k, y0k = np.clip(e0[keep], 1e-12, 1 - 1e-12), y0[keep]
if estimator == "match":
# 1-nearest-neighbour on the score, with replacement (Table 3 column 7's design).
order = np.argsort(e0k)
sorted_e = e0k[order]
pos = np.clip(np.searchsorted(sorted_e, e1), 1, len(sorted_e) - 1)
left, right = sorted_e[pos - 1], sorted_e[pos]
nearest = np.where(np.abs(e1 - left) <= np.abs(right - e1), pos - 1, pos)
matched = y0k[order][nearest]
counts = np.bincount(nearest, minlength=len(sorted_e))
return Estimate(float(np.mean(y1 - matched)), len(y1), int((counts > 0).sum()),
float(counts.max() / counts.sum()))
w = e0k / (1 - e0k) # ATT odds weights
share = float(w.max() / w.sum())
if estimator == "ipw":
return Estimate(float(y1.mean() - np.average(y0k, weights=w)), len(y1), int(keep.sum()), share)
if estimator == "aipw":
X0 = comparison.loc[keep, ADJUSTMENT].to_numpy(float)
design0 = np.column_stack([np.ones(len(X0)), X0])
beta, *_ = np.linalg.lstsq(design0, y0k, rcond=None)
mu1 = np.column_stack([np.ones(len(treated)), treated[ADJUSTMENT].to_numpy(float)]) @ beta
mu0 = design0 @ beta
return Estimate(float(np.mean(y1 - mu1) - np.average(y0k - mu0, weights=w)),
len(y1), int(keep.sum()), share)
raise ValueError(f"unknown estimator {estimator!r}")
def bootstrap(treated: pd.DataFrame, comparison: pd.DataFrame, *, estimator: str, spec: str,
reps: int) -> np.ndarray:
"""Percentile-bootstrap draws, resampling treated and comparison separately and
re-fitting the propensity model in every draw (the score is estimated, not given)."""
rng = np.random.default_rng(BOOTSTRAP_SEED)
draws = np.empty(reps)
for b in range(reps):
tb = treated.iloc[rng.integers(0, len(treated), len(treated))]
cb = comparison.iloc[rng.integers(0, len(comparison), len(comparison))]
draws[b] = att(tb, cb, estimator=estimator, spec=spec).att
return draws
# ------------------------------------------------------------------ pinned tables
def study_dir() -> Path:
return Path(__file__).resolve().parents[1]
def write_table(relative_path: str, columns: Sequence[str], rows: Iterable[Mapping[str, Any]]) -> Path:
"""Deterministic TSV (fixed columns, %.6f, LF); not written under KLEIN_SMOKE=1."""
path = study_dir() / relative_path
text = pd.DataFrame(list(rows), columns=list(columns)).to_csv(
index=False, sep="\t", float_format="%.6f", lineterminator="\n"
)
if os.environ.get("KLEIN_SMOKE") == "1":
return path
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8", newline="")
return path
No verifier script is declared for this study. The checker is the benchmark itself: the gap is computed in the same run from the experimental controls, and the registered rules read only that gap.
Analysis-pipeline advice, in order
- Name the estimand and get a benchmark if one exists at all: a randomised arm, a pilot, a known-null placebo outcome. Without the answer key nothing above could be judged.
- Cross-read every printed target against the paper's other tables before registering a replication (claim C14). Here that explained both reproduction refutations before any cell ran, so the anchor's STOP rule could tell a known inconsistency in the paper from a broken pipeline. Put the cross-reads in the cell as never-counted diagnostic rows.
- Print the weight-concentration pair with every weighting or matching estimate, the largest single weight share and the number of comparison units used, and read it before the point estimate (claim C15).
- Run more than one estimator on the same score and read the spread as uncertainty (claim C31).
- Write sensitivity predictions against the baseline cell, not the benchmark band (claim C13), and when a cell drops a covariate, drop only that covariate's terms and hold the support fixed, or report the support change beside the shift (claim C22).
- Say what your interval covers (claim C17). A bootstrap that re-fits the score but holds the experimental controls fixed is an interval for the estimate, not the gap, and for matching it is descriptive only. Treat a registered selection among estimators as a tie-break, not a ranking (claim C24).
- Call a same-seed re-run determinism (claim C27). The exact re-executions here show the pipeline is deterministic; they say nothing about robustness to other code, seeds or specifications.
War stories that bit this study
- A tool timeout is a driver bug, not a result. Give the driver's own timeout more room than the run's
max_run_secondsand set the cell before launching: two wrapper kills spent two of four estimator slots and forced a budget re-record (claim C18). - Never commit, cherry-pick or reset in a checkout where a run may be in flight. It removed a run's filed evidence commits and misnumbered the next cell; the repair is a recovery, not a routine (claim C19).
- Read the sealed rehearsal's exit code as a budget measurement. The first dry run timed out (exit 124), and the sealed cell later took longer than the old limit (claim C20). Launching at the old limit would most likely have spent the only sealed access on a timeout.
- A numeral in a name is still a numeral. The lock pins small integers so that names like PSID-1 and Table 3 have an alias, and those pins carry no measurement.
What to try next
- A registered placebo-outcome cell on both comparison groups: 1975 earnings as the outcome, the 1975 terms removed from the score, the same three estimators, and a rule of the form "placebo ATT within a registered band of zero". This tests the identification assumption that agreement with the benchmark cannot, and it is the single most informative next cell.
- A registered specification family as a measurement sweep: note c, note e (the CPS-specific logit), Dehejia-Wahba's Table 5 specification, and Smith-Todd variants, crossed with IPW, AIPW and matching, with a family-wise adjustment and a forest plot against the benchmark line. Add covariate balance after weighting and a cell that drops only the three 1974 terms with support held fixed.
- Fix the uncertainty and test the weight story directly: a bootstrap that also resamples the 260 experimental controls, the Abadie-Imbens variance for matching, and a pinned table of the top-weighted comparison men so the different-handfuls reading of the IPW and matching misses can be tested.
- Recover the missing covariate set and re-implement independently: a registered sweep over candidate covariate lists scored against the printed comparison values, or the JASA text as a second source; and a different-code, different-seed re-implementation so that "replicated" means robust, not only deterministic.
References
All eighteen entries were verified at the METHOD gate against Crossref or a publisher landing page (klein refs verify, none failed); none is promoted from unverified. Only the NBER working paper was read for Table 3 and its notes; the JASA article text was not accessed.
- LaLonde, R. J. (1986). Evaluating the Econometric Evaluations of Training Programs with Experimental Data. American Economic Review 76(4):604-620.
- Dehejia, R. H.; Wahba, S. (1999). Causal Effects in Nonexperimental Studies: Reevaluating the Evaluation of Training Programs. Journal of the American Statistical Association 94(448):1053-1062. doi:10.1080/01621459.1999.10473858
- Dehejia, R. H.; Wahba, S. (1998). Causal Effects in Non-Experimental Studies: Re-Evaluating the Evaluation of Training Programs. NBER Working Paper 6586. doi:10.3386/w6586
- Dehejia, R. H.; Wahba, S. (2002). Propensity Score-Matching Methods for Nonexperimental Causal Studies. Review of Economics and Statistics 84(1):151-161. doi:10.1162/003465302317331982
- Rosenbaum, P. R.; Rubin, D. B. (1983). The central role of the propensity score in observational studies for causal effects. Biometrika 70(1):41-55. doi:10.1093/biomet/70.1.41
- Smith, J. A.; Todd, P. E. (2005). Does matching overcome LaLonde's critique of nonexperimental estimators?. Journal of Econometrics 125(1-2):305-353. doi:10.1016/j.jeconom.2004.04.011
- Dehejia, R. (2005). Practical propensity score matching: a reply to Smith and Todd. Journal of Econometrics 125(1-2):355-364. doi:10.1016/j.jeconom.2004.04.012
- Abadie, A.; Imbens, G. W. (2006). Large Sample Properties of Matching Estimators for Average Treatment Effects. Econometrica 74(1):235-267. doi:10.1111/j.1468-0262.2006.00655.x
- Abadie, A.; Imbens, G. W. (2008). On the Failure of the Bootstrap for Matching Estimators. Econometrica 76(6):1537-1557. doi:10.3982/ECTA6474
- Abadie, A.; Imbens, G. W. (2016). Matching on the Estimated Propensity Score. Econometrica 84(2):781-807. doi:10.3982/ECTA11293
- Imbens, G. W. (2004). Nonparametric Estimation of Average Treatment Effects Under Exogeneity: A Review. Review of Economics and Statistics 86(1):4-29. doi:10.1162/003465304323023651
- Imbens, G. W. (2015). Matching Methods in Practice: Three Examples. Journal of Human Resources 50(2):373-419. doi:10.3368/jhr.50.2.373
- Robins, J. M.; Rotnitzky, A.; Zhao, L. P. (1994). Estimation of Regression Coefficients When Some Regressors are not Always Observed. Journal of the American Statistical Association 89(427):846-866. doi:10.1080/01621459.1994.10476818
- Bang, H.; Robins, J. M. (2005). Doubly Robust Estimation in Missing Data and Causal Inference Models. Biometrics 61(4):962-973. doi:10.1111/j.1541-0420.2005.00377.x
- Sant'Anna, P. H. C.; Zhao, J. (2020). Doubly robust difference-in-differences estimators. Journal of Econometrics 219(1):101-122. doi:10.1016/j.jeconom.2020.06.003
- Kang, J. D. Y.; Schafer, J. L. (2007). Demystifying Double Robustness: A Comparison of Alternative Strategies for Estimating a Population Mean from Incomplete Data. Statistical Science 22(4):523-539. doi:10.1214/07-STS227
- Crump, R. K.; Hotz, V. J.; Imbens, G. W.; Mitnik, O. A. (2009). Dealing with limited overlap in estimation of average treatment effects. Biometrika 96(1):187-199. doi:10.1093/biomet/asn055
- Imbens, G. W.; Xu, Y. (2025). Comparing Experimental and Nonexperimental Methods: What Lessons Have We Learned Four Decades after LaLonde (1986)?. Journal of Economic Perspectives 39(4):173-201. doi:10.1257/jep.20251440