The Shell Game: Swapping the VAR without changing the name or the formula.
The shellgame package reveals how data quality silently degrades during geographic transformations while variable labels remain unchanged. Like a shell game where the ball gets swapped without anyone noticing, geographic transformations swap observed data for imputed data while keeping the same column name.
The key insight: This error is agnostic to:
- Variable: Population, median income, vehicle ownership - doesn't matter
- Tool: R, Python, Stata, ArcGIS - doesn't matter
- Geography: Hennepin County or anywhere else - doesn't matter
What matters: The transformation itself causes the error.
# Install from GitHub
# install.packages("devtools")
devtools::install_github("phinnmarkson/shellgame")library(shellgame)
# Run audit on Hennepin County (example data included)
result <- audit_transformation(
baseline_data = hennepin_zcta_baseline,
zip_zcta_map = hennepin_zip_zcta_map,
hud_crosswalk = hennepin_hud_crosswalk,
county_fips = "27053",
variable_name = "pop"
)
# View results
summary(result)
#> Baseline: 1,391,557 (74 ZCTAs, observed from ACS)
#> After transformation: 1,216,874 (recovered via HUD TOT_RATIO)
#> Loss: 174,683 (-12.6%)
#>
#> The shell game: Same column name, different underlying quantity.What's happening:
- Start: Real measured population (observed data)
- Hop 1 (ZCTA→ZIP): Swap in imputed values via association
- Hop 2 (ZIP→County): Swap in more assumptions via TOT_RATIO
- End: Completely imputed values, still labeled "population"
The cups never announce the swap, so everyone thinks they're still tracking the original ball.
# Visualize the transformation
plot_transformation_loss(result)- Reproducible audit framework - Quantify error at each transformation hop
- Variable agnostic - Works with any ACS variable
- Tool agnostic - Demonstrates the transformation is the problem
- Publication-ready visualizations - Maps and plots included
- Pre-loaded example - Hennepin County data ready to use
vignette("hennepin-example")- Complete worked examplevignette("understanding-shell-game")- Conceptual explanationvignette("data-preparation")- How to audit your own geography
If you use this package in your research, please cite:
Markson, P. (2026). shellgame: The Shell Game - Audit Geographic Data
Transformations. R package version 0.1.0.
https://doi.org/10.5281/zenodo.18634426
Package structure inspired by the excellent areal package by Christopher Prener.
MIT © Phinn Markson

