Add Borusyak-Jaravel-Spiess (2024) Imputation DiD estimator#141
Add Borusyak-Jaravel-Spiess (2024) Imputation DiD estimator#141
Conversation
Implement ImputationDiD, the efficient imputation estimator for staggered DiD from Borusyak, Jaravel & Spiess (2024) "Revisiting Event-Study Designs: Robust and Efficient Estimation", Review of Economic Studies. Core features: - Three-step estimation: OLS on untreated → impute counterfactuals → aggregate - Conservative clustered variance (Theorem 3) with configurable auxiliary model partition (cohort_horizon, cohort, horizon) - Event study and group aggregation with balance_e and horizon_max options - Pre-trend test (Equation 9) independent of treatment effect estimation - Proposition 5: NaN for unidentified long-run effects without never-treated - Optional multiplier bootstrap for consistency with other staggered estimators - Covariate support via within-transformation Includes 54 tests, API docs, tutorial notebook, R benchmark scripts, methodology registry entry, and README/ROADMAP/CLAUDE.md updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Overall Assessment: ⛔ Blocker Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
…ring - Fix 1 (P0): Replace one-pass demeaning with iterative Gauss-Seidel for exact FE on unbalanced panels (add _iterative_fe helper) - Fix 2 (P0): Use v_it-weighted tau_tilde_g in auxiliary residuals per Eq 8 - Fix 3 (P1): Add rank-condition checks after Step 1, fix fillna(0.0)->NaN consistency in auxiliary residuals, handle NaN in v*eps product - Fix 4 (P1): Bootstrap generates weights per cluster_var (not always unit), add cluster column validation - Fix 5 (P2): plot_event_study detects reference via n_obs==0 (ImputationDiD) - Fix 6 (P3): Use scipy.sparse for FE dummy matrices in covariate v_it - Fix 7: Add 6 new tests, update REGISTRY.md edge cases and docstrings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: Executive summary:
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
…tstrap balance_e - Extract _iterative_demean as static method; fix _pretrend_test to use iterative demeaning (exact for unbalanced panels) instead of one-pass - Overall ATT SE: zero-weight NaN tau_hat observations so variance matches the finite-only ATT estimand; guard n_valid==0 returning NaN SE - Extract _compute_balanced_cohort_mask helper; apply in bootstrap event-study loop so bootstrap SEs respect balance_e filtering - Add 4 new tests covering all three fixes - Update REGISTRY.md edge cases documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/ai-review |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: Executive summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
…putationDiD Emit UserWarning when first_treat varies within a unit, which violates the absorbing treatment assumption. The estimator proceeds but warns users that results may be unreliable. Adds test and REGISTRY.md documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: Executive summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
…riance, weight/covariate fixes - Fix bootstrap to use Theorem 3 influence function (psi_i = sum_t v_it * epsilon_tilde_it) instead of perturbing raw tau_hat, correctly accounting for first-stage estimation error - Add sparse solver (spsolve) for variance normal equations to avoid O(p^2) memory blow-up, with dense lstsq fallback - Exclude rank-deficient covariates from variance design matrices A_0/A_1 via kept_cov_mask - Renormalize treatment_effects weights: 0 for NaN tau_hat, 1/n_valid for finite - Add 6 new tests: zero-noise bootstrap SE, sparse solver, dense fallback, weight consistency, rank-deficient covariates, bootstrap precomputation failure warning - Update REGISTRY.md edge cases documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment:
|
…riods _compute_balanced_cohort_mask had two bugs preventing pre-treatment balance checking: (1) required_range filtered from post-treatment-only all_horizons, missing negative values; (2) cohort horizons were built from Omega_1 (post-treatment), so negative rel_times were never seen. Fix: add _build_cohort_rel_times() to scan the full panel, and use range(-balance_e, max_h+1) for the required set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment
Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
Summary
ImputationDiDestimator: the efficient imputation approach for staggered DiD from Borusyak, Jaravel & Spiess (2024)Methodology references (required if estimator / math changes)
Validation
tests/test_imputation.py(54 tests covering basic fit, aggregation modes, variance estimation, pre-trend test, bootstrap, cross-validation vs CS/SA, edge cases)docs/tutorials/11_imputation_did.ipynb, R benchmark scripts atbenchmarks/R/benchmark_didimputation.RSecurity / privacy
Generated with Claude Code