This function runs enables running iterative ecoligical inference (EI) to estimate the proportion of votes by different race/ethnicity groups for different political candidates.
ei_iter(
data,
cand_cols,
race_cols,
totals_col,
name = "",
erho = 10,
seed = NULL,
plots = FALSE,
eiCompare_class = TRUE,
betas = FALSE,
par_compute = FALSE,
n_cores = NULL,
verbose = FALSE,
plot_path = NULL,
...
)
If eiCompare_class = TRUE, an object of class eiCompare is returned. Otherwise, a dataframe is returned that matches the formatting of ei_est_gen output.
A data.frame() object containing precinct-level turnout data by race and candidate
A character vector listing the column names for turnout for each candidate
A character vector listing the column names for turnout by race
The name of the column containing total votes cast in each precinct
A unique identifier for the outputted eiCompare object.
A number passed directly to ei::ei(). Defaulted to 10. Can also pass in a vector of erho values
An integer seed value for replicating estimate results across runs. If NULL, a random seed is chosen. Defaulted to NULL.
A boolean indicating whether or not to include density and tomography plots
default = TRUE
A boolean to return precinct-level betas for each 2x2 ei
A boolean to conduct ei using parallel processing
The number of cores to use in parallel computation. Defaulted to NULL, in which case parallel::detectCores() - 1 is used
A boolean indicating whether to print out status messages.
A string to specify plot save location. If NULL, plot is not saved
Additional arguments passed directly to ei::ei()
Loren Collingwood <loren.collingwood@ucr.edu>
Ari Decter-Frain <agd75@cornell.edu>
Hikari Murayama <hikari_murayama@berkeley.edu>
Iterative EI iterates through all possible race-candidate pairs. For each pair, votes by other races and for other candidates are binned and 2x2 ecological inference is run.
This function wraps around the ei function from the ei R package. This function is unstable and can break in arbitrary ways. Errors often emerge with particular values of the erho parameter. If the function breaks, it will automatically try adjusting the erho parameter, first to 20, then to 0.5.
If problems persist, please submit an issue on the eiCompare github repository and include the error message you receive.
eiPack. Gary King (1997). A Solution to the Ecological Inference Problem. Princeton: Princeton University Press.