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

redist.findparams(
  map,
  nsims,
  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
)

Arguments

map

A redist_map object.

nsims

The number of simulations run before a save point.

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.

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

# \donttest{
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))

# Make map
map_fl <- redist_map(fl25, ndists = 3, pop_tol = 0.2)
#> Projecting to CRS 3857
## Run the algorithm
redist.findparams(map_fl,
    init_plan = init_plan, nsims = 10000, params = params)
#> ## ------------------------------
#>  ## redist.findparams(): Parameter tuning for redist.flip()
#>  ## Searching over 3 parameter combinations
#>  ## ------------------------------
#> 
#> 
#> ── redist_flip() ────────────────────────────────────────────────────────────────────────────────────────────────────────
#> 
#> ── Automated Redistricting Simulation Using Markov Chain Monte Carlo ──
#>  Preprocessing data.
#>  Starting swMH().
#> 
   0% | ETA: 5s

#> 
■■                                 3% | ETA: 4s

#> 
■■■                                7% | ETA: 4s

#> 
■■■■■■                            17% | ETA:  3s | MH Acceptance: 0.99

#> 
■■■■■■■■■                         26% | ETA:  2s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■                      35% | ETA:  2s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■                    45% | ETA:  1s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■                 54% | ETA:  1s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■■■               61% | ETA:  1s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■■■■              64% | ETA:  1s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■■■■■■■           73% | ETA:  1s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■        83% | ETA:  0s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     92% | ETA:  0s | MH Acceptance: 0.99

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s | MH Acceptance: 0.99

#> 
#> 
#> ── redist_flip() ────────────────────────────────────────────────────────────────────────────────────────────────────────
#> 
#> ── Automated Redistricting Simulation Using Markov Chain Monte Carlo ──
#>  Preprocessing data.
#>  Starting swMH().
#> 
   0% | ETA: 4s

#> 
   0% | ETA:43s

#> 
■■■■                              10% | ETA: 3s

#> 
■■■■■■■                           19% | ETA:  2s | MH Acceptance: 0.96

#> 
■■■■■■■■■■                        29% | ETA:  2s | MH Acceptance: 0.97

#> 
■■■■■■■■■■■■                      38% | ETA:  2s | MH Acceptance: 0.97

#> 
■■■■■■■■■■■■■■■                   47% | ETA:  1s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■                56% | ETA:  1s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■■               59% | ETA:  1s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  1s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■■■■■■■          76% | ETA:  1s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■       86% | ETA:  0s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     94% | ETA:  0s | MH Acceptance: 0.96

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s | MH Acceptance: 0.96

#> 
#> 
#> ── redist_flip() ────────────────────────────────────────────────────────────────────────────────────────────────────────
#> 
#> ── Automated Redistricting Simulation Using Markov Chain Monte Carlo ──
#>  Preprocessing data.
#>  Starting swMH().
#> 
■■                                 2% | ETA: 2s

#> 
■■■■                              11% | ETA:  2s | MH Acceptance: 0.92

#> 
■■■■■■■                           19% | ETA:  2s | MH Acceptance: 0.92

#> 
■■■■■■■■■                         28% | ETA:  2s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■                       33% | ETA:  2s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■                     40% | ETA:  2s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■                  49% | ETA:  1s | MH Acceptance: 0.94

#> 
■■■■■■■■■■■■■■■■■■■               59% | ETA:  1s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■■■■■■■            68% | ETA:  1s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■■■■■■■■■          76% | ETA:  1s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■        85% | ETA:  0s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     92% | ETA:  0s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    97% | ETA:  0s | MH Acceptance: 0.93

#> 
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s | MH Acceptance: 0.93

