redist.mcmc.mpi | R Documentation |
redist.mcmc.mpi
is used to simulate Congressional redistricting
plans using Markov Chain Monte Carlo methods.
redist.mcmc.mpi(
adj,
total_pop,
nsims,
ndists = NA,
init_plan = NULL,
loopscompleted = 0,
nloop = 1,
nthin = 1,
eprob = 0.05,
lambda = 0,
pop_tol = NA,
group_pop = NA,
areasvec = NA,
counties = NA,
borderlength_mat = NA,
ssdmat = NA,
compactness_metric = "fryer-holden",
rngseed = NA,
constraint = NA,
constraintweights = NA,
betaseq = "powerlaw",
betaseqlength = 10,
adjswaps = TRUE,
freq = 100,
savename = NA,
maxiterrsg = 5000,
verbose = FALSE,
cities = NULL
)
adj |
An adjacency matrix, list, or object of class "SpatialPolygonsDataFrame." |
total_pop |
A vector containing the populations of each geographic unit. |
nsims |
The number of simulations run before a save point. |
ndists |
The number of congressional districts. The default is
|
init_plan |
A vector containing the congressional district labels
of each geographic unit. The default is |
loopscompleted |
Number of save points reached by the
algorithm. The default is |
nloop |
The total number of save points for the algorithm. The
default is |
nthin |
The amount by which to thin the Markov Chain. The default
is |
eprob |
The probability of keeping an edge connected. The default
is |
lambda |
The parameter determining the number of swaps to attempt
each iteration of the algorithm. The number of swaps each iteration is
equal to Pois( |
pop_tol |
The strength of the hard population
constraint. |
group_pop |
A vector of populations for some sub-group of
interest. The default is |
areasvec |
A vector of precinct areas for discrete Polsby-Popper.
The default is |
counties |
A vector of county membership assignments. The default is |
borderlength_mat |
A matrix of border length distances, where
the first two columns are the indices of precincts sharing a border and
the third column is its distance. Default is |
ssdmat |
A matrix of squared distances between geographic
units. The default is |
compactness_metric |
The compactness metric to use when constraining on
compactness. Default is |
rngseed |
Allows the user to set the seed for the
simulations. Default is |
constraint |
Which constraint to apply. Accepts any combination of |
constraintweights |
The weights to apply to each constraint. Should be a vector the same length as constraint. Default is NULL. |
betaseq |
Sequence of beta values for tempering. The default is
|
betaseqlength |
Length of beta sequence desired for
tempering. The default is |
adjswaps |
Flag to restrict swaps of beta so that only
values adjacent to current constraint are proposed. The default is
|
freq |
Frequency of between-chain swaps. Default to once every 100 iterations |
savename |
Filename to save simulations. Default is |
maxiterrsg |
Maximum number of iterations for random seed-and-grow algorithm to generate starting values. Default is 5000. |
verbose |
Whether to print initialization statement. Default is
|
cities |
integer vector of cities for QPS constraint. |
This function allows users to simulate redistricting plans using Markov Chain Monte Carlo methods. Several constraints corresponding to substantive requirements in the redistricting process are implemented, including population parity and geographic compactness. In addition, the function includes multiple-swap and parallel tempering functionality in MPI to improve the mixing of the Markov Chain.
redist.mcmc.mpi
returns an object of class "redist". The object
redist
is a list that contains the following components (the
inclusion of some components is dependent on whether tempering
techniques are used):
partitions |
Matrix of congressional district assignments generated by the algorithm. Each row corresponds to a geographic unit, and each column corresponds to a simulation. |
distance_parity |
Vector containing the maximum distance from parity for a particular simulated redistricting plan. |
mhdecisions |
A vector specifying whether a proposed redistricting plan was accepted (1) or rejected (0) in a given iteration. |
mhprob |
A vector containing the Metropolis-Hastings acceptance probability for each iteration of the algorithm. |
pparam |
A vector containing the draw of the |
constraint_pop |
A vector containing the value of the population constraint for each accepted redistricting plan. |
constraint_compact |
A vector containing the value of the compactness constraint for each accepted redistricting plan. |
constraint_vra |
A vector containing the value of the vra constraint for each accepted redistricting plan. |
constraint_similar |
A vector containing the value of the similarity constraint for each accepted redistricting plan. |
beta_sequence |
A vector containing the value of beta for each iteration of the algorithm. Returned when tempering is being used. |
mhdecisions_beta |
A vector specifying whether a proposed beta value was accepted (1) or rejected (0) in a given iteration of the algorithm. Returned when tempering is being used. |
mhprob_beta |
A vector containing the Metropolis-Hastings acceptance probability for each iteration of the algorithm. Returned when tempering is being used. |
Fifield, Benjamin, Michael Higgins, Kosuke Imai and Alexander Tarr. (2016) "A New Automated Redistricting Simulator Using Markov Chain Monte Carlo." Working Paper. Available at http://imai.princeton.edu/research/files/redist.pdf.
## Not run:
# Cannot run on machines without Rmpi
data(fl25)
data(fl25_enum)
data(fl25_adj)
## Code to run the simulations in Figure 4 in Fifield, Higgins, Imai and
## Tarr (2015)
## Get an initial partition
init_plan <- fl25_enum$plans[, 5118]
## Run the algorithm
redist.mcmc.mpi(adj = fl25_adj, total_pop = fl25$pop,
init_plan = init_plan, nsims = 10000, savename = "test")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.