View source: R/redist_ms_parallel.R
redist_mergesplit_parallel | R Documentation |
redist_mergesplit_parallel()
runs redist_mergesplit()
on several
chains in parallel.
redist_mergesplit_parallel(
map,
nsims,
chains = 1,
warmup = if (is.null(init_plan)) 10 else max(100, nsims%/%5),
thin = 1L,
init_plan = NULL,
counties = NULL,
compactness = 1,
constraints = list(),
constraint_fn = function(m) rep(0, ncol(m)),
adapt_k_thresh = 0.99,
k = NULL,
ncores = NULL,
cl_type = "PSOCK",
return_all = TRUE,
init_name = NULL,
verbose = FALSE,
silent = FALSE
)
map |
A |
nsims |
The number of samples to draw, including warmup. |
chains |
the number of parallel chains to run. Each chain will have
|
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, unless initializing from a random plan. |
thin |
Save every |
init_plan |
The initial state of the map, provided as a single vector
to be shared across all chains, or a matrix with |
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. 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 |
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 log-weights, 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. |
ncores |
the number of parallel processes to run. Defaults to the maximum available. |
cl_type |
the cluster type (see |
return_all |
if |
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. |
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.
A redist_plans
object with all of the simulated plans, and an
additional chain
column indicating the chain the plan was drawn from.
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. (2023). Sequential Monte Carlo for Sampling Balanced and Compact Redistricting Plans. Annals of Applied Statistics 17(4). Available at \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/23-AOAS1763")}.
DeFord, D., Duchin, M., and Solomon, J. (2019). Recombination: A family of Markov chains for redistricting. arXiv preprint arXiv:1911.05725.
## Not run:
data(fl25)
fl_map <- redist_map(fl25, ndists = 3, pop_tol = 0.1)
sampled <- redist_mergesplit_parallel(fl_map, nsims = 100, chains = 100)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.