Calculate Partisan Dislocation

part_dislocation(
  plans,
  shp,
  dvote,
  rvote,
  total_pop = dvote + rvote,
  epsg = 3857,
  by_precinct = FALSE,
  signed = TRUE
)

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 with an sf geometry column.

dvote

Unqouted name of column in shp with total population.

rvote

Unqouted name of column in shp with group population.

total_pop

Unqouted name of column in shp with total population.

epsg

Numeric EPSG code to use to project the shapefile, if needed. Default is 3857.

by_precinct

Defaults to FALSE, returning district-level values.

signed

Defaults to TRUE. Should the output for district-level values be signed? Setting to TRUE returns precinct-level values.

Value

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

References

DeFord, D. R., Eubank, N., & Rodden, J. (2022). Partisan dislocation: A precinct-level measure of representation and gerrymandering. Political Analysis, 30(3), 403-425.

Examples

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

# Or many plans:
part_dislocation(plans = nh_m[, 3:5], shp = nh, rvote = nrv, dvote = ndv)
#> [1]  0.026426642 -0.005861866  0.039019354 -0.018983433  0.044388704
#> [6] -0.024102163