Skip to content
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

Handle division where normalized_margin numerator and denominator are 0 #98

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

dmnapolitano
Copy link
Contributor

Description

Hi! The change in this PR fixes an issue where the numerator (margin) and denominator (weights) used to compute normalized_margin could be 0. This is probably most common when computing a baseline_margin estimand, when a unit's baseline_dem and baseline_gop are 0, resulting in baseline_margin and baseline_weights being 0. I've also added a unit test for this case 🎉 Thanks!

Jira Ticket

Test Steps

This test bed command:
python run.py 2022-11-08_USA_G redo --office_id S_precinct --fixed_effects "['county_classification']" --geographic_unit_type precinct --pi_method bootstrap --estimands "['margin']" --features "['baseline_normalized_margin', 'median_household_income', 'percent_bachelor_or_higher']" --end_timestamp "2022-11-09 10:31:27-05:00" --single_state IA

@dmnapolitano dmnapolitano requested a review from a team as a code owner August 15, 2024 18:24
@dmnapolitano dmnapolitano merged commit d4d1d7f into develop Aug 16, 2024
3 checks passed
@dmnapolitano dmnapolitano deleted the bug/fix_bad_normalized_margin_math branch August 16, 2024 14:57
@dmnapolitano dmnapolitano restored the bug/fix_bad_normalized_margin_math branch August 16, 2024 14:57
@dmnapolitano dmnapolitano deleted the bug/fix_bad_normalized_margin_math branch August 16, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants