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
)
A redist_map
object.
The number of simulations run before a save point.
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
.
Whether to adaptively tune the lambda parameter so that the Metropolis-Hastings acceptance probability falls between 20% and 40%. Default is FALSE.
Whether to adaptively tune the edgecut probability parameter so that the Metropolis-Hastings acceptance probability falls between 20% and 40%. Default is FALSE.
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
.
A matrix of squared distances between geographic
units. The default is NULL
.
A vector of populations for some sub-group of
interest. The default is NULL
.
A vector of county membership assignments. The default is NULL
.
The number of maps to sample from the preprocessing chain for use as starting values in future simulations. Default is 1.
The maximum distance from the starting map that sampled maps should be. Default is 100 (no restriction).
Maximum number of iterations for random seed-and-grow algorithm to generate starting values. Default is 5000.
Whether to report all summary statistics for each set of
parameter values. Default is TRUE
.
Whether to run separate parameter settings in parallel.
Default is FALSE
.
Number of parallel tasks to run, declared outside of the
function. Default is NULL
.
Whether to open a log to track progress for each parameter combination being tested. Default is FALSE.
Whether to print additional information about the tests.
Default is TRUE
.
redist.findparams
returns a print-out of summary statistics
about each parameter setting.
This function allows users to test multiple parameter settings of
redist_flip
in preparation for a longer run for analysis.
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.
# \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: 7s
#> ■■■ 6% | ETA: 2s
#> ■■■■■■■ 19% | ETA: 1s | MH Acceptance: 0.99
#> ■■■■■■■■■■■ 32% | ETA: 1s | MH Acceptance: 0.99
#> ■■■■■■■■■■■■■■ 44% | ETA: 1s | MH Acceptance: 0.99
#> ■■■■■■■■■■■■■■■■■■ 56% | ETA: 1s | MH Acceptance: 0.99
#> ■■■■■■■■■■■■■■■■■■■■■ 68% | ETA: 1s | MH Acceptance: 0.99
#> ■■■■■■■■■■■■■■■■■■■■■■■■■ 81% | ETA: 0s | MH Acceptance: 0.99
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 94% | 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().
#> ■■ 3% | ETA: 1s
#> ■■■■■■ 15% | ETA: 1s | MH Acceptance: 0.97
#> ■■■■■■■■■ 27% | ETA: 1s | MH Acceptance: 0.97
#> ■■■■■■■■■■■■■ 39% | ETA: 1s | MH Acceptance: 0.97
#> ■■■■■■■■■■■■■■■■ 51% | ETA: 1s | MH Acceptance: 0.97
#> ■■■■■■■■■■■■■■■■■■■■ 63% | ETA: 1s | MH Acceptance: 0.97
#> ■■■■■■■■■■■■■■■■■■■■■■■■ 75% | ETA: 0s | MH Acceptance: 0.97
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 87% | ETA: 0s | MH Acceptance: 0.96
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 98% | 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().
#> ■■■ 7% | ETA: 2s
#> ■■■■■ 14% | ETA: 2s | MH Acceptance: 0.92
#> ■■■■■■■■■ 26% | ETA: 2s | MH Acceptance: 0.92
#> ■■■■■■■■■■■■■ 38% | ETA: 1s | MH Acceptance: 0.92
#> ■■■■■■■■■■■■■■■■ 51% | ETA: 1s | MH Acceptance: 0.92
#> ■■■■■■■■■■■■■■■■■■■■ 64% | ETA: 1s | MH Acceptance: 0.92
#> ■■■■■■■■■■■■■■■■■■■■■■■■ 77% | ETA: 0s | MH Acceptance: 0.92
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 90% | ETA: 0s | MH Acceptance: 0.92
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% | ETA: 0s | MH Acceptance: 0.92
#>
#> ## -------------------------------------
#> ## -------------------------------------
#> ## Parameter Values for Simulation 1
#> ## Edgecut probability = 0.01
#> ## Lambda = 0
#> ## No hard population constraint applied
#> ## -------------------------------------
#> ## Diagnostics:
#> ## Metropolis-Hastings Acceptance Ratio = 0.993
#> ## Mean population parity distance = 0.855
#> ## Median population parity distance = 0.847
#> ## Population parity range = 0.013 1.81
#> ## MCMC Iteration quantiles of population parity median = 0.847 0.933 0.866 0.811
#>
#> ## Mean share of geographies equal to initial assignment = 0.336
#> ## Median share of geographies equal to initial assignment = 0.32
#> ## 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.28 0.32
#> ## -------------------------------------
#> ## -------------------------------------
#>
#> ## -------------------------------------
#> ## -------------------------------------
#> ## Parameter Values for Simulation 1
#> ## Edgecut probability = 0.05
#> ## Lambda = 0
#> ## No hard population constraint applied
#> ## -------------------------------------
#> ## Diagnostics:
#> ## Metropolis-Hastings Acceptance Ratio = 0.964
#> ## Mean population parity distance = 0.856
#> ## Median population parity distance = 0.852
#> ## Population parity range = 0.017 1.886
#> ## MCMC Iteration quantiles of population parity median = 0.906 0.868 0.939 0.808
#>
#> ## Mean share of geographies equal to initial assignment = 0.362
#> ## 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.36 0.4 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.919
#> ## Mean population parity distance = 0.82
#> ## Median population parity distance = 0.816
#> ## Population parity range = 0.008 1.852
#> ## MCMC Iteration quantiles of population parity median = 0.766 0.918 0.814 0.88
#>
#> ## Mean share of geographies equal to initial assignment = 0.365
#> ## 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.28 0.32 0.36 0.44
#> ## -------------------------------------
#> ## -------------------------------------
#>
#> $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.993\n## Mean population parity distance = 0.855\n## Median population parity distance = 0.847\n## Population parity range = 0.013 1.81\n## MCMC Iteration quantiles of population parity median = 0.847 0.933 0.866 0.811\n\n## Mean share of geographies equal to initial assignment = 0.336\n## Median share of geographies equal to initial assignment = 0.32\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.28 0.32\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.964\n## Mean population parity distance = 0.856\n## Median population parity distance = 0.852\n## Population parity range = 0.017 1.886\n## MCMC Iteration quantiles of population parity median = 0.906 0.868 0.939 0.808\n\n## Mean share of geographies equal to initial assignment = 0.362\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.36 0.4 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.919\n## Mean population parity distance = 0.82\n## Median population parity distance = 0.816\n## Population parity range = 0.008 1.852\n## MCMC Iteration quantiles of population parity median = 0.766 0.918 0.814 0.88\n\n## Mean share of geographies equal to initial assignment = 0.365\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.28 0.32 0.36 0.44\n## -------------------------------------\n## -------------------------------------\n\n"
#>
#> $startvals
#> $startvals[[1]]
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 2
#> [4,] 1
#> [5,] 3
#> [6,] 1
#> [7,] 3
#> [8,] 3
#> [9,] 1
#> [10,] 3
#> [11,] 3
#> [12,] 3
#> [13,] 1
#> [14,] 1
#> [15,] 1
#> [16,] 1
#> [17,] 1
#> [18,] 1
#> [19,] 1
#> [20,] 1
#> [21,] 2
#> [22,] 1
#> [23,] 2
#> [24,] 3
#> [25,] 1
#>
#> $startvals[[2]]
#> [,1]
#> [1,] 1
#> [2,] 2
#> [3,] 1
#> [4,] 1
#> [5,] 1
#> [6,] 2
#> [7,] 1
#> [8,] 1
#> [9,] 2
#> [10,] 1
#> [11,] 1
#> [12,] 1
#> [13,] 2
#> [14,] 2
#> [15,] 2
#> [16,] 2
#> [17,] 3
#> [18,] 2
#> [19,] 3
#> [20,] 2
#> [21,] 2
#> [22,] 2
#> [23,] 2
#> [24,] 1
#> [25,] 2
#>
#> $startvals[[3]]
#> [,1]
#> [1,] 2
#> [2,] 2
#> [3,] 3
#> [4,] 2
#> [5,] 2
#> [6,] 2
#> [7,] 2
#> [8,] 2
#> [9,] 2
#> [10,] 2
#> [11,] 2
#> [12,] 2
#> [13,] 1
#> [14,] 2
#> [15,] 2
#> [16,] 3
#> [17,] 3
#> [18,] 3
#> [19,] 3
#> [20,] 2
#> [21,] 3
#> [22,] 2
#> [23,] 2
#> [24,] 2
#> [25,] 2
#>
#>
# }