Usage
race.pred(voters, races = c("white", "black", "latino", "asian", "other"), name.clean = TRUE, surname.only = FALSE, census = "", census.key = "", demo = FALSE, party)
Arguments
voters
An object of class data.frame. Must contain a field for
surname (surname). Optional fields include Census tract (tract),
Census block (block), party registration (party),
age (age), and sex (sex).
races
A character vector specifying which racial groups to generate
predicted probabilities for. Can include any subset of the default vector,
which is c("white", "black", "latino", "asian", "other").
name.clean
A TRUE/FALSE object. If TRUE, function will call
name.clean to merge in data from U.S. Census 2000 Surname List
and Spanish Surname List. If FALSE, voters object must contain fields
specifying Pr(Race | Surname), named as follows:
p_whi for Whites, p_bla for Blacks,
p_his for Hispanics/Latinos, p_asi for Asians,
and/or p_oth for Other. Default is TRUE.
surname.only
A TRUE/FALSE object. If TRUE, race predictions will
only use surname data and calculate Pr(Race | Surnname). Default is FALSE
census
An optional character vector specifying what level of
geography to use to merge in U.S. Census 2010 data. Currently only
tract and "block" are supported.
If "tract" or "block" is specified,
function will call census.helper.api to merge in tract- or block-
level data. If left unspecified, voters must contain fields
specifying Pr(Geolocation | Race), including any of the following:
r_whi, r_bla, r_his,
r_asi, and/or r_oth.
census.key
A character object specifying user's Census API
key. Must be specified if census is specified, because the
census.helper function requires a Census API key to operate.
demo
An optional TRUE/FALSE object specifying whether to
condition race predictions on individual age and sex.
If TRUE, voters should include numerical variables
age and sex, where sex coded as 0 for
males and 1 for females. Default is FALSE.
May only be set to TRUE when census is specified.
party
An optional character object specifying party registration field.
Party registration should be coded as 1 for Democrat, 2 for Republican, and
0 for Other.