Awesome-Agent-Skills-for-Empirical-Research redistricting-analysis
Redistricting analysis in R using the redistverse ecosystem. Use whenever the user is working with redist, redistmetrics, ggredist, geomander, adj, alarmdata, PL94171, censable, easycensus, tinytiger, baf, rict, or redistio. Covers the complete pipeline: Census and spatial data loading, adjacency graph construction, SMC/MCMC simulation, constraints (population balance, county splits, VRA compliance), convergence diagnostics, plan metrics (compactness, partisan fairness, splits), visualization, summary tables, and interactive plan drawing. Invoke whenever the user mentions redistricting, gerrymandering, district plans, simulation ensembles, or any redistverse package by name.
git clone https://github.com/brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research
T=$(mktemp -d) && git clone --depth=1 https://github.com/brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/22-christopherkenny-skills/skills/redistricting-analysis" ~/.claude/skills/brycewang-stanford-awesome-agent-skills-for-empirical-research-redistricting-ana && rm -rf "$T"
skills/22-christopherkenny-skills/skills/redistricting-analysis/SKILL.mdRedistricting Analysis with the redistverse
A comprehensive reference for redistricting analysis in R using the redistverse ecosystem (
library(redistverse) loads redist, redistmetrics, ggredist, geomander, sf, and adj).
Standard Analysis Pipeline
- Load data — Download pre-built precinct map + demographics + elections via
, or assemble your ownalarmdata
object and build asf
. → 12-alarmdata.mdredist_map - Prepare adjacency — Verify and edit the adjacency graph (remove water-body edges, fix topological errors). → 08-adj.md, 09-geomander-adjacency.md
- Set constraints — Define population tolerance, county-split penalties, VRA hinge constraints, compactness. → 02-redist-constraints.md
- Simulate — Run
(recommended) or MCMC to generate an ensemble of valid plans. → 01-redist-simulation.mdredist_smc() - Validate — Check convergence (
), R-hat, effective sample size, and plan diversity. → 01-redist-simulation.mdsummary() - Score — Compute compactness, partisan fairness, splits, and other metrics across the ensemble. → 04–06 redistmetrics references
- Visualize & compare — Map plans, plot metric distributions, compare enacted plan to the baseline. → 07-ggredist.md
Quick Navigation
| Package / Topic | Reference |
|---|---|
, , , , , diagnostics | 01-redist-simulation.md |
, , , all soft constraints | 02-redist-constraints.md |
, , , | 03-redist-advanced.md |
— Polsby-Popper, Reock, spanning tree, , functions | 04-redistmetrics-compactness.md |
— efficiency gap, mean-median, bias, declination, functions | 05-redistmetrics-partisan.md |
— county splits, segregation, competitiveness, incumbents, , | 06-redistmetrics-other.md |
— , party color scales, cartographic palettes, | 07-ggredist.md |
— adjacency graph construction, edge operations, coloring, Laplacian | 08-adj.md |
— adjacency construction, contiguity checks, , edge editing | 09-geomander-adjacency.md |
— , , , spatial estimation | 10-geomander-spatial.md |
— downloading VEST, ALARM, DRA, HEDA, election data | 11-geomander-data.md |
— , pre-built datasets, caching, | 12-alarmdata.md |
— Census P.L. 94-171 decennial data ingestion | 13-pl94171.md |
(data + state IDs), (ACS), (TIGER shapefiles) | 14-census-utilities.md |
— download official Census Bureau block assignment files | 15-baf.md |
— summary tables: population, demographics, elections, compactness, splits | 16-rict.md |
— interactive Shiny plan drawing () and adjacency editor () | 17-redistio.md |
Key Data Structures
— an redist_map
sf tibble with one row per precinct. Stores the adjacency graph, population column, number of districts, and population tolerance. Created by redist_map() or downloaded via alarm_50state_map(). Standard columns include pop, pop_black, pop_hisp, pop_asian, pop_white, pop_vap, pop_bvap, ndv (Democratic votes), nrv (Republican votes), and geometry.
— a tibble with one row per district per plan (so redist_plans
nsims × ndists rows, plus reference plans). Stores district assignments in a hidden integer matrix; metrics are added as columns via mutate(). Access the plan matrix with get_plans_matrix().
— an S3 vector class representing an adjacency list. Each element is a zero-indexed integer vector of neighbors. Stored as the adj
adj column in redist_map.
Population Tolerance Guidelines
| Map type | Typical | Legal basis |
|---|---|---|
| Congressional | (±0.5%) | Wesberry v. Sanders |
| State legislative | (±10%) | Reynolds v. Sims |
| Local | Varies by state | State law |