Conversation
Implement the Two-Stage DiD estimator from Gardner (2022), matching the R `did2s` package. Stage 1 estimates unit+time fixed effects on untreated observations; Stage 2 regresses residualized outcomes on treatment indicators. Point estimates are identical to ImputationDiD; the key contribution is a GMM sandwich variance estimator (Newey & McFadden 1994) that accounts for first-stage estimation error. - TwoStageDiD class with static, event study, and group aggregation - Custom GMM sandwich variance (cannot reuse compute_robust_vcov) - Multiplier bootstrap on GMM influence function - 51 tests including equivalence tests with ImputationDiD - Full documentation: README, REGISTRY, CLAUDE.md, ROADMAP Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Overall assessment: Executive summary:
Methodology
Code Quality
Performance
Maintainability
Tech Debt Security Documentation/Tests
Tests not run (review only). |
- Always-treated warning now lists affected unit IDs (truncated at 10) - Bootstrap handles NaN y_tilde: masks NaN obs in static, event study, and group bootstrap paths; returns None when all treated obs are NaN - balance_e warns when no cohorts qualify instead of silently falling back - Add 3 edge case tests and REGISTRY.md update 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
|
Address PR review round 2: - [P1] Add n_obs==0 early check in _stage2_event_study and _stage2_group to produce NaN inference for zero-observation horizons/cohorts - [P2] Fix REGISTRY.md bootstrap weight type (Rademacher only, not Rademacher/Mammen/Webb) - [P2] Add tests for zero-observation event study horizons and group effects from NaN y_tilde filtering 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
Suggested next steps
|
Distinguish Prop 5 horizons (treated obs exist, counterfactual unidentified) from zero-observation horizons. Prop 5 horizons get n_obs > 0 with NaN inference and a warning, matching ImputationDiD behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: ✅ Looks good Executive summary:
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Tests not run (review only). |
Summary
TwoStageDiDestimator implementing Gardner (2022) two-stage differences-in-differencesImputationDiD(verified to machine precision ~1e-16)compute_robust_vcovbecause correction term uses GLOBAL cross-momentdid2s)Methodology references (required if estimator / math changes)
did2s::did2s()(Kyle Butts & John Gardner)(X'_{10} X_{10})^{-1}in GMM variance (matching R source code), not per-cluster inverse from paper Eq. 6Validation
tests/test_two_stage.py— 51 tests in 7 classes (basic, equivalence, variance, edge cases, parameters, bootstrap, convenience)ImputationDiDwithin ~1e-16; GMM SEs differ from conservative SEs (ratio ~1.27)generate_staggered_data(n_units=200, n_periods=10)produces expected resultsSecurity / privacy
Generated with Claude Code