Package: redist 4.2.0

redist: Simulation Methods for Legislative Redistricting

Enables researchers to sample redistricting plans from a pre-specified target distribution using Sequential Monte Carlo and Markov Chain Monte Carlo algorithms. The package allows for the implementation of various constraints in the redistricting process such as geographic compactness and population parity requirements. Tools for analysis such as computation of various summary statistics and plotting functionality are also included. The package implements the SMC algorithm of McCartan and Imai (2023) <doi:10.1214/23-AOAS1763>, the enumeration algorithm of Fifield, Imai, Kawahara, and Kenny (2020) <doi:10.1080/2330443X.2020.1791773>, the Flip MCMC algorithm of Fifield, Higgins, Imai and Tarr (2020) <doi:10.1080/10618600.2020.1739532>, the Merge-split/Recombination algorithms of Carter et al. (2019) <arxiv:1911.01503> and DeFord et al. (2021) <doi:10.1162/99608f92.eb30390f>, and the Short-burst optimization algorithm of Cannon et al. (2020) <arxiv:2011.02288>.

Authors:Christopher T. Kenny [aut, cre], Cory McCartan [aut], Ben Fifield [aut], Kosuke Imai [aut], Jun Kawahara [ctb], Alexander Tarr [ctb], Michael Higgins [ctb]

redist.pdf |redist.html
redist/json (API)

# Install redist in R:
install.packages('redist', repos = c('', ''))

Peer review:

Bug tracker:

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
  • EPSG - EPSG Table
  • fl25 - Florida 25 Precinct Shape File
  • fl250 - Florida 250 Precinct Shape File
  • fl25_adj - Florida 25 Precinct File
  • fl25_enum - All Partitions of 25 Precincts into 3 Congressional Districts
  • fl70 - Florida 70 Precinct Shape File
  • iowa - Iowa County File



133 exports 65 stars 3.80 score 66 dependencies 3 dependents

Last updated 3 months agofrom:f6e23cbf418d945a4c6f764f17e0855e4ce163be



Common Arguments to `redist` Functions

Rendered fromcommon_args.Rmdusingknitr::rmarkdownon May 26 2024.

Last update: 2022-06-11
Started: 2022-06-11

Introduction to redist

Rendered fromredist.Rmdusingknitr::rmarkdownon May 26 2024.

Last update: 2024-01-11
Started: 2021-04-04

Map Pre-processing for Special Constraints

Rendered frommap-preproc.Rmdusingknitr::rmarkdownon May 26 2024.

Last update: 2024-01-11
Started: 2021-04-04

Redistricting with Flip MCMC

Rendered fromflip.Rmdusingknitr::rmarkdownon May 26 2024.

Last update: 2024-01-12
Started: 2024-01-11

Readme and manuals

Help Manual

