impute_ethnorace: Impute Ethnicity/Race

View source: R/impute_ethnorace.R

impute_ethnoraceR Documentation

Impute Ethnicity/Race

Description

Calculates posterior probabilities for individual ethnorace categories using the Naive Bayes algorithm. Also returns highest probability ethnorace as a new character column in the data frame.

Usage

impute_ethnorace(input_data, bper_data = NULL, year, census_key, ...)

Arguments

input_data

The input data frame containing the individuals whose ethnorace the user wants to impute. The following input variables are supported: last_name, first_name, age, sex, party, multi_unit, state, county, zip, place, tract, district, block.

bper_data

The data list containing ethnorace conditional probabilities. If left empty, will default to downloading directly from Census API. Use the function load_bper_data to save this data list ahead of time.

year

The year for which Census data will be loaded. The function will retrieve the closest available Census data for the year.

census_key

Personal Census API key. See https://api.census.gov/data/key_signup.html

Value

The original data frame with the additional columns for ethnorace probabilities and highest probability imputed category.


bwilden/bper documentation built on March 25, 2023, 3:39 p.m.