Skip to content

Commit c5015c7

Browse files
igerberclaude
andcommitted
Fix _estimate_max_pre_violation to use reference-aware pre_periods
Use the pre_periods list from _extract_event_study_params() instead of hardcoded t < 0. With anticipation > 0, the reference period is at e = -1 - anticipation, so periods -anticipation through -1 are NOT pre-treatment and should not enter max_pre_violation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1f8a537 commit c5015c7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

diff_diff/honest_did.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,11 +1443,12 @@ def _estimate_max_pre_violation(self, results: Any, pre_periods: List) -> float:
14431443

14441444
if isinstance(results, CallawaySantAnnaResults):
14451445
if results.event_study_effects:
1446-
# Filter out normalization constraints (n_groups=0, e.g. reference period)
1446+
# Use the reference-aware pre_periods from _extract_event_study_params
1447+
pre_set = set(pre_periods) if pre_periods else set()
14471448
pre_effects = [
14481449
abs(results.event_study_effects[t]["effect"])
14491450
for t in results.event_study_effects
1450-
if t < 0 and results.event_study_effects[t].get("n_groups", 1) > 0
1451+
if t in pre_set and results.event_study_effects[t].get("n_groups", 1) > 0
14511452
]
14521453
if pre_effects:
14531454
return max(pre_effects)

0 commit comments

Comments
 (0)