Impute gender for ambiguous responses
impute_gender.RdImputes gender for persons reporting neither male nor female using Monte Carlo sampling from sample age/gender distribution. Use for cleaning survey data with ambiguous or missing gender.
Usage
impute_gender(
persons,
value_labels,
report_dir = NULL,
outputs_dir = NULL,
seed = NULL,
acs_year = NULL,
settings
)Arguments
- persons
data.table. Person records to impute.
- value_labels
data.table. Value labels for age and gender.
- report_dir
character(1), optional. Directory for report output.
- outputs_dir
character(1), optional. Directory for imputation output.
- seed
integer(1), optional. RNG seed for reproducibility.
- acs_year
integer(1), optional. ACS year for reference.
- settings
list. Settings object with configs.
Details
Labels age and gender using value labels.
Computes age-by-gender proportions from sample.
Fills missing proportions with average share.
Assigns gender by Monte Carlo sampling using proportions.
Returns data.table with imputed gender for each person.
Assumes input is a data.table and value labels are complete.
Settings
acs_year (direct): ACS year for reference.
rng_seed (direct): random seed for reproducibility.
See also
value_labels
Other imputation utilities:
calculate_acs_proportions(),
get_acs_ethnicity(),
get_acs_race(),
get_hh_person_sums(),
impute_ethnicity(),
impute_income_nonrelatives(),
impute_income_pnta(),
impute_race(),
make_binary(),
prep_hhs_for_income_imputation(),
prepare_acs_income(),
prepare_ethnicity_labels(),
prepare_ethnicity_survey_data(),
prepare_impute_targets(),
prepare_income_fit_dt(),
prepare_persons_dt(),
update_hh_income_imputed()