Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6be470b
test(efficient_did): a re-capture routine for the EfficientDiD arms o…
igerber Nov 28, 2026
c476ceb
fix(efficient_did): stack one never-treated moment under PT-All
igerber Nov 28, 2026
37afd17
test(efficient_did): report fixture movement per row in SE units
igerber Nov 28, 2026
3e6022f
fix(efficient_did): centre covariate-path scores on (G_g/pi_g) ATT, a…
igerber Nov 28, 2026
804adb8
fix(efficient_did): drop a cohort with no pre-treatment period under …
igerber Nov 28, 2026
3359d8d
test(efficient_did): re-baseline the EfficientDiD arms of the aggrega…
igerber Nov 28, 2026
f596104
docs(efficient_did): record the three corrections; a seeded script fo…
igerber Nov 28, 2026
08e06dc
fix(efficient_did): integer period and cohort labels stay integers, s…
igerber Nov 28, 2026
480424a
fix(efficient_did): the Hausman pretest takes its variance from the p…
igerber Nov 28, 2026
8b76ca0
fix(efficient_did): normalise label dtypes on entry; the Hausman pret…
igerber Nov 28, 2026
f1e18a8
fix(efficient_did): reconcile the two label columns jointly; the Haus…
igerber Nov 28, 2026
86b8400
fix(efficient_did): scores at floating-point roundoff give NaN infere…
igerber Nov 28, 2026
c992b11
fix(efficient_did): roundoff guard on bootstrap aggregates and weight…
igerber Nov 28, 2026
e3dd516
fix(efficient_did): gate the reported standard error for roundoff; ve…
igerber Nov 28, 2026
35d5f0f
fix(efficient_did): label check tests decisions, not bit-exactness; H…
igerber Nov 28, 2026
ccd0ede
fix(efficient_did): label arithmetic on exact numbers, through shared…
igerber Nov 28, 2026
e197758
fix(efficient_did): aggregate('total') counts the cells its ATT was b…
igerber Nov 28, 2026
08eea6f
fix(efficient_did): a saved result's total recovers its cell set from…
igerber Nov 28, 2026
363d4d8
fix(efficient_did): a saved result's cell set must reproduce its stor…
igerber Nov 28, 2026
06214f9
fix(efficient_did): a saved result's total reconstructs the historica…
igerber Nov 28, 2026
b744c50
fix(efficient_did): a saved result's total is computed only when its …
igerber Nov 28, 2026
46657eb
fix(efficient_did): the saved-result guard requires every label to su…
igerber Nov 30, 2026
f24698e
docs(efficient_did): the saved-result recovery's docstring and error …
igerber Nov 30, 2026
d08acd8
test(efficient_did): the mixed-precision saved-result test goes throu…
igerber Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions METHODOLOGY_REVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,16 @@ and covariate-adjusted specifications.)
| Primary Reference | Chen, Sant'Anna & Xie (2025), *Efficient Difference-in-Differences and Event Study Estimators* |
| R Reference | (no canonical R package; paper compares against `did` / `DIDmultiplegt` / BJS / Gardner / Wooldridge as benchmarks rather than providing a reference implementation) |
| Status | **Complete** |
| Last Review | 2026-06-01 |
| Last Review | 2026-11-27 (corrections; first review 2026-06-01) |

**Documentation in place:**
- REGISTRY.md section: `## EfficientDiD` (full Theorem 4.1 EIF, sieve-based propensity-ratio and outcome-regression estimation with AIC/BIC, kernel-smoothed conditional covariance, Hausman pretest for PT-All vs PT-Post, survey support)
- Paper review on file: `docs/methodology/papers/chen-santanna-xie-2025-review.md` (PR-A, 2026-05-31) — faithful paper-sourced transcription of arXiv:2506.17729v1 (assumptions S/O/NA/PT-Post/PT-All; Theorem 3.1/3.2 EIFs + Corollaries 3.1/3.2; §4 sieve/kernel DR estimation; Theorem 4.1 SEs; Theorem A.1 Hausman; HRS Table 6 anchor)
- Tests: `tests/test_efficient_did.py` (unit/API), `tests/test_efficient_did_validation.py` (HRS Table 6 + Compustat MC), and `tests/test_methodology_efficient_did.py` (PR-B paper-equation Verified Components)

