-
Notifications
You must be signed in to change notification settings - Fork 89
Add convex hull violation diagnostic for synthetic control methods #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: drbenvincent <[email protected]>
Co-authored-by: drbenvincent <[email protected]>
Co-authored-by: drbenvincent <[email protected]>
Co-authored-by: drbenvincent <[email protected]>
Co-authored-by: drbenvincent <[email protected]>
|
bugbot run |
PR SummaryAdds
Written by Cursor Bugbot for commit 8f8d79d. This will update automatically on new commits. Configure here. |
The interrogate coverage badge in the documentation was updated to reflect a new coverage value of 96.4%.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #599 +/- ##
==========================================
+ Coverage 93.27% 93.38% +0.11%
==========================================
Files 37 37
Lines 5632 5733 +101
Branches 367 370 +3
==========================================
+ Hits 5253 5354 +101
Misses 248 248
Partials 131 131 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Note to self: the "What to Do if Violated" section needs a bit more work. |
Added a check in check_convex_hull_violation to safely handle empty treated and control arrays, returning default pass results. Added a corresponding test to ensure correct behavior for this edge case.
Reworded suggestions for alternative methods in the synthetic control discussion to improve clarity and consistency. Adjusted phrasing for Augmented Synthetic Control and Comparative Interrupted Time Series methods.
Synthetic control methods construct counterfactuals using non-negative weights summing to one—a convex combination. This mathematically constrains predictions to lie within the convex hull of control units. When the treated unit's pre-intervention trajectory falls outside this hull (e.g., consistently above or below all controls), the method cannot produce accurate counterfactuals.
Changes
Core diagnostic
check_convex_hull_violation()utility that validates treated unit values fall within control range at each time pointSyntheticControl.__init__()that warns when violated:Testing
Documentation
sc_pymc.ipynbintroducing the conceptsc_pymc_brexit.ipynbwith mathematical explanation, visualization code, and alternatives when violatedOriginal prompt
This section details on the original issue you should resolve
<issue_title>Add Diagnostic Test for Convex Hull Assumption in Synthetic Control</issue_title>
<issue_description>## Problem Description
Background
The synthetic control method constructs a counterfactual by finding a weighted combination of control units that best approximates the treated unit in the pre-intervention period. In CausalPy, this is implemented via the
WeightedSumFitter(Bayesian) andWeightedProportion(OLS) models, both of which impose:These constraints mean the synthetic control prediction μ is a convex combination of the control units:
The Convex Hull Assumption
By definition, a convex combination can only produce values that lie within the convex hull of the input points. In the context of synthetic control, this means:
When this assumption is violated:
In either case, no valid convex combination can match the treated unit's trajectory, leading to:
Current State
CausalPy does not currently:
Proposed Solution
1. Implement Diagnostic Test
Add a function to check whether the treated unit's pre-intervention values fall within the convex hull of the control units at each time point. A simplified but effective approach:
2. Issue Warning with Instructive Message
In
SyntheticControl.__init__(), after preparing the data but before fitting, run the diagnostic and issue a warning if violated:3. Update Notebooks
sc_pymc.ipynbAdd a brief subsection titled "Convex Hull Assumption" that:
sc_pymc_brexit.ipynbAdd a more detailed pedagogical subsection titled "Understanding the Convex Hull Assumption" t...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.