redist.mcmc
is used to simulate Congressional redistricting
plans using Markov Chain Monte Carlo methods.
redist.mcmc( adjobj, popvec, nsims, ndists = NULL, initcds = NULL, loopscompleted = 0, nloop = 1, nthin = 1, eprob = 0.05, lambda = 0, popcons = NULL, grouppopvec = NULL, areasvec = NULL, countymembership = NULL, borderlength_mat = NULL, ssdmat = NULL, temper = FALSE, constraint = NULL, constraintweights = NULL, compactness_metric = "fryerholden", ssd_denom = 1, betaseq = "powerlaw", betaseqlength = 10, betaweights = NULL, adjswaps = TRUE, rngseed = NULL, maxiterrsg = 5000, adapt_lambda = FALSE, adapt_eprob = FALSE, contiguitymap = "rooks", exact_mh = FALSE, savename = NULL, verbose = TRUE, tgt_min = 0.55, tgt_other = 0.25 )
adjobj  An adjacency matrix, list, or object of class "SpatialPolygonsDataFrame." 

popvec  A vector containing the populations of each geographic unit 
nsims  The number of simulations run before a save point. 
ndists  The numbe of congressional districts. The default is

initcds  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 detmerining the number of swaps to attempt
each iteration fo the algoirhtm. The number of swaps each iteration is
equal to Pois( 
popcons  The strength of the hard population
constraint. 
grouppopvec  A vector of populations for some subgroup of
interest. The default is 
areasvec  A vector of precinct areas for discrete PolsbyPopper.
The default is 
countymembership  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 
temper  Whether to use simulated tempering algorithm. Default is FALSE. 
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. 
compactness_metric  The compactness metric to use when constraining on
compactness. Default is 
ssd_denom  The normalizing constant for the sumofsquared distance FryerHolden metric. Default is 1.0 (unnormalized). 
betaseq  Sequence of beta values for tempering. The default is

betaseqlength  Length of beta sequence desired for
tempering. The default is 
betaweights  Sequence of weights for different values of
beta. Allows the user to upweight certain values of beta over
others. The default is 
adjswaps  Flag to restrict swaps of beta so that only
values adjacent to current constraint are proposed. The default is

rngseed  Allows the user to set the seed for the
simulations. Default is 
maxiterrsg  Maximum number of iterations for random seedandgrow algorithm to generate starting values. Default is 5000. 
adapt_lambda  Whether to adaptively tune the lambda parameter so that the MetropolisHastings acceptance probability falls between 20% and 40%. Default is FALSE. 
adapt_eprob  Whether to adaptively tune the edgecut probability parameter so that the MetropolisHastings acceptance probability falls between 20% and 40%. Default is FALSE. 
contiguitymap  Use queens or rooks distance criteria for generating an adjacency list from a "SpatialPolygonsDataFrame" data type. Default is "rooks". 
exact_mh  Whether to use the approximate (0) or exact (1) MetropolisHastings ratio calculation for acceptreject rule. Default is FALSE. 
savename  Filename to save simulations. Default is 
verbose  Whether to print initialization statement.
Default is 
tgt_min  The majority minority target percent as a decimal. Default is 0.55. 
tgt_other  The remaining target percent as a decimal. Default is 0.25. 
redist.mcmc
returns an object of class "redist". The object
redist
is a list that contains the folowing components (the
inclusion of some components is dependent on whether tempering
techniques are used):
Matrix of congressional district assignments generated by the algorithm. Each row corresponds to a geographic unit, and each column corresponds to a simulation.
Vector containing the maximum distance from parity for a particular simulated redistricting plan.
A vector specifying whether a proposed redistricting plan was accepted (1) or rejected (0) in a given iteration.
A vector containing the MetropolisHastings acceptance probability for each iteration of the algorithm.
A vector containing the draw of the p
parameter for each
simulation, which dictates the number of swaps attempted.
A vector containing the value of the population constraint for each accepted redistricting plan.
A vector containing the value of the compactness constraint for each accepted redistricting plan.
A vector containing the value of the vra constraint for each accepted redistricting plan.
A vector containing the value of the similarity constraint for each accepted redistricting plan.
A vector containing the value of beta for each iteration of the algorithm. Returned when tempering is being used.
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.
A vector containing the MetropolisHastings acceptance probability for each iteration of the algorithm. Returned when tempering is being used.
This function allows users to simulate redistricting plans using Markov Chain Monte Carlo methods. Several constraints correspoding to substantive requirements in the redistricting process are implemented, including population parity and geographic compactness. In addition, the function includes multipleswap and simulated tempering functionality to improve the mixing of the Markov Chain.
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.
if (FALSE) { data(algdat.pfull) ## Code to run the simulations in Figure 4 in Fifield, Higgins, ## Imai and Tarr (2015) ## Get an initial partition set.seed(1) initcds < algdat.pfull$cdmat[,sample(1:ncol(algdat.pfull$cdmat), 1)] ## Run the algorithm alg_253 < redist.mcmc(adjobj = algdat.pfull$adjlist, popvec = algdat.pfull$precinct.data$pop, initcds = initcds, nsims = 10000) }