#> 
#>  ## -------------------------------------
#>  ## -------------------------------------
#>  ## Parameter Values for Simulation 1 
#> ## Edgecut probability = 0.01
#> ## Lambda = 0
#> ## No hard population constraint applied
#> ## -------------------------------------
#> ## Diagnostics:
#> ## Metropolis-Hastings Acceptance Ratio = 0.992
#> ## Mean population parity distance = 0.868
#> ## Median population parity distance = 0.868
#> ## Population parity range = 0.008 1.912
#> ## MCMC Iteration quantiles of population parity median = 0.905 0.935 0.971 0.935
#> 
#> ## Mean share of geographies equal to initial assignment = 0.305
#> ## Median share of geographies equal to initial assignment = 0.28
#> ## Range of share of geographies equal to initial assignment = 0 1
#> ## MCMC Iteration quantiles of geography distance to initial assignment = 0.36 0.24 0.28 0.24
#> ## -------------------------------------
#> ## -------------------------------------
#> 
#>  ## -------------------------------------
#>  ## -------------------------------------
#>  ## Parameter Values for Simulation 1 
#> ## Edgecut probability = 0.05
#> ## Lambda = 0
#> ## No hard population constraint applied
#> ## -------------------------------------
#> ## Diagnostics:
#> ## Metropolis-Hastings Acceptance Ratio = 0.963
#> ## Mean population parity distance = 0.812
#> ## Median population parity distance = 0.824
#> ## Population parity range = 0.008 1.889
#> ## MCMC Iteration quantiles of population parity median = 0.866 0.847 0.658 0.991
#> 
#> ## Mean share of geographies equal to initial assignment = 0.358
#> ## Median share of geographies equal to initial assignment = 0.36
#> ## Range of share of geographies equal to initial assignment = 0 0.96
#> ## MCMC Iteration quantiles of geography distance to initial assignment = 0.32 0.32 0.32 0.36
#> ## -------------------------------------
#> ## -------------------------------------
#> 
#>  ## -------------------------------------
#>  ## -------------------------------------
#>  ## Parameter Values for Simulation 1 
#> ## Edgecut probability = 0.1
#> ## Lambda = 0
#> ## No hard population constraint applied
#> ## -------------------------------------
#> ## Diagnostics:
#> ## Metropolis-Hastings Acceptance Ratio = 0.926
#> ## Mean population parity distance = 0.845
#> ## Median population parity distance = 0.842
#> ## Population parity range = 0.007 1.903
#> ## MCMC Iteration quantiles of population parity median = 0.766 0.805 0.772 0.671
#> 
#> ## Mean share of geographies equal to initial assignment = 0.38
#> ## Median share of geographies equal to initial assignment = 0.4
#> ## Range of share of geographies equal to initial assignment = 0 0.96
#> ## MCMC Iteration quantiles of geography distance to initial assignment = 0.4 0.28 0.48 0.4
#> ## -------------------------------------
#> ## -------------------------------------
#> 
#> $diagnostics
#> [1] " ## -------------------------------------\n ## -------------------------------------\n ## Parameter Values for Simulation 1 \n## Edgecut probability = 0.01\n## Lambda = 0\n## No hard population constraint applied\n## -------------------------------------\n## Diagnostics:\n## Metropolis-Hastings Acceptance Ratio = 0.992\n## Mean population parity distance = 0.868\n## Median population parity distance = 0.868\n## Population parity range = 0.008 1.912\n## MCMC Iteration quantiles of population parity median = 0.905 0.935 0.971 0.935\n\n## Mean share of geographies equal to initial assignment = 0.305\n## Median share of geographies equal to initial assignment = 0.28\n## Range of share of geographies equal to initial assignment = 0 1\n## MCMC Iteration quantiles of geography distance to initial assignment = 0.36 0.24 0.28 0.24\n## -------------------------------------\n## -------------------------------------\n\n ## -------------------------------------\n ## -------------------------------------\n ## Parameter Values for Simulation 1 \n## Edgecut probability = 0.05\n## Lambda = 0\n## No hard population constraint applied\n## -------------------------------------\n## Diagnostics:\n## Metropolis-Hastings Acceptance Ratio = 0.963\n## Mean population parity distance = 0.812\n## Median population parity distance = 0.824\n## Population parity range = 0.008 1.889\n## MCMC Iteration quantiles of population parity median = 0.866 0.847 0.658 0.991\n\n## Mean share of geographies equal to initial assignment = 0.358\n## Median share of geographies equal to initial assignment = 0.36\n## Range of share of geographies equal to initial assignment = 0 0.96\n## MCMC Iteration quantiles of geography distance to initial assignment = 0.32 0.32 0.32 0.36\n## -------------------------------------\n## -------------------------------------\n\n ## -------------------------------------\n ## -------------------------------------\n ## Parameter Values for Simulation 1 \n## Edgecut probability = 0.1\n## Lambda = 0\n## No hard population constraint applied\n## -------------------------------------\n## Diagnostics:\n## Metropolis-Hastings Acceptance Ratio = 0.926\n## Mean population parity distance = 0.845\n## Median population parity distance = 0.842\n## Population parity range = 0.007 1.903\n## MCMC Iteration quantiles of population parity median = 0.766 0.805 0.772 0.671\n\n## Mean share of geographies equal to initial assignment = 0.38\n## Median share of geographies equal to initial assignment = 0.4\n## Range of share of geographies equal to initial assignment = 0 0.96\n## MCMC Iteration quantiles of geography distance to initial assignment = 0.4 0.28 0.48 0.4\n## -------------------------------------\n## -------------------------------------\n\n"
#> 
#> $startvals
#> $startvals[[1]]
#>       [,1]
#>  [1,]    3
#>  [2,]    1
#>  [3,]    3
#>  [4,]    3
#>  [5,]    3
#>  [6,]    3
#>  [7,]    3
#>  [8,]    3
#>  [9,]    2
#> [10,]    3
#> [11,]    3
#> [12,]    3
#> [13,]    2
#> [14,]    2
#> [15,]    2
#> [16,]    1
#> [17,]    1
#> [18,]    1
#> [19,]    3
#> [20,]    3
#> [21,]    3
#> [22,]    3
#> [23,]    3
#> [24,]    3
#> [25,]    3
#> 
#> $startvals[[2]]
#>       [,1]
#>  [1,]    3
#>  [2,]    3
#>  [3,]    1
#>  [4,]    1
#>  [5,]    2
#>  [6,]    1
#>  [7,]    3
#>  [8,]    3
#>  [9,]    1
#> [10,]    1
#> [11,]    1
#> [12,]    1
#> [13,]    1
#> [14,]    1
#> [15,]    1
#> [16,]    3
#> [17,]    3
#> [18,]    1
#> [19,]    3
#> [20,]    3
#> [21,]    1
#> [22,]    3
#> [23,]    1
#> [24,]    2
#> [25,]    3
#> 
#> $startvals[[3]]
#>       [,1]
#>  [1,]    2
#>  [2,]    2
#>  [3,]    1
#>  [4,]    1
#>  [5,]    1
#>  [6,]    2
#>  [7,]    1
#>  [8,]    2
#>  [9,]    3
#> [10,]    2
#> [11,]    2
#> [12,]    2
#> [13,]    2
#> [14,]    2
#> [15,]    2
#> [16,]    1
#> [17,]    1
#> [18,]    1
#> [19,]    1
#> [20,]    1
#> [21,]    1
#> [22,]    1
#> [23,]    1
#> [24,]    1
#> [25,]    1
#> 
#> 
# }