R/redist_ms_tidy.R
, R/redist_ms.R
redist_mergesplit.Rd
redist_mergesplit
uses a Markov Chain Monte Carlo algorithm to
generate congressional or legislative redistricting plans according to
contiguity, population, compactness, and administrative boundary constraints.
The MCMC proposal is the same as is used in the SMC sampler; it is similar
but not identical to those used in the references. 1level hierarchical
Mergesplit is supported through the counties
parameter; unlike in
the SMC algorithm, this does not guarantee a maximum number of county splits.
redist_mergesplit( map, nsims, warmup = floor(nsims/2), init_plan = NULL, counties = NULL, compactness = 1, constraints = list(), constraint_fn = function(m) rep(0, ncol(m)), adapt_k_thresh = 0.975, k = NULL, init_name = NULL, verbose = TRUE, silent = FALSE ) redist.mergesplit( adj, total_pop, nsims, ndists, pop_tol = 0.01, init_plan, counties, compactness = 1, constraints = list(), constraint_fn = function(m) rep(0, ncol(m)), adapt_k_thresh = 0.975, k = NULL, verbose = TRUE, silent = FALSE )
map  A 

nsims  The number of samples to draw, including warmup. 
warmup  The number of warmup samples to discard. 
init_plan  The initial state of the map. If not provided, will default to
the reference map of the 
counties  A vector containing county (or other administrative or
geographic unit) labels for each unit, which may be integers ranging from 1
to the number of counties, or a factor or character vector. If provided, the
algorithm will generate maps tend to follow county lines. You may combine this
with a Gibbs constraint on the number of county splits using the

