Add pre-period event study coefficients to ImputationDiD and TwoStageDiD#252
Conversation
|
Overall Assessment ⛔ Blocker The conceptual Executive Summary
Methodology
No other unmitigated methodology deviations found. The intended BJS/Gardner extensions are documented in docs/methodology/REGISTRY.md:L839-L850 and docs/methodology/REGISTRY.md:L941-L946. Code Quality No additional findings beyond the blocker above. Performance No new performance findings in the changed code. Maintainability
Tech Debt No deferrable finding mitigates the blocker. This issue is not tracked in Security No findings. Documentation/Tests
Execution note: I could not run the test file in this environment because Path to Approval
|
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment The prior ImputationDiD non-default-index blocker appears fixed, but this re-review still has one unmitigated P1: Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ⛔ Blocker The previous source-material concern appears resolved: Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Executive Summary
Methodology At a high level, the estimator choices are aligned with the cited sources: BJS Test 1 estimates Equation 9 by OLS on untreated observations only and explicitly says those coefficients can be used for event-study plots, while Gardner’s event-study extension amends the second stage to regress residualized outcomes on lead and duration indicators and keeps GMM-based asymptotics for valid SEs. I did not find a new paper-level mismatch in the
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Executive Summary
Methodology BJS Test 1 estimates lead coefficients by OLS on untreated observations only and explicitly notes that those coefficients can be used for event-study plots; Gardner’s two-stage approach estimates fixed effects on untreated observations first and extends to event-study analyses of pre-trends and duration-specific effects. Against that benchmark, I do not see a new paper-level mismatch in
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
I could not execute Path to Approval
|
Add pretrends=True parameter to both estimators. When enabled, event study includes pre-treatment horizons (should be ~0 under parallel trends) for visual pre-trends assessment, matching CallawaySantAnna and StackedDiD. ImputationDiD: computes tau_hat for pre-treatment observations of eventually-treated units, aggregates by relative time, uses extended Theorem 3 variance (pre-period targets contribute both directly and via FE correction). TwoStageDiD: extends Stage 2 design matrix with pre-period dummies; GMM sandwich handles naturally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ression P0: Bootstrap pre-period path now uses same union of pre+post horizons for balance_e cohort filtering as the analytical path. Previously used pre-only horizons which could include different cohorts. P1: Moved untreated_units/untreated_times initialization before the survey_weights_0 branch in _compute_cluster_psi_sums, fixing a regression where the survey-weighted FE-only variance path would crash. P2: Added regression tests for survey-weighted, covariates + pretrends, and balance_e + bootstrap combinations. Added pretrends parameter to public docstrings for both estimators. P3: Removed dead pre_tau_hat variable in bootstrap path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace label-based df_pre.index[h_mask_pre] with positional np.where(omega_pre_mask.values)[0][h_mask_pre] in both analytical and bootstrap paths. The previous code used DataFrame labels as positional array indices, which corrupts pre-period SEs/CIs when users pass DataFrames with non-default index (gapped, permuted, or filtered). Add regression tests verifying identical inference across RangeIndex, permuted, and gapped index types for both analytical and bootstrap paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address CI review P1: replace placebo-style residual averages with BJS Test 1 lead regression (Equation 9). Pre-period coefficients now come from within-transformed OLS on Omega_0 with cluster-robust SEs, consistent with pretrend_test(). This matches the cited methodology. - Add _compute_lead_coefficients() helper reused by both _pretrend_test() and _aggregate_event_study() - Remove placebo machinery: preperiod_weights, auxiliary residuals for pre-periods, covariate projection for pre-periods - Bootstrap no longer updates pre-period SEs (they come from lead regression) - Update REGISTRY.md to reference Test 1 / Equation 9 - Replace cross-estimator parity test with contract test against pretrend_test().lead_coefficients Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
P0: Raise NotImplementedError when pretrends=True + survey_design (lead regression is not yet survey-aware, matching pretrend_test() behavior). P1: Thread balance_e through pre-period lead regression by filtering Omega_0 to balanced cohorts before computing leads. Handle rank-deficient lead regression gracefully (returns NaN effects). P1: Add regression tests for pretrends + survey_design (NotImplementedError), pretrends + balance_e, and TwoStageDiD pretrends + bootstrap. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ead indicators P1: balance_e pre-period path was dropping never-treated controls from Omega_0 before the lead regression. Now keeps the full untreated sample for within-transformation and restricts only which cohorts' lead indicators are activated (via balanced_cohorts parameter to _compute_lead_coefficients). P1: Add **Note:** in REGISTRY.md documenting pretrends + survey_design NotImplementedError. Fix error message to not suggest pretrend_test(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When no cohort satisfies balance_e, skip pre-period coefficient generation entirely instead of falling back to unrestricted leads. Also fix n_obs to use the lead indicator (which respects balanced_cohorts restriction) instead of the unrestricted relative-time count. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0684ad4 to
0b65daa
Compare
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good — no unmitigated P0/P1 findings in the changed estimator, variance, or bootstrap paths. Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
Version bump covering silent warning audit (#256), replicate weight expansion (#253), and imputation pre-period coefficients (#252). Adds Phase 8 survey maturity roadmap (SDR, FPC expansion, lonely PSU, CV, weight trimming, compatibility matrix). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
pretrends: bool = Falseparameter to bothImputationDiDandTwoStageDiDMethodology references (required if estimator / math changes)
Validation
tests/test_pretrends_event_study.py(22 tests covering both estimators, cross-estimator consistency, edge cases, and regression tests for survey/covariates/bootstrap paths)Security / privacy
Generated with Claude Code