R package for accessing ballot-level microdata from the Florida November 2000 general election and computing summaries for ecological inference.
# Work with local files - avoids specifying source= in every call, e.g.:
options(data_dir = "~/florida_2000/")
# Add this to ~/.Rprofile to persist across sessionsWithout this option, all functions download data from the OSF repository.
library(eiballots)
# Browse available races and counties
list_elections()
list_elections(level = "federal")
list_elections(type = "referendum")
list_counties()
# Load raw microdata
lee <- get_county_data("Lee")
df <- get_election_data(c("PRE", "USS"))
# --- Ecological inference summaries ---
# Single race: marginal distributions only (no joint array)
pres <- ei_summary("PRE")
summary(pres)
# Two races: margins + 3-D joint array [precinct x PRE x USS]
obj <- ei_summary(c("PRE", "USS"))
print(obj)
summary(obj)
dim(obj$joint_precinct) # [n_precincts, opts_PRE, opts_USS]
# Three races: 4-D joint array
obj3 <- ei_summary(c("PRE", "USS", "HOS3"))
dim(obj3$joint_precinct) # [n_precincts, opts_PRE, opts_USS, opts_HOS3]
# Extract a 2-race subset from an existing object (no data reload)
obj2 <- obj3[c("PRE", "USS")]
# Convert to eipack wide format
obj_wide <- to_eipack(obj) # margins become a single wide data.frame
obj_back <- to_lphom(obj_wide) # convert back to list format
# Provide data directly (useful for testing or custom subsets)
obj <- ei_summary(c("PRE", "USS"), data = my_data_frame)ei_summary objectei_summary(c("PRE", "USS"))
# $margins - named list of data.frames, one per race (lphom format)
# $PRE: precinct_id | county_id | n_voters | R | D | O | A | I
# $USS: precinct_id | county_id | n_voters | R | D | O | A | I
# (n_voters is identical across races: shared intersection universe)
#
# $joint_precinct - integer array [n_precincts x opts_PRE x opts_USS]
# $joint_total - integer array [opts_PRE x opts_USS] (sum over precincts)
# $meta - list: elections, counties, n_precincts, n_voters,
# opt_levels, format, precinct_info, created_at| Code | Meaning | Treatment |
|---|---|---|
R, D, BauDuf, Y,
… |
Valid vote | Active category |
A |
Abstention (Undervote: voter was eligible, made no choice) | Active category |
I |
Invalid vote (Overvote: mark not counted) | Active category |
NA |
Voter not eligible in this race | Excluded from universe |
The distinction between A, I, and
NA is critical: only NA values define the
universe boundary for ecological inference.