-
Notifications
You must be signed in to change notification settings - Fork 9
Fix plot_event_study reference_period normalization #108
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
Fix plot_event_study reference_period normalization #108
Conversation
The reference_period parameter was documented as normalizing effects to 0 but only applied visual styling. This commit adds actual normalization logic that subtracts the reference effect from all effects when reference_period is specified. Changes: - Add normalization logic in plot_event_study() after critical_value calculation: subtracts reference effect from all effects - Only normalizes if reference_period exists in data and is finite - Add 3 tests verifying normalization behavior, no-normalization case, and NaN reference handling - Fix Python 3.9 compatibility issue in tutorial notebook (backslash in f-string expression) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Overall assessment: Executive summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
When normalizing effects to a reference period, the reference SE is now set to NaN since it's an identifying constraint rather than an estimated quantity. This follows the fixest (R) convention where the omitted category has no associated uncertainty. Changes: - visualization.py: Set reference SE to NaN when normalizing - test_visualization.py: Verify reference period has no error bars - REGISTRY.md: Document event study plotting normalization behavior Co-Authored-By: Claude Opus 4.5 <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
|
- Add reference_inferred flag to _extract_plot_data return value - Track whether reference_period was user-provided vs auto-detected - Auto-inferred reference periods get hollow marker styling only, no normalization - Explicit reference_period=X triggers normalization and sets ref SE to NaN - Add tests for both auto-inferred (no normalization) and explicit (normalizes) - Update REGISTRY.md to document the explicit vs inferred behavior This prevents unintended normalization when reference period isn't a true identifying constraint (e.g., CallawaySantAnna with base_period="varying"). Co-Authored-By: Claude Opus 4.5 <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
Open Questions
|
- Clarify reference_period docstring: explicit triggers normalization, auto-inferred only applies hollow marker styling - Update Notes section to distinguish explicit vs inferred behavior - Refactor two tests to reuse cs_results fixture instead of re-fitting Co-Authored-By: Claude Opus 4.5 <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
|
Summary
plot_event_studyto actually normalize effects whenreference_periodis specifiedMethodology references (required if estimator / math changes)
Validation
tests/test_visualization.py(3 new tests)test_plot_event_study_reference_period_normalization- verifies normalization occurstest_plot_event_study_no_normalization_without_reference- verifies no change when reference_period=Nonetest_plot_event_study_normalization_with_nan_reference- verifies NaN reference is handled02_staggered_did.ipynbvalidated via/validate-tutorial 02Security / privacy
Generated with Claude Code