Help pageTopics
Add a reference plan to a set of plansadd_reference
Average a variable by precinctavg_by_prec
Hierarchically classify a set of redistricting plansclassify_plans
Make a comparison between two sets of planscompare_plans
Compute Competitivenesscompetitiveness redist.competitiveness
Sampling constraintsadd_constr_compet add_constr_custom add_constr_edges_rem add_constr_fry_hold add_constr_grp_hinge add_constr_grp_inv_hinge add_constr_grp_pow add_constr_incumbency add_constr_log_st add_constr_multisplits add_constr_polsby add_constr_pop_dev add_constr_segregation add_constr_splits add_constr_status_quo add_constr_total_splits constraints
Count County Splitscounty_splits redist.splits
Calculate compactness measures for a set of plansdistr_compactness redist.compactness
Florida 25 Precinct Shape Filefl25
Florida 25 Precinct Filefl25_adj
All Partitions of 25 Precincts into 3 Congressional Districts (No Population Constraint)fl25_enum
Florida 250 Precinct Shape Filefl250
Florida 70 Precinct Shape Filefl70
Freeze Parts of a Mapfreeze redist.freeze
Get and set the adjacency graph from a 'redist_map' objectget_adj set_adj
Extract the existing district assignment from a 'redist_map' objectget_existing
Extract the Metropolis Hastings Acceptance Rateget_mh_acceptance_rate
Extract the matrix of district assignments from a redistricting simulationas.matrix.redist_plans get_plans_matrix
Extract the sampling weights from a redistricting simulation.get_plans_weights weights.redist_plans
Get and set the population tolerance from a 'redist_map' objectget_pop_tol set_pop_tol
Extract the sampling information from a redistricting simulationget_sampling_info
Extract the target district population from a 'redist_map' objectget_target
Calculate Group Proportion by Districtgroup_frac
Iowa County Fileiowa
Check that a 'redist_map' object is contiguousis_contiguous
Identify which counties are split by a planis_county_split
Extract the last plan from a set of planslast_plan
Identify Cores of a District (Heuristic)make_cores redist.identify.cores
Renumber districts to match an existing planmatch_numbers
Merge map unitsmerge_by
Calculates Sparse Population Moves to Minimize Population Deviationmin_move_parity
Counts the Number of Municipalities Split Between Districtsmuni_splits redist.muni.splits
Renumber districts to match a quantity of interestnumber_by
Calculate gerrymandering metrics for a set of planspartisan_metrics redist.metrics
Access the Current 'redist_plans()' Objectpl
Compute Distance between Partitionsplan_distances redist.distances
Calculate the diversity of a set of plansplans_diversity
Plot a plan classificationplot.redist_classified
Visualize constraintsplot.redist_constr
Plot a 'redist_map'plot.redist_map
Summary plots for '\link{redist_plans}'plot.redist_plans
Extract the district assignments for a precinct across all simulated plansprec_assignment
Compute a matrix of precinct co-occurrencesprec_cooccurrence
Print redist_classified objectsprint.redist_classified
Generic to print redist_constrprint.redist_constr
Generic to print redist_mapprint.redist_map
Print method for 'redist_plans'print.redist_plans
Pull back plans to unmerged unitspullback
Combine multiple sets of redistricting plansrbind.redist_plans
Confidence Intervals for SMC and MCMC Estimatesredist_ci redist_mcmc_ci redist_smc_ci
Set up constraints for samplingredist_constr
'Flip' Markov Chain Monte Carlo Redistricting Simulation (Fifield et al. 2020)redist_flip
Flip MCMC Redistricting Simulator using Simulated Annealingredist_flip_anneal
Create a 'redist_map' object.as_redist_map redist_map
Merge-Split/Recombination MCMC Redistricting Sampler (Carter et al. 2019)redist_mergesplit
Parallel Merge-Split/Recombination MCMC Redistricting Samplerredist_mergesplit_parallel
A set of redistricting plansredist_plans
Helper function to truncate importance weightsredist_quantile_trunc
Redistricting Optimization through Short Burstsredist_shortburst
SMC Redistricting Sampler (McCartan and Imai 2023)redist_smc
Adjacency List functionality for redistredist.adjacency
Calculate Frontier
Coarsen Adjacency Listredist.coarsen.adjacency
Combine successive runs of 'redist.mcmc.mpi'redist.combine.mpi
Create Constraints for SMCredist.constraint.helper
Create County
Relabel Discontinuous Countiesredist.county.relabel
Redistricting via Compact Random Seed and Grow Algorithmredist.crsg
Diagnostic plotting functionality for MCMC redistricting.redist.diagplot
Compare the Population Overlap Across Plans at the District Levelredist.dist.pop.overlap
Counts the Number of Counties within a Districtredist.district.splits
Enumerate All Parititions (Fifield et al. 2020)redist.enumpart
Find Majority Minority
Run parameter testing for 'redist_flip'redist.findparams
Initialize enumpartredist.init.enumpart
Inverse probability reweighting for MCMC Redistrictingredist.ipw
MCMC Redistricting Simulator using MPIredist.mcmc.mpi
Counts the Number of Counties Split Between 3 or More Districtsredist.multisplits
Calculates Maximum Deviation from Population Parityplan_parity redist.parity
Creates a Graph Overlayredist.plot.adj
Plot Coresredist.plot.cores
Plot quantities by districtredist.plot.distr_qtys
Plot a histogram of a summary statistichist.redist_plans redist.plot.hist
Majority Minority Plotsredist.plot.majmin
Plot a
(Deprecated) Visualize Group Power Penaltyredist.plot.penalty
Plot a district assignmentredist.plot.plans
Scatter plot of plan summary statisticsredist.plot.scatter
Make a traceplot for a summary statisticredist.plot.trace
Static Variation of Information Plotredist.plot.varinfo
Plot Weighted Border Adjacencyredist.plot.wted.adj
Compare the Population Overlap Across Plans at the Precinct Levelredist.prec.pop.overlap
Prepares a run of the enumpart algorithm by ordering edgesredist.prep.enumpart
Return a random subgraph of a shaperedist.random.subgraph
Read Results from
Reduce Adjacency Listredist.reduce.adjacency
Reorders district numbersredist.reorder
Redistricting via Random Seed and Grow Algorithmredist.rsg
Runs the enumpart
Sink Plans to 1:ndistsredist.sink.plan
(Deprecated) Confidence Intervals for Importance Sampling Estimatesredist.smc_is_ci
Subset a shpredist.subset
Uncoarsen a District Matrixredist.uncoarsen
Create Weighted Adjacency Dataredist.wted.adj
Scoring functions for 'redist_shortburst'scorers scorer_frac_kept scorer_group_pct scorer_multisplits scorer_polsby_popper scorer_pop_dev scorer_splits scorer_status_quo
Scoring function arithmetic*.redist_scorer +.redist_scorer -.redist_scorer scorer-arith
Combine scoring functionscbind.redist_scorer combine_scorers scorer-combine
Segregation index calculation for MCMC redistricting.redist.segcalc segregation_index
Subset to sampled or reference drawssubset_ref subset_sampled
Diagnostic information on sampled planssummary.redist_plans
Tally a variable by districttally_var