Package: redist 4.2.0

Christopher T. Kenny

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_4.2.0.tar.gz
redist_4.2.0.tar.gz(r-4.5-noble)redist_4.2.0.tar.gz(r-4.4-noble)
redist_4.2.0.tgz(r-4.4-emscripten)redist_4.2.0.tgz(r-4.3-emscripten)
redist.pdf |redist.html
redist/json (API)
NEWS

# Install 'redist' in R:
install.packages('redist', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/alarm-redist/redist/issues

Pkgdown site:https://alarm-redist.org

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:
  • 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

openblascppopenmp

3.30 score 259 scripts 381 downloads 133 exports 66 dependencies

Last updated 12 months agofrom:a0286be84d. Checks:OK: 1 NOTE: 1. Indexed: no.

TargetResultDate
Doc / VignettesOKDec 09 2024
R-4.5-linux-x86_64NOTEDec 09 2024

Exports:add_constr_competadd_constr_customadd_constr_edges_remadd_constr_fry_holdadd_constr_grp_hingeadd_constr_grp_inv_hingeadd_constr_grp_powadd_constr_incumbencyadd_constr_log_stadd_constr_multisplitsadd_constr_polsbyadd_constr_pop_devadd_constr_segregationadd_constr_splitsadd_constr_status_quoadd_constr_total_splitsadd_referenceas_redist_mapavg_by_precclassify_planscombine_scorerscompare_planscompetitivenesscounty_splitsdistr_compactnessfilterfreezeget_adjget_existingget_mh_acceptance_rateget_plans_matrixget_plans_weightsget_pop_tolget_sampling_infoget_targetgroup_fracis_contiguousis_county_splitlast_planmake_coresmatch_numbersmerge_bymin_move_paritymuni_splitsnumber_bypartisan_metricsplplan_distancesplan_parityplans_diversityprec_assignmentprec_cooccurrencepullbackredist_ciredist_constrredist_flipredist_flip_annealredist_mapredist_mcmc_ciredist_mergesplitredist_mergesplit_parallelredist_plansredist_quantile_truncredist_shortburstredist_smcredist_smc_ciredist.adjacencyredist.calc.frontier.sizeredist.coarsen.adjacencyredist.combine.mpiredist.compactnessredist.competitivenessredist.constraint.helperredist.county.idredist.county.relabelredist.crsgredist.diagplotredist.dist.pop.overlapredist.distancesredist.district.splitsredist.enumpartredist.find.targetredist.findparamsredist.freezeredist.group.percentredist.identify.coresredist.init.enumpartredist.ipwredist.mcmc.mpiredist.metricsredist.multisplitsredist.muni.splitsredist.parityredist.plot.adjredist.plot.coresredist.plot.distr_qtysredist.plot.histredist.plot.majminredist.plot.mapredist.plot.penaltyredist.plot.plansredist.plot.scatterredist.plot.traceredist.plot.varinforedist.plot.wted.adjredist.prec.pop.overlapredist.prep.enumpartredist.random.subgraphredist.read.enumpartredist.reduce.adjacencyredist.reorderredist.rsgredist.run.enumpartredist.segcalcredist.sink.planredist.smc_is_ciredist.splitsredist.subsetredist.uncoarsenredist.wted.adjscorer_frac_keptscorer_group_pctscorer_multisplitsscorer_polsby_popperscorer_pop_devscorer_splitsscorer_status_quosegregation_indexset_adjset_pop_tolsubset_refsubset_sampledtally_var

Dependencies:classclassIntclicodetoolscolorspaceDBIdigestdoParalleldoRNGdplyre1071fansifarverfastmapforeachgenericsgeosggplot2gluegtablehttpuvisobanditeratorsjsonliteKernSmoothlabelinglaterlatticelibgeoslifecyclemagrittrMASSMatrixmgcvmimemunsellnlmepatchworkpillarpkgconfigpromisesproxyR6RColorBrewerRcppRcppArmadilloRcppThreadredistmetricsrlangrngtoolss2scalesservrsfstringistringrsystibbletidyselectunitsutf8vctrsviridisLitewithrwkxfun

Common Arguments to redist Functions

Rendered fromcommon_args.Rmdusingknitr::rmarkdownon Dec 09 2024.

Last update: 2022-06-16
Started: 2022-06-16

Introduction to redist

Rendered fromredist.Rmdusingknitr::rmarkdownon Dec 09 2024.

Last update: 2024-01-14
Started: 2021-04-07

Map Pre-processing for Special Constraints

Rendered frommap-preproc.Rmdusingknitr::rmarkdownon Dec 09 2024.

Last update: 2024-01-14
Started: 2021-04-07

Redistricting with Flip MCMC

Rendered fromflip.Rmdusingknitr::rmarkdownon Dec 09 2024.

Last update: 2024-01-14
Started: 2024-01-14

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
EPSG TableEPSG
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 redist.group.percent
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 Sizeredist.calc.frontier.size
Coarsen Adjacency Listredist.coarsen.adjacency
Combine successive runs of 'redist.mcmc.mpi'redist.combine.mpi
Create Constraints for SMCredist.constraint.helper
Create County IDsredist.county.id
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 Remainderredist.find.target
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 Mapredist.plot.map
(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 enumpartredist.read.enumpart
Reduce Adjacency Listredist.reduce.adjacency
Reorders district numbersredist.reorder
Redistricting via Random Seed and Grow Algorithmredist.rsg
Runs the enumpart algorithmredist.run.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