**Corrections Made (PR-B source validation):** (None — implementation verified correct.) The PR-B walk-through traced each paper result against the source and found the no-covariate path (multi-baseline efficiency recovered via the `g'=g` same-cohort pairs), the generated outcome (Eq 3.9), the optimal weights (Eq 3.5/3.13), the conditional covariance Ω*(X) (Eq 3.12), the analytical SE (Theorem 4.1), the cohort-size event-study aggregation (with the `(G_g − π_g)` WIF correction), and the Hausman covariance direction (Eq A.2, restricted − efficient) all correct.
**Corrections Made (PR-B source validation):** none at the time. Three defects found on 2026-11-27 are recorded in the next paragraph. The PR-B walk-through traced each paper result against the source and found the no-covariate path (multi-baseline efficiency recovered via the `g'=g` same-cohort pairs), the generated outcome (Eq 3.9), the optimal weights (Eq 3.5/3.13), the conditional covariance Ω*(X) (Eq 3.12), the analytical SE (Theorem 4.1), the cohort-size event-study aggregation (with the `(G_g − π_g)` WIF correction), and the Hausman covariance direction (Eq A.2, restricted − efficient) all correct.

**Corrections Made (2026-11-27, found while reviewing the EfficientDiD tutorial):** three defects the PR-B pass did not catch. (1) *Never-treated moments under PT-All.* The library stacked one `(∞, t_pre)` moment per baseline and applied Eq 3.12 to them; they are the same moment (their two never-treated terms telescope) and Eq 3.12 omits the cross-covariance between those terms, so `Ω*` was wrong, the PT-All weights were not the efficient ones, and the Hausman pretest was miscalibrated (null statistic mean 0.667, 1.7% rejections at the 5% level). The estimator now stacks the single pair `(∞, period_1)`, for which Eq 3.12 is exact. The PR-B check of Eq 3.12 compared the code with the printed formula, not with the covariance of the moments the library actually stacks. (2) *Covariate-path influence function.* Scores were centred on the scalar ATT where Eq 3.10 subtracts `(G_g/π_g) ATT(g,t)`, adding `ATT² (1−π_g)/π_g` to the variance, so covariate-path standard errors grew with the size of the effect (noiseless panel, ATT 2: SE 0.1414 where 0 is correct). (3) *Cohorts with no pre-treatment period* were estimated silently under PT-All; they are now dropped with a warning, as under PT-Post. Label arithmetic (relative times, baseline lookups) is now done on exact numbers through shared `utils` helpers; native arithmetic wrapped for unsigned labels, merged cohorts above `2**53` and could match a baseline to a period it was not equal to. (4) *Hausman pretest.* Both sides now aggregate only the cells both fits estimate (PT-Post drops a cohort PT-All keeps when periods have gaps), and the variance of `ES_post - ES_all` is estimated from the paired influence-function differences (the paper's footnote-21 alternative) instead of as the difference of the two covariances, which is that variance only under exact efficiency: with nearly collinear periods the default ridge made the printed form return a statistic averaging 0.20 with no rejections on null panels (paired form: 0.99, 4.6%). (5) *Roundoff scores.* On a panel with no sampling variation the scores are floating-point residue and the SE came out near 1e-17 with a meaningless p-value; every reported standard error is now tested against the outcome scale (SE 0 analytically, NaN under the bootstrap, NaN inference) through the shared `utils.se_is_roundoff`. See the EfficientDiD Notes in `docs/methodology/REGISTRY.md` and `TestNeverTreatedMoment`, `TestHausmanCalibration`, `TestCovariateScoreCentring` and `TestCohortWithoutPreTreatmentPeriod`.

**Implementation change (deliberate, decided with the maintainer — eliminates a deviation rather than fixing a bug):**
- Covariate outcome regression upgraded from linear OLS to a **polynomial sieve** (AIC/BIC order selection, same basis family as the propensity-ratio sieve; a *growing* sieve with no fixed order ceiling — `floor(n_pos^{1/5})` over the positive-weight support `n_pos` (raw group size when unweighted; zero-weight survey rows are inert for order selection), bounded by `n_basis < n_pos` — which, since C.1's rate is on the sieve *dimension* `p_K = comb(K+d,d)` (not the polynomial degree, which differ once `d > 1`), satisfies Assumption C.1's uniform-consistency / `o_p(n^{-1/2})` product-rate conditions for the low-dimensional covariate settings typical of DiD) so the doubly-robust covariate path attains the semiparametric efficiency bound asymptotically under the paper's nonparametric-nuisance specification (Section 4 / Theorem 4.1), not only when the conditional mean is linear. Degree 1 reproduces the prior linear OLS *outcome regression*; `sieve_k_max=1` forces all covariate-path sieves to degree 1 (it recovers the linear outcome component but also degree-1-constrains the propensity sieves, so it does **not** reproduce the exact pre-PR estimator). Removing the hard `K≤5` cap also updates the two pre-existing propensity-ratio / inverse-propensity sieves (a no-op for groups under ~3,125 units). `diff_diff/efficient_did_covariates.py::estimate_outcome_regression`.
Expand All @@ -712,17 +714,19 @@ and covariate-adjusted specifications.)
**Verified Components** (`tests/test_methodology_efficient_did.py`, paper-equation-numbered):
- [x] Inverse-covariance optimal weights `1'Ω*⁻¹/(1'Ω*⁻¹1)` (Eq 3.5 / 3.13) + the min-variance property + the singular-Ω* pseudoinverse path.
- [x] No-covariate generated outcome (Eq 3.9): `g'=g` telescopes to the per-baseline DiD (Eq 3.3); `g'=∞` to the period-1 long-difference.
- [x] One never-treated moment under PT-All: `Ω*` from every builder equals the covariance of each group's complete per-unit score vector (no-covariate loop and Gram forms at 1e-12; conditional dense and tiled forms at 1e-9), and the efficient weights on a long and a short DiD with iid errors are one half each.
- [x] Covariate-path influence function (Eq 3.10): zero SE on a noiseless constant-effect panel, SEs invariant to the size of the effect, and PT-Post agreement with Callaway-Sant'Anna's doubly robust SE.
- [x] No-covariate efficient ATT = `weights @ generated_outcomes` (Eq 3.13 / §4.1), rebuilt independently from within-group sample means/covariances.
- [x] PT-Post just-identified reduction = Callaway-Sant'Anna single-baseline (Corollary 3.1 single-date exact at 1e-9; Corollary 3.2 staggered).
- [x] Analytical SE = `sqrt(mean(EIF²)/n)` (Theorem 4.1).
- [x] Hausman statistic (Theorem A.1 / Eq A.2): `H = Δ'V⁺Δ`, `V = aCov(ẼS) − aCov(ÊS)` (restricted − efficient); `df = |E|` (well-conditioned) and `df = effective_rank < |E|` (rank-deficient safeguard); covariance-direction guard.
- [x] Hausman statistic (Theorem A.1 / Eq A.2): `H = Δ'V⁺Δ` with `V` the variance of the contrast `Δ = ẼS − ÊS`, estimated from the paired influence-function differences (equal to the theorem's `aCov(ẼS) − aCov(ÊS)` under exact efficiency; REGISTRY Hausman Note); `df = |E|` (well-conditioned) and `df = effective_rank < |E|` (horizons at which the two fits coincide). Null size measured in `TestHausmanCalibration` (plain, nearly collinear periods, clustered).
- [x] Covariate sieve outcome regression: recovers a nonlinear-in-X conditional mean (K≥2), reproduces linear OLS on linear data (K=1), and beats a forced-linear working model under a nonlinear-nuisance conditional-PT DGP.
- [x] Empirical anchor: HRS Table 6 (`tests/test_efficient_did_validation.py::TestHRSReplication`) on the paper's data (a derived openICPSR 116186 subset) matches all six ATT(g,t) + ES(0)/ES(1)/ES(2) + ES_avg to < 0.03 published SE; the Compustat MC confirms unbiasedness, the CS efficiency gain, coverage, and SE calibration.
- [x] Empirical anchor: HRS Table 6 (`tests/test_efficient_did_validation.py::TestHRSReplication`) on the paper's data (a derived openICPSR 116186 subset) matches all six ATT(g,t) + ES(0)/ES(1)/ES(2) + ES_avg to within 0.002 published SE (asserted at 0.01); the Compustat MC confirms unbiasedness, the CS efficiency gain, coverage, and SE calibration.

**Deviations (ratified; each carries a recognized REGISTRY label):**
- `overall_att` is the cohort-size-weighted post-treatment average (Callaway-Sant'Anna convention), not the paper's uniform `ES_avg` (Eq 2.3); `ES_avg` is recoverable from the event-study output.
- The multiplier bootstrap re-aggregates with fixed cohort-size weights (matching the CS bootstrap); the analytical path carries the `(G_g − π_g)` WIF weight-estimation correction.
- The Hausman χ² uses the effective rank of `V` as degrees of freedom (a finite-sample safeguard equal to `|E|` when `V` is well-conditioned), rather than a fixed `|E|`.
- The Hausman χ² uses the effective rank of `V` as degrees of freedom (equal to `|E|` when `V` is well-conditioned), rather than a fixed `|E|`, and estimates `V` from paired influence-function differences rather than as a difference of covariances. On staggered designs the pretest is conservative (REGISTRY Hausman Note; `TODO.md`).
- `vcov_type` is permanently narrow to `{"hc1"}` (the IF-based variance has no single design matrix for analytical-sandwich families); the polynomial sieve basis and the Silverman kernel bandwidth are working-model choices the paper leaves open.
- SEs are i.i.d.-asymptotics (`sqrt(mean(EIF²)/n)` or multiplier bootstrap); cluster/survey EIF variants are documented library extensions beyond the paper's stated scope.

Expand Down
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Related tracking surfaces:
| No public idiom for a static staggered TWFE with a time-varying covariate (`Y ~ D_it + X_it` with unit and calendar fixed effects): `TwoWayFixedEffects.fit` is 2x2-shaped in static mode and `decompose()` takes no covariates, so tutorial 33's "include the bad control" benchmark builds it from `within_transform` plus `solve_ols`. Either document that route as the supported one or add a staggered static mode. | `twfe.py`, `docs/tutorials/33_bad_controls.ipynb` | 4.0 tutorial review | Mid | Low |
| `SyntheticDiD` Frank-Wolfe convergence on an ordinary panel (tutorial 03: 3 treated and 40 control units, 14 periods, outcomes 30-80, noise sd 0.5): (1) `variance_method="bootstrap"` warns "Frank-Wolfe did not converge on 199 of 199 valid bootstrap draws" on the Rust backend, so the refit bootstrap cannot be shown warning-free and the tutorial demonstrates placebo and jackknife only; (2) on the pure-Python backend the placebo and jackknife fits warn "Frank-Wolfe SC weight solver did not converge in 100 iterations" and "... in 10000 iterations" where the Rust backend is silent on the same data and returns the same ATT. Establish whether the iteration cap or tolerance is too tight for refits, and why the two backends differ in what they report. Same family as the tutorial-18 row below. | `synthetic_did.py`, `utils.py`, `rust/src/` | 4.0 tutorial review | Mid | Low |
| `PreTrendsPower().fit(results)` with the default `M=None` evaluates power at the MDV itself, where it equals the target up to the integration error of the NIS box probability (`scipy.stats.multivariate_normal.cdf`, randomised Genz integration, about 1e-6, unseeded). `PreTrendsPowerResults.power_adequate` is `power >= target_power` with no tolerance, so on identical calls it comes out True or False at random (tutorial-07 panel: True in 14 of 30 fits, power 0.799991 to 0.800007), and `summary()` prints either "Power (80%) meets target" or "Power (80%) below target. Would need violations of 0.208" for the same fit. The MDV and every NIS power also jitter at that scale. Compare with a tolerance no smaller than the integration error (or treat the at-MDV evaluation as adequate by construction), and seed the integration so repeated calls agree. The Wald form is deterministic and unaffected. | `pretrends.py` | 4.0 tutorial review | Quick | Medium |
| `EfficientDiD(omega_ridge=0)` keeps the degenerate pre-treatment self-pair `(g'=g, t_pre=t)` that the default ridge path drops, so every pre-treatment cell goes through the pseudoinverse with an infinite condition number (12 of 27 cells on a 300-unit, 10-period panel) and a per-cell warning. It was kept so that `omega_ridge=0` reproduced the pre-ridge path bit for bit; that path no longer exists as such (the never-treated moment set changed), so the pair can be dropped on both paths. Decide, then re-measure the placebo cells and update the ridge Note. | `diff_diff/efficient_did.py` | EfficientDiD correctness PR | Quick | Low |
| `EfficientDiD.hausman_pretest` on staggered designs: the multi-horizon pretest is conservative and does not converge to nominal size. The contrast is nearly the same at several horizons of a cohort, the variance of the contrast is close to singular, and `df` counts those directions (null simulation, seven periods, cohorts at 3 and 5: mean H/df 0.85 and 3.0% rejections at the 5% level with 80 units per group, 0.80 and 3.2% with 300). Derive a rank-revealing `df` (an eigenvalue threshold tied to the sampling order, or testing a reduced set of contrasts), validate its size and power, and record it as a REGISTRY Note. | `diff_diff/efficient_did.py` | EfficientDiD correctness PR | Mid | Medium |
| Adopt the shared roundoff guard in the other influence-function estimators. `EfficientDiD` passes every standard error it reports through `diff_diff.utils.se_is_roundoff` (`se * sqrt(n)` at roundoff relative to `outcome_scale(y, weights)` gives SE 0 analytically, NaN under the bootstrap, and NaN inference, at the cell and aggregate levels). The others still return a roundoff SE that passes `safe_inference`'s `se > 0` check (noiseless panel, true effect 0: `CallawaySantAnna` SE 1e-17, `ImputationDiD` SE 2e-12 with p = 1.5e-23). Follow the recipe in the helper's docstring per estimator, in one PR; `ImputationDiD` and other iterative solvers need their own `rtol` (their numerical error is the solver tolerance, not machine roundoff), measured the way `EfficientDiD`'s was; pin each with a noiseless zero-effect panel and a small-noise panel that keeps its inference. | `diff_diff/utils.py`, `diff_diff/staggered.py`, `diff_diff/imputation.py`, `diff_diff/sun_abraham.py`, `diff_diff/two_stage.py`, `diff_diff/triple_diff.py` | EfficientDiD correctness PR | Mid | Medium |
| Label arithmetic outside `EfficientDiD`. `EfficientDiD` computes every label difference and cross-column comparison (relative time, baseline lookup, pre-treatment comparison) on exact numbers through `diff_diff.utils.exact_label` / `label_minus` / `event_time_bucket` / `matching_period`, because native arithmetic wraps for unsigned labels, rounds for integer labels above `2**53` or for large and fractional floats, and depends on the order of subtraction (probes before the fix: ATT 1.624 with `uint64` labels against 0.639 with `int64`; 1.31 against 1.89 after shifting every label by `2**53`). The other staggered estimators do the same native arithmetic and have not been audited: fit each on `uint64`-labelled, `2**53`-shifted and decimal-labelled copies of a panel with `anticipation > 0`, compare with the plain `int64` fit, and move the arithmetic to the shared helpers wherever they differ. | `diff_diff/utils.py`, `diff_diff/staggered.py`, `diff_diff/sun_abraham.py`, `diff_diff/imputation.py`, `diff_diff/two_stage.py`, `diff_diff/stacked_did.py`, `diff_diff/wooldridge.py` | EfficientDiD correctness PR | Mid | Medium |

### Performance

Expand Down
Loading
Loading