Add Synthetic Difference-in-Differences (SDID) estimator#8
Merged
Conversation
Implements the Synthetic DiD method from Arkhangelsky et al. (2021) that combines DiD with synthetic control by re-weighting control units to match treated units' pre-treatment outcomes. Key features: - SyntheticDiD estimator class with sklearn-like API - Unit weight optimization via projected gradient descent - Time weight computation for emphasizing informative periods - Bootstrap and placebo-based inference - SyntheticDiDResults with weight inspection methods - Comprehensive test suite (30+ new tests) - Documentation with use cases (few treated units, questionable parallel trends, heterogeneous controls) Bumps version to 0.3.0.
Add comprehensive bibliography covering all techniques implemented in the library: - Difference-in-Differences (Ashenfelter & Card, Card & Krueger, Angrist & Pischke) - Two-Way Fixed Effects (Wooldridge, Imai & Kim) - Robust Standard Errors (White, MacKinnon & White, Cameron et al.) - Synthetic Control Method (Abadie et al.) - Synthetic Difference-in-Differences (Arkhangelsky et al.) - Parallel Trends Testing (Roth, Rambachan & Roth) - Multi-Period/Staggered DiD (Callaway & Sant'Anna, Sun & Abraham, de Chaisemartin) - General Causal Inference (Imbens & Rubin, Cunningham)
igerber
pushed a commit
that referenced
this pull request
Jan 4, 2026
igerber
added a commit
that referenced
this pull request
Apr 18, 2026
…StageDiD Addresses axis-C findings #8, #9, and #10 from the silent-failures audit: three sites where a sparse factorization failure silently fell back to dense lstsq without any user-facing signal. - diff_diff/imputation.py:1516 (variance path: scipy.sparse.linalg.spsolve on (A_0' W A_0) z = A_1' w). Bare `except Exception` was swallowing the root cause before dense lstsq. Now emits a UserWarning identifying the exception type and explaining the fallback implication. - diff_diff/two_stage.py:1647 (GMM sandwich: sparse_factorized on X'_{10} W X_{10} for Stage 1 normal equations). `except RuntimeError` was silent; now emits a UserWarning. - diff_diff/two_stage_bootstrap.py:134 (bootstrap path: same pattern as above). `except RuntimeError` was silent; now emits a UserWarning. All three are single-call sites (per fit, or per aggregation level, or per bootstrap replicate at most a handful of times) so no aggregation wrapper pattern is needed — one warning per fallback event is appropriate. REGISTRY.md updated under ImputationDiD and TwoStageDiD. New tests (3): monkey-patch the sparse entry point to raise a RuntimeError, run .fit(), assert the UserWarning fires with the expected message prefix. Works against both the variance and bootstrap surfaces. Axis-C baseline: 3 major silent-fallback sites (imputation, two_stage, two_stage_bootstrap) -> 0 remaining in these files. PowerAnalysis simulation counter (finding #11) and ContinuousDiD B-spline (#12) still open as separate follow-ups. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the Synthetic DiD method from Arkhangelsky et al. (2021) that
combines DiD with synthetic control by re-weighting control units to match
treated units' pre-treatment outcomes.
Key features:
trends, heterogeneous controls)
Bumps version to 0.3.0.