Rewrite TripleDifference to match R's triplediff::ddd()#169
Conversation
…SE match) Replace naive cell-mean DDD with three-DiD decomposition from Ortiz-Villavicencio & Sant'Anna (2025), matching the official R companion package triplediff::ddd(). All 3 methods (DR, IPW, RA) now use pairwise DiD comparisons with influence function-based SE, achieving <0.001% relative difference from R across all 4 DGP types, with and without covariates. Key changes: - Decompose DDD into DiD_3 + DiD_2 - DiD_1 (three pairwise comparisons) - SE via combined influence function: std(w3*IF_3 + w2*IF_2 - w1*IF_1)/sqrt(n) - Per-comparison propensity scores and outcome regressions - Add 91 methodology verification tests (hand calc, R comparison, edge cases) - Add R/Python benchmark scripts and pre-computed R results (panel=FALSE) - Update METHODOLOGY_REVIEW.md and REGISTRY.md with verified status Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Overall assessment: Executive Summary
Methodology
Code Quality Performance Maintainability Tech Debt Security Documentation/Tests
|
Path(__file__) resolves to temp dir under pytest-xdist workers. Use diff_diff.__file__ to find repo root instead. Also skip gracefully when R DGP CSV files (gitignored) aren't available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ell warning - Make `cluster` param functional with Liang-Zeger cluster-robust SE on influence function; document `robust` as no-op (IF-based SEs inherently heteroskedasticity-robust) - Fix `rank_deficient_action` for "warn"/"silent" by replacing np.linalg.lstsq with solve_ols() in _fit_predict_mu() and R-squared computation - Add low cell count warning (<10 obs) in _validate_data() - Update module/class docstrings to reflect current implementation - Add 5 tests: rank_deficient warn/silent, cluster SE, low cell warning, robust no-op equivalence - Update REGISTRY.md with cluster-robust SE formula and edge cases Co-Authored-By: Claude Opus 4.6 (1M context) <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
|
Guard cluster-robust SE against G<2 (ValueError), validate cluster IDs for NaN, add propensity score overlap warning for IPW/DR when >5% of observations are trimmed at bounds. Add 4 tests and update REGISTRY.md. Co-Authored-By: Claude Opus 4.6 (1M context) <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
|
…sistency When propensity score estimation fails, skip Hessian computation (set hessian=None) instead of computing a correction for a non-estimated model. Pass user's rank_deficient_action to r_squared solve_ols call instead of hardcoding "silent". Co-Authored-By: Claude Opus 4.6 (1M context) <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
Suggestions (optional)
|
…ng fix Non-finite influence function values (from extreme propensity scores or near-singular design) now warn and set SE to NaN instead of silently zeroing. Updated triple_difference() docstring to document robust as no-op, matching class docstring. Co-Authored-By: Claude Opus 4.6 (1M context) <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
|
…erence Add self.cluster to required_cols in _validate_data() so a missing cluster column raises a consistent ValueError instead of a raw pandas KeyError. 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
Tests not run (review only). Suggested next steps
|
The detailed section was updated in PR #169 but the summary table at the top of METHODOLOGY_REVIEW.md was missed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
triplediff::ddd()(Ortiz-Villavicencio & Sant'Anna 2025)Methodology references (required if estimator / math changes)
triplediff::ddd()v0.2.1 (CRAN) — official companion by paper authorspanel=FALSE(repeated cross-section) mode only; panel mode not yet implementedValidation
tests/test_methodology_triple_diff.py(91 new tests)tests/test_triple_diff.py(5 expectations updated)Security / privacy
Generated with Claude Code