Learn R Programming

redist (version 3.0.7)

redist.findparams: Run parameter testing for redist.flip

Description

redist.findparams is used to find optimal parameter values of redist.flip for a given map.

Usage

redist.findparams(
  adj,
  total_pop,
  nsims,
  ndists = NULL,
  init_plan = NULL,
  adapt_lambda = FALSE,
  adapt_eprob = FALSE,
  params,
  ssdmat = NULL,
  group_pop = NULL,
  counties = NULL,
  nstartval_store = 1,
  maxdist_startval = 100,
  maxiterrsg = 5000,
  report_all = TRUE,
  parallel = FALSE,
  ncores = NULL,
  log = FALSE,
  verbose = TRUE,
  adjobj,
  popvec,
  initcds,
  grouppopvec,
  countymembership,
  nthreads
)

Arguments

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 NULL.

init_plan

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.

adapt_lambda

Whether to adaptively tune the lambda parameter so that the Metropolis-Hastings acceptance probability falls between 20% and 40%. Default is FALSE.

adapt_eprob

Whether to adaptively tune the edgecut probability parameter so that the Metropolis-Hastings acceptance probability falls between 20% and 40%. Default is FALSE.

params

A matrix of parameter values to test, such as the output of expand.grid. Parameters accepted for params include eprob, lambda, pop_tol, beta, and constraint.

ssdmat

A matrix of squared distances between geographic units. The default is NULL.

group_pop

A vector of populations for some sub-group of interest. The default is NULL.

counties

A vector of county membership assignments. The default is NULL.

nstartval_store

The number of maps to sample from the preprocessing chain for use as starting values in future simulations. Default is 1.

maxdist_startval

The maximum distance from the starting map that sampled maps should be. Default is 100 (no restriction).

maxiterrsg

Maximum number of iterations for random seed-and-grow algorithm to generate starting values. Default is 5000.

report_all

Whether to report all summary statistics for each set of parameter values. Default is TRUE.

parallel

Whether to run separate parameter settings in parallel. Default is FALSE.

ncores

Number of parallel tasks to run, declared outside of the function. Default is NULL.

log

Whether to open a log to track progress for each parameter combination being tested. Default is FALSE.

verbose

Whether to print additional information about the tests. Default is TRUE.

adjobj

Deprecated, use adj. An adjacency matrix, list, or object of class "SpatialPolygonsDataFrame."

popvec

Deprecated, use total_pop. A vector containing the populations of each geographic unit.

initcds

Deprecated, use init_plan. 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.

grouppopvec

A vector of populations for some sub-group of interest. The default is NULL.

countymembership

Deprecated, use counties. A vector of county membership assignments. The default is NULL.

nthreads

Deprecated, use ncores. Number of parallel tasks to run, declared outside of the function. Default is NULL.

Value

redist.findparams returns a print-out of summary statistics about each parameter setting.

Details

This function allows users to test multiple parameter settings of redist.flip in preparation for a longer run for analysis.

References

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.

Examples

Run this code
# NOT RUN {
data(fl25)
data(fl25_enum)
data(fl25_adj)

## Get an initial partition
init_plan <- fl25_enum$plans[, 5118]

params <- expand.grid(eprob = c(.01, .05, .1))

## Run the algorithm
redist.findparams(adj = fl25_adj, total_pop = fl25$pop,
                  init_plan = init_plan, nsims = 10000, params = params)
# }

Run the code above in your browser using DataLab