washingtonpost / elex-live-model

a model to generate estimates of the number of outstanding votes on an election night based on the current results of the race
48 stars 5 forks source link

feat: add selection of fixed effects #43

Closed jchaskell closed 1 year ago

jchaskell commented 1 year ago

Description

Allows you to select which fixed effects are included in the model. All other values for that variable are coded as "other". You do so with a fixed_effects parameter that looks like:

'{"state_postal": ["PA", "CA"], "county_classification": ["all"]}'

(it needs to have the quotes in that order on the CLI - just pass as a dictionary to the client)

This change is kinda backward compatible in that you can still pass Featurizer a list of fixed effects and it will assume that you want all FEs for everything in the list. Additionally, you can pass 1 set of fixed effects in the old way to the cli, but you cannot pass multiple --fixed_effects parameters.

Jira Ticket

elex-2375

Test Steps

elexmodel 2017-11-07_VA_G --estimands=dem --office_id=G --geographic_unit_type=precinct --aggregates=county_classification --aggregates=postal_code --fixed_effects='{"county_classification": ["nova", "southside"]}' --percent_reporting 10 --features=ethnicity_european --features=ethnicity_hispanic_and_portuguese

elexmodel 2021-01-05_GA_G --office_id=S_precinct --estimands=dem --geographic_unit_type=precinct --pi_method=gaussian --percent_reporting=20 --fixed_effects='{"county_fips": ["13311", "13319"], "county_classification": ["all"]}'