You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add base_period parameter to CallawaySantAnna for pre-treatment effects
Implement the base_period parameter matching R's did::att_gt() API to enable
computation of pre-treatment ATT(g,t) values for parallel trends assessment.
Two modes are supported:
- "varying" (default): Pre-treatment uses t-1 as base (consecutive comparisons)
- "universal": All comparisons use g-anticipation-1 as base
Both modes produce identical post-treatment ATT(g,t) values. They differ only
in how pre-treatment effects are computed. The overall ATT aggregation only
includes post-treatment effects, matching R's behavior.
Changes:
- Add base_period parameter to CallawaySantAnna.__init__ with validation
- Modify _compute_att_gt_fast to select base period based on mode
- Update fit() to compute pre-treatment ATT(g,t) where t < g - anticipation
- Filter _aggregate_simple and bootstrap to only aggregate post-treatment effects
- Add base_period to CallawaySantAnnaResults and display in summary()
- Update methodology registry with base_period edge case documentation
- Add 11 new tests for pre-treatment effects
Validated against R's did package v2.3.0 with max numerical difference of 4.91e-05.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Threshold: Returns NaN if <50% of bootstrap samples are valid
211
211
-**Note**: This is a defensive enhancement over reference implementations (R's `did::att_gt`, Stata's `csdid`) which may error or produce unhandled inf/nan in edge cases without informative warnings
212
+
- Base period selection (`base_period` parameter):
213
+
- "varying" (default): Pre-treatment uses t-1 as base (consecutive comparisons)
214
+
- "universal": All comparisons use g-anticipation-1 as base
215
+
- Both produce identical post-treatment ATT(g,t); differ only pre-treatment
216
+
- Matches R `did::att_gt()` base_period parameter
212
217
213
218
**Reference implementation(s):**
214
219
- R: `did::att_gt()` (Callaway & Sant'Anna's official package)
0 commit comments