R/pop_overlap.R
redist.prec.pop.overlap.Rd
Compare the Population Overlap Across Plans at the Precinct Level
redist.prec.pop.overlap(
plan_old,
plan_new,
total_pop,
weighting = "s",
normalize = TRUE,
index_only = FALSE,
return_mat = FALSE
)
The reference plan to compare against
The new plan to compare to the reference plan
The total population by precinct This can also take a redist_map object and will use the population in that object. If nothing is provided, it weights all entries in plan equally.
Should weighting be done by sum of populations 's'
, mean of
populations 'm'
, geometric mean of populations 'g'
, or none 'n'
Should entries be normalized by the total population
Default is FALSE. TRUE returns only one numeric index, the mean of the upper triangle of the matrix, under the weighting and normalization chosen.
Defaults to FALSE, where it returns the summary by row. If TRUE returns matrix with length(plan_old) rows and columns. Ignored if index_only = TRUE.
numeric vector with length(plan_old) entries
set.seed(5)
data(iowa)
iowa_map <- redist_map(iowa, total_pop = pop, pop_tol = 0.01, ndists = 4)
plans <- redist_smc(iowa_map, 2, silent = TRUE)
plans_mat <- get_plans_matrix(plans)
ov_vec <- redist.prec.pop.overlap(plans_mat[, 1], plans_mat[, 2], iowa_map)
redist.prec.pop.overlap(plans_mat[, 1], plans_mat[, 2], iowa_map, weighting = "s",
normalize = FALSE, index_only = TRUE)
#> [1] 14020.52