Learn R Programming

redist (version 1.0)

redist.mcmc: MCMC Redistricting Simulator

Description

redist.mcmc is used to simulate Congressional redistricting plans using Markov Chain Monte Carlo methods.

Usage

redist.mcmc(adjobj, popvec, nsims, ndists = NULL, initcds = NULL, loopscompleted = 0,
              nloop = 1, nthin = 1, eprob = 0.05, lambda = 0,
              popcons = NULL, grouppopvec = NULL, ssdmat = NULL,
              betacompact = 0, betapop = 0,
              betaseg = 0, betasimilar = 0,
              temperbetacompact = 0, temperbetapop = 0,
              temperbetaseg = 0, temperbetasimilar = 0,
              betaseq = "powerlaw", betaseqlength = 10,
              betaweights = NULL,
              adjswaps = TRUE, rngseed = NULL,
              savename = NULL, verbose = TRUE)

Arguments

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 number of congressional districts. The default is NULL.
initcds
A vector containing the congressional district labels of each geographic unit. The default is NULL. If not provided, random and contiguous congressional district assignments will be generated using redist.rsg.
loopscompleted
Number of save points reached by the algorithm. The default is 0.
nloop
The total number of save points for the algorithm. The default is 1. Note that the total number of simulations run will be nsims * nloop.
nthin
The amount by which to thin the Markov Chain. The default is 1.
eprob
The probability of keeping an edge connected. The default is 0.05.
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(lambda) + 1. The default is 0.
popcons
The strength of the hard population constraint. popcons = 0.05 means that any proposed swap that brings a district more than 5% away from population parity will be rejected. The default is NULL.
grouppopvec
A vector of populations for some sub-group of interest. The default is NULL.
ssdmat
A matrix of squared distances between geographic units. The default is NULL.
betacompact
Strength of the constraint to impose geographic compactness. Values of betacompact less than zero impose more compactness. The default is 0 (no constraint).
betapop
Strength of the constraint to impose population parity. Values of betapop less than zero bring the simulated districts closer to population parity. The default is 0 (no constraint).
betaseg
Strength of the constraint to "pack" a particular subgroup into a single district. Values of betaseg greater than zero will create districts with higher concentrations of the subgroup. The default is 0 (no constraint).
betasimilar
Strength of the constraint to simulate redistricting similar to a specified plan. Values of betasimilar less than zero will create districts more similar to the specified plan. The default is 0 (no constraint).
temperbetacompact
Flag to apply simulated tempering to the betacompact constraint. The default is 0 (no tempering).
temperbetapop
Flag to apply simulated tempering to the betacompact constraint. The default is 0 (no tempering).
temperbetaseg
Flag to apply simulated tempering to the betaseg constraint. The default is 0 (no tempering).
temperbetasimilar
Flag to apply simulated tempering to the betasimilar constraint. The default is 0 (no tempering).
betaseq
Sequence of beta values for tempering. The default is powerlaw (see Fifield et. al (2015) for details).
betaseqlength
Length of beta sequence desired for tempering. The default is 10.
betaweights
Sequence of weights for different values of beta. Allows the user to upweight certain values of beta over others. The default is NULL (equal weighting).
adjswaps
Flag to restrict swaps of beta so that only values adjacent to current constraint are proposed. The default is TRUE.
rngseed
Allows the user to set the seed for the simulations. Default is NULL.
savename
Filename to save simulations. Default is NULL.
verbose
Whether to print initialization statement. Default is TRUE.

Value

  • 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):
  • partitionsMatrix of congressional district assignments generated by the algorithm. Each row corresponds to a geographic unit, and each column corresponds to a simulation.
  • distance_parityVector containing the maximum distance from parity for a particular simulated redistricting plan.
  • mhdecisionsA vector specifying whether a proposed redistricting plan was accepted (1) or rejected (0) in a given iteration.
  • mhprobA vector containing the Metropolis-Hastings acceptance probability for each iteration of the algorithm.
  • pparamA vector containing the draw of the p parameter for each simulation, which dictates the number of swaps attempted.
  • constraint_popA vector containing the value of the population constraint for each accepted redistricting plan.
  • constraint_compactA vector containing the value of the compactness constraint for each accepted redistricting plan.
  • constraint_segregationA vector containing the value of the segregation constraint for each accepted redistricting plan.
  • constraint_similarA vector containing the value of the similarity constraint for each accepted redistricting plan.
  • beta_sequenceA vector containing the value of beta for each iteration of the algorithm. Returned when tempering is being used.
  • mhdecisions_betaA 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_betaA vector containing the Metropolis-Hastings acceptance probability for each iteration of the algorithm. Returned when tempering is being used.

Details

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 multiple-swap and simulated tempering functionality to improve the mixing of the Markov Chain.

References

Fifield, Benjamin, Michael Higgins, Kosuke Imai and Alexander Tarr. (2015) "A New Automated Redistricting Simulator Using Markov Chain Monte Carlo." Working Paper. Available at http://imai.princeton.edu/research/files/redist.pdf.

See Also

redist.ipw for inverse probability weighting functionality.

Examples

Run this code
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)

Run the code above in your browser using DataLab