Calculate Efficiency Gap

part_egap(plans, shp, dvote, rvote)

Arguments

plans

A redist_plans object or plans_matrix where each row indicates a district assignment and each column is a plan.

shp

A redist_map object, tibble, or data frame containing other columns.

dvote

Unqouted name of column in shp with total population.

rvote

Unqouted name of column in shp with group population.

Value

A numeric vector. Can be shaped into a district-by-plan matrix.

References

Nicholas O. Stephanopoulos. 2015. Partisan Gerrymandering and the Efficiency Gap. The University of Chicago Law Review, 82, Pp. 831-900.

Examples

data(nh)
data(nh_m)
# For a single plan:
part_egap(plans = nh$r_2020, shp = nh, rvote = nrv, dvote = ndv)
#> [1] -0.0201538 -0.0201538

# Or many plans:
part_egap(plans = nh_m[, 3:5], shp = nh, rvote = nrv, dvote = ndv)
#> [1] -0.043193591 -0.043193591 -0.005930746 -0.005930746 -0.038463753
#> [6] -0.038463753