createRandomPlan {BARD}R Documentation

Create an initial plan for later refinement

Description

These methods create plans starting with random seeds. These plans should be refined with one of the refinement functions.

Usage

createRandomPlan(basemap,ndists)
createRandomPopPlan(basemap,ndists,predvar="POP")
createAssignedPlan(basemap,predvar="BARDPlanID")
createKmeansPlan(basemap,ndists)
createWeightedKmeansPlan( basemap, ndists, centers = c(), weightVar = NULL,
                 trimfactor = 2.5, smallBlock = c("cap", "closest"))
createContiguousPlan(basemap, ndists, predvar = "POP", threshold = 0.05,
                 ssize = 20, usebb = TRUE, maxtries = (10/threshold),
                 neighborstarts = TRUE, fillholes = TRUE, districtonly=FALSE, traceLevel=0)
createContiguousDistrict(basemap, ndists, predvar = "POP", threshold = 0.05,
                 ssize = 20, usebb = TRUE, maxtries = (10/threshold),
                 neighborstarts = TRUE, fillholes = TRUE)
createGreedyContiguousPlan( basemap, ndists, predvar="POP", scoreFUN=calcPopScore,display=FALSE,...)

Arguments

basemap Bard basemap from which to create plan
ndists number of districts to create
predvar name of variable of interest (for createAssignedPlan can be a vector or block assignments)
threshold tolerance threshold for districts being "equal" in population
ssize check up to ssize neighbors at random, shoosing the one with the fewest foreign neighbors
usebb use bounding box compactness
maxtries maximum number of tries to create plan
neighborstarts whether to start new district at neighbors of existing districts
fillholes fill any holes remaining
centers suggested centers for weighted kmeans
weightVar name of weighting variable in basemap, for weighting
trimfactor rescales and trims weights, see below
smallBlock how weighted kmeans handles blocks that are weighted to 0: caps minimimum weights at 1; closest post-assigns zero-weighted blocks to the nearest district
districtonly whether to generate a single district of the plan only
scoreFUN Bard score function
display whether to display plans while creating – for demos and teaching
traceLevel for debugging, tracelevel > 2 will turn on dynamic plotting
... arguments for score function

Details

createKmeansPlan create plans through applying kmeans to the center of each polygon. It tends toward contiguity, but is not guaranteed to produce contiguous plans

createRandomPlan creates plans by random block assignment, as per Grofman [1982], these are highly non-contiguous

createRandomPopPlan creates plans by random block assignment, but caps each district at a population threshold. It will not add a block to a district in formation that will cause the plan to go more than (1+threshold)/(totalpopulation/plan), unless that block would cause all districts to exceed their thresholds. With blocks of single individuals, and a threshold of 0 this is equivalent to the random assignment discusses. in Bush v. Vera [2004]

createGreedyContiguousPlan uses createRandomPopPlan followed by fixContiguityPlan

createContiguousPlan duplicates the algorthim in Cirincione, et. al (see the references). As per pg 196:

``The first algorithm, the contiguity algorithm, begins by randomly selecting a block group to serve as the base of the first district. It then constructs a perimeter list containing the unassigned block groups contiguous to the base block group. The program then randomly selects a block group from the perimeter list to add to the emerging district and adjusts the perimeter list. This process continues until the population of the emerging district achieves the desired district population level. (A newly created district is thrown out if its population deviates by more than 1 from the ideal district average population, which in this case is 581,117.) The next district begins with the random selection of a census block group from among those that touch one of the completed districts.''

(Note that ssize was not included as an option, originally)

In practice this method gets sometimes fails because creation of earlier districts prevents the creation of contiguous later districts. In this case, the method restarts, up to the maximum number of retstarts. If fillholes is true, then even a final failed attempt will be patched with fixUnassignedPlan and fixContiguousPlan, however, beware that this may yield some districts as empty, or districts out of the target criteria range. In this case a warning is issued.

The districtonly option will cause a single district only to be created, which is a quick-and-dirty way of pseudo-sampling districts.

The resulting plan object is flagged as a `single-district' plan and score functions will return the score for that district, not the plan as a whole.

createContiguousDistrict is a wrapper for createContiguousPlan with the districtonly option set.

createWeightedKmeansPlan weights kmeans by a particular variable, most often used with population. This is implemented through block replication, so to limit memory use, the weights are rescaled so that minimum and maximum weights span approximately trimfactor orders of magnitude. Zero-weight blocks can either be capped at 1 an incorporated in the kmeans calculation, or left out and assigned to the closest district, based on the value of smallblock.

Value

Returns a bard plan. Note that this plan is not guaranteed to be contiguous, or equipopulous.

Note

Turning on dynamic plotting is great for teaching and demos, but slows down plan creation by several orders of magnitude.

Author(s)

Micah Altman Micah_Altman@harvard.edu http://www.hmdc.harvard.edu/micah_altman/

References

Micah Altman, 1997. ``Is Automation the Answer? The Computational Complexity of Automated Redistricting'', Rutgers Computer and Technology Law Journal 23 (1), 81-142 http://www.hmdc.harvard.edu/micah_altman/pubpapers.shtml

Altman, M. 1998. Modeling the Effect of Mandatory District Compactness on Partisan Gerrymanders, Political Geography 17:989-1012.

Bush v. Vera, 517 U.S. 952 (1996).

Micah Altman and Michael P. McDonald. 2004. A Computation Intensive Method for Detecting Gerrymanders Paper presented at the annual meeting of the The Midwest Political Science Association, Palmer House Hilton, Chicago, Illinois, Apr 15, 2004. http://www.allacademic.com/meta/p83108_index.html

C. Cirincione , T.A. Darling, and T.G. O'Rourke. 2000. ``Assessing South Carolina's 1990's Congressional Districting.'' Political Geography 19: 189-211.

Grofman, B. 1982, "For single Member Districts Random is Not Equal", In Representation and Redistricting Issues, ed. B. Grofman, A. Lijphart, R. McKay, H. Scarrow. Lexington, MA: Lexington Books.

Micah Altman, Karin Mac Donald, and Michael P. McDonald, 2005. ``From Crayons to Computers: The Evolution of Computer Use in Redistricting'' Social Science Computer Review 23(3): 334-46.

See Also

Interactive editing editPlanInteractive Plan refinement algorithms refineGreedyPlan, refineAnnealPlan, refineGenoudPlan, refineNelderPlan. Plan fixups fixUnassignedPlan , fixContiguityPlan

Examples

  # read in a shapefile with demographic data
    suffolk.map <- importBardShape(
      file.path(system.file("shapefiles", package="BARD"),"suffolk_tracts")
  )
    
    
  # choose number of districts
  ndists <- 5
  
  # create some initial plans
  kplan <- createKmeansPlan(suffolk.map,ndists)
  rplan <- createRandomPlan(suffolk.map,ndists)
  aplan <- createAssignedPlan(suffolk.map,predvar=1:ndists)
  wkplan<-createWeightedKmeansPlan(suffolk.map,ndists,weightVar="POP")

  
  cplan <- createContiguousPlan(suffolk.map,ndists)
  plot(cplan)
  summary(cplan)
  
 
  plot(kplan)
  summary(kplan)
  plot(summary(rplan))
  
  
  c1plan<-createGreedyContiguousPlan(suffolk.map,ndists)
  
  plot(c1plan)
  summary(c1plan)
  
  # single district only 
  c2plan<-createContiguousDistrict(suffolk.map,ndists)
  c2plan
  plot(c2plan)
  summary(c2plan)
  

[Package BARD version 1.09 Index]