redist_mergesplit uses a Markov Chain Monte Carlo algorithm (Carter et al. 2019; based on DeFord et. al 2019) 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 (McCartan and Imai 2020); it is similar but not identical to those used in the references. 1-level hierarchical Merge-split is supported through the counties parameter; unlike in the SMC algorithm, this does not guarantee a maximum number of county splits.

  warmup = max(100, nsims%/%2),
  thin = 1L,
  init_plan = NULL,
  counties = NULL,
  compactness = 1,
  constraints = list(),
  constraint_fn = function(m) rep(0, ncol(m)),
  adapt_k_thresh = 0.98,
  k = NULL,
  init_name = NULL,
  verbose = FALSE,
  silent = FALSE



A redist_map object.


The number of samples to draw, including warmup.


The number of warmup samples to discard. Recommended to be at least the first 20% of samples, and in any case no less than around 100 samples.


Save every thin-th sample. Defaults to no thinning (1).


The initial state of the map. If not provided, will default to the reference map of the map object, or if none exists, will sample a random initial state using redist_smc. You can also request a random initial state by setting init_plan="sample".


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. There is no strength parameter associated with this constraint. To adjust the number of county splits further, or to constrain a second type of administrative split, consider using add_constr_splits(), add_constr_multisplits(), and add_constr_total_splits().


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.


A list containing information on constraints to implement. See the 'Details' section for more information.


A function which takes in a matrix where each column is a redistricting plan and outputs a vector of log-weights, which will be added the the final weights.


The threshold value used in the heuristic to select a value k_i for each splitting iteration. Set to 0.9999 or 1 if the algorithm does not appear to be sampling from the target distribution. Must be between 0 and 1.


The number of edges to consider cutting after drawing a spanning tree. Should be selected automatically in nearly all cases.


a name for the initial plan, or FALSE to not include the initial plan in the output. Defaults to the column name of the existing plan, or "<init>" if the initial plan is sampled.


Whether to print out intermediate information while sampling. Recommended.


Whether to suppress all diagnostic information.


redist_mergesplit returns an object of class redist_plans containing the simulated plans.


This function draws samples from a specific target measure, controlled by the map, compactness, and constraints parameters.

Key to ensuring good performance is monitoring the acceptance rate, which is reported at the sample level in the output. Users should also check diagnostics of the sample by running summary.redist_plans().

Higher values of compactness sample more compact districts; setting this parameter to 1 is computationally efficient and generates nicely compact districts.


Carter, D., Herschlag, G., Hunter, Z., and Mattingly, J. (2019). A merge-split proposal for reversible Monte Carlo Markov chain sampling of redistricting plans. arXiv preprint arXiv:1911.01503.

McCartan, C., & Imai, K. (2020). Sequential Monte Carlo for Sampling Balanced and Compact Redistricting Plans. Available at

DeFord, D., Duchin, M., and Solomon, J. (2019). Recombination: A family of Markov chains for redistricting. arXiv preprint arXiv:1911.05725.


# \donttest{

fl_map <- redist_map(fl25, ndists = 3, pop_tol = 0.1)
#> Projecting to CRS 3857

sampled_basic <- redist_mergesplit(fl_map, 10000)
#> Sampling 10,000 25-unit maps with 3 districts and population between 52,513 and 64,182.
#>    0% | ETA:?
#> ■■■■■■■■                          23% | ETA:  1s | MH Acceptance: inf
#> ■■■■■■■■■■■■■■■                   46% | ETA:  0s | MH Acceptance: 0.80
#> ■■■■■■■■■■■■■■■■■■■■■■            71% | ETA:  0s | MH Acceptance: 0.78
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    96% | ETA:  0s | MH Acceptance: 0.78
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s | MH Acceptance: 0.78
#> Acceptance rate: 77.93%

sampled_constr <- redist_mergesplit(fl_map, 10000, constraints = list(
    incumbency = list(strength = 1000, incumbents = c(3, 6, 25))
#> Sampling 10,000 25-unit maps with 3 districts and population between 52,513 and 64,182.
#> ■■■■                              10% | ETA: 1s
#> ■■■■■■■■■■                        29% | ETA:  1s | MH Acceptance: 0.46
#> ■■■■■■■■■■■■■■■                   47% | ETA:  1s | MH Acceptance: 0.52
#> ■■■■■■■■■■■■■■■■■■■               61% | ETA:  0s | MH Acceptance: 0.52
#> ■■■■■■■■■■■■■■■■■■■■■■■           74% | ETA:  0s | MH Acceptance: 0.53
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      90% | ETA:  0s | MH Acceptance: 0.53
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s | MH Acceptance: 0.53
#> Acceptance rate: 53.63%
# }