compactness  Controls the compactness of the generated districts, with higher values preferring more compact districts. Must be nonnegative. See the 'Details' section for more information, and computational considerations. 
constraints  A list containing information on constraints to implement. See the 'Details' section for more information. 
constraint_fn  A function which takes in a matrix where each column is a redistricting plan and outputs a vector of logweights, which will be added the the final weights. 
adapt_k_thresh  The threshold value used in the heuristic to select a
value 
k  The number of edges to consider cutting after drawing a spanning tree. Should be selected automatically in nearly all cases. 
init_name  a name for the initial plan, or 
verbose  Whether to print out intermediate information while sampling. Recommended. 
silent  Whether to suppress all diagnostic information. 
adj  adjacency matrix, list, or object of class "SpatialPolygonsDataFrame." 
total_pop  A vector containing the populations of each geographic unit 
ndists  The number of congressional districts. 
pop_tol  The desired population constraint. All sampled districts
will have a deviation from the target district size no more than this value
in percentage terms, i.e., 
redist_mergesplit
returns an object of class
redist_plans
containing the simulated plans.
redist.mergesplit
(Deprecated) returns an object of class list containing the
simulated plans.
This function draws samples from a specific target measure, controlled by the
compactness
, constraints
, and constraint_fn
parameters.
Higher values of compactness
sample more compact districts;
setting this parameter to 1 is computationally efficient and generates nicely
compact districts.
The constraints
parameter allows the user to apply several common
redistricting constraints without implementing them by hand. This parameter
is a list, which may contain any of the following named entries:
status_quo
: a list with two entries:
strength
, a number controlling the tendency of the generated districts
to respect the status quo, with higher values preferring more similar
districts.
current
, a vector containing district assignments for
the current map.
hinge
: a list with three entries:
strength
, a number controlling the strength of the Voting Rights Act
(VRA) constraint, with higher values prioritizing majorityminority districts
over other considerations.
tgts_min
, the target percentage(s) of minority voters in minority
opportunity districts. Defaults to c(0.55)
.
min_pop
, A vector containing the minority population of each
geographic unit.
incumbency
: a list with two entries:
strength
, a number controlling the tendency of the generated districts
to avoid pairing up incumbents.
incumbents
, a vector of precinct indices, one for each incumbent's
home address.
splits
: a list with one entry:
strength
, a number controlling the tendency of the generated districts
to avoid splitting counties.
multisplits
: a list with one entry:
strength
, a number controlling the tendency of the generated districts
to avoid splitting counties multiple times.
vra
: a list with five entries, which may be set up using
redist.constraint.helper
:
strength
, a number controlling the strength of the Voting Rights Act
(VRA) constraint, with higher values prioritizing majorityminority districts
over other considerations.
tgt_vra_min
, the target percentage of minority voters in minority
opportunity districts. Defaults to 0.55.
tgt_vra_other
The target percentage of minority voters in other
districts. Defaults to 0.25, but should be set to reflect the total minority
population in the state.
pow_vra
, which controls the allowed deviation from the target
minority percentage; higher values are more tolerant. Defaults to 1.5
min_pop
, A vector containing the minority population of each
geographic unit.
All constraints are fed into a Gibbs measure, with coefficients on each
constraint set by the corresponding strength
parameters.
The strength can be any real number, with zero corresponding to no constraint.
The status_quo
constraint adds a term measuring the variation of
information distance between the plan and the reference, rescaled to [0, 1].
The hinge
constraint takes a list of target minority percentages. It
matches each district to its nearest target percentage, and then applies a
penalty of the form \(\sqrt{max(0, tgt  minpct)}\), summing across
districts. This penalizes districts which are below their target population.
The incumbency
constraint adds a term counting the number of districts
containing pairedup incumbents. The splits
constraint adds a term
counting the number of counties which contain precincts belonging to more
than one district.
The vra
constraint (not recommended) adds a term of the form
\((tgtvraminminpcttgtvraotherminpct)^{powvra})\), which
encourages districts to have minority percentages near either tgt_vra_min
or tgt_vra_other
. This can be visualized with
redist.plot.penalty
.
Carter, D., Herschlag, G., Hunter, Z., and Mattingly, J. (2019). A mergesplit proposal for reversible Monte Carlo Markov chain sampling of redistricting plans. arXiv preprint arXiv:1911.01503.
DeFord, D., Duchin, M., and Solomon, J. (2019). Recombination: A family of Markov chains for redistricting. arXiv preprint arXiv:1911.05725.
#>sampled_basic = redist_mergesplit(fl_map, 10000)#> MARKOV CHAIN MONTE CARLO #> Sampling 10000 25unit maps with 3 districts and population between 52512.9 and 64182.4. #> Using k = 2 #> Iteration 500/10000 #> Iteration 1000/10000 #> Iteration 1500/10000 #> Iteration 2000/10000 #> Iteration 2500/10000 #> Iteration 3000/10000 #> Iteration 3500/10000 #> Iteration 4000/10000 #> Iteration 4500/10000 #> Iteration 5000/10000 #> Iteration 5500/10000 #> Iteration 6000/10000 #> Iteration 6500/10000 #> Iteration 7000/10000 #> Iteration 7500/10000 #> Iteration 8000/10000 #> Iteration 8500/10000 #> Iteration 9000/10000 #> Iteration 9500/10000 #> Iteration 10000/10000 #> Acceptance rate: 76.96sampled_constr = redist_mergesplit(fl_map, 10000, constraints=list( incumbency = list(strength=1000, incumbents=c(3, 6, 25)) ))#> MARKOV CHAIN MONTE CARLO #> Sampling 10000 25unit maps with 3 districts and population between 52512.9 and 64182.4. #> Using k = 3 #> Iteration 500/10000 #> Iteration 1000/10000 #> Iteration 1500/10000 #> Iteration 2000/10000 #> Iteration 2500/10000 #> Iteration 3000/10000 #> Iteration 3500/10000 #> Iteration 4000/10000 #> Iteration 4500/10000 #> Iteration 5000/10000 #> Iteration 5500/10000 #> Iteration 6000/10000 #> Iteration 6500/10000 #> Iteration 7000/10000 #> Iteration 7500/10000 #> Iteration 8000/10000 #> Iteration 8500/10000 #> Iteration 9000/10000 #> Iteration 9500/10000 #> Iteration 10000/10000 #> Acceptance rate: 83.46# }