Learn R Programming

eiCompare (version 3.0.4)

wru_predict_race_wrapper: Prepares a voter file for the WRU predict_race function, and then predicts race.

Description

This function assumes that the Census data is provided to the function. It does not provide the capability of downloading the Census data, since this is a time intensive process.

Usage

wru_predict_race_wrapper(
  voter_file,
  census_data,
  voter_id = NULL,
  surname = "last_name",
  state = NULL,
  county = NULL,
  tract = NULL,
  block = NULL,
  census_geo = NULL,
  use_surname = TRUE,
  surname_only = FALSE,
  surname_year = 2010,
  use_age = FALSE,
  use_sex = FALSE,
  return_surname_flag = FALSE,
  return_geocode_flag = FALSE,
  verbose = FALSE
)

Value

The voter file component extracted from the provided data frame, with additional surname/geocode flags, as well as a data frame race prediction.

Arguments

voter_file

The voter file, containing columns with a surname and potentially geographic information.

census_data

A data frame containing Census data corresponding to the geographic information for units in the voter file.

voter_id

A string denoting the column containing voter ID. Default is NULL, if there is no voter ID in the file. In this case, a voter ID will be assigned.

surname

A string denoting the column containing the surname.

state

A string denoting the column containing the state FIPS code.

county

A string denoting the column containing the county FIPS code.

tract

A string denoting the column containing the tract FIPS code.

block

A string denoting the column containing the block FIPS code.

census_geo

The census level at which to apply BISG. Passed to WRU.

use_surname

Whether to use the surname in calculating race probabilities. Passed to WRU.

surname_only

Whether to only use the surname in calculating race probabilities. Passed to WRU.

surname_year

Which Census year to use for surname matching. Passed to WRU.

use_age

Whether to use the age in the BISG calculation. Passed to WRU.

use_sex

Whether to use the sex in the BISG calculation. Passed to WRU.

return_surname_flag

If TRUE, returns a flag indicating whether the surnames matched.

return_geocode_flag

If TRUE, returns a flag indicating whether the first level of geocode matched.

verbose

A flag indicating whether to print out status messages.

References

Imai and Khanna (2016) "Improving Ecological Inference by Predicting Individual Ethnicity from Voter Registration Records"