decisions = pd.DataFrame([
{"choice": "Data source", "setting": "Atlas SQLite (presidential_election_results, county_indicators)",
"reason": "One local, documented database; provenance in dataset_catalog / data_load_log"},
{"choice": "Years", "setting": "2020 (MEDSL) vs 2024 (tonmcg, provisional)",
"reason": "Separate persistent geography from 2024-specific change"},
{"choice": "Outcomes", "setting": "GOP two-party share 2020, 2024, and their difference",
"reason": "Two-party share removes minor-party swings from the shift"},
{"choice": "Covariates", "setting": ", ".join(COVARS), "reason": "Guideline priority list available in the Atlas; z-scored"},
{"choice": "Coverage rule", "setting": "both years + all covariates", "reason": "Drops Connecticut (2024 planning regions)"},
{"choice": "Comparability rule", "setting": "2024/2020 ballots in [0.67, 1.5]",
"reason": f"Drops {int(not_comparable.sum())} county with a source boundary change (Jackson Co., MO)"},
{"choice": "CRS / coordinates", "setting": "EPSG:5070; polygon centroids", "reason": "Audit passed; metres"},
{"choice": "Weights", "setting": "Queen, row-standardised, islands linked", "reason": "Moran's I stable across KNN 4–12"},
{"choice": "Alpha / permutations / seed", "setting": f"{ALPHA} / {PERM} / {SEED}", "reason": "Fixed for every test"},
{"choice": "Cluster transitions", "setting": "LISA (uncorrected) in each year, cross-tabulated", "reason": "Same α both years"},
{"choice": "Shift clusters", "setting": "Gi* analytic with FDR; LISA uncorrected",
"reason": "999-permutation LISA cannot pass FDR at n ≈ 3,100; Gi* carries the corrected map"},
{"choice": "Mean model (shift)", "setting": spatial_fits["shift"]["best"], "reason": "Lowest AIC among OLS, SLM, SEM"},
{"choice": "GWR", "setting": f"adaptive bisquare, k = {best_k}", "reason": "Lowest AICc on 100 / 200 / 400"},
{"choice": "MGWR", "setting": "fixed bisquare, ≤ 4 iterations", "reason": "Adaptive MGWR is expensive at n ≈ 3,100"},
{"choice": "Count model", "setting": "SMR → EB → BYM vs kept-2020 expectation", "reason": "400 draws, 400 tune, 2 chains, thin 5"},
{"choice": "Machine learning", "setting": "XGBoost, 8 state-grouped folds, TreeSHAP", "reason": "Spatial CV avoids neighbour leakage"},
{"choice": "Not fit", "setting": "IDW surface, space-time model",
"reason": "Votes are areal, not a field; spacetime module is a stub (two time points here)"},
])
display(decisions)
fig, axes = plt.subplots(2, 3, figsize=(16, 9.5))
lim = float(np.nanpercentile(np.abs(dy), 99))
counties.plot(column="rep2p_2024", cmap="Reds", vmin=20, vmax=80, ax=axes[0, 0], edgecolor="none", legend=True,
legend_kwds={"shrink": 0.55, "orientation": "horizontal", "pad": 0.02})
axes[0, 0].set_title("GOP two-party share 2024 (%)")
counties.plot(column="shift", cmap="RdBu_r", norm=TwoSlopeNorm(vmin=-lim, vcenter=0, vmax=lim), ax=axes[0, 1],
edgecolor="none", legend=True, legend_kwds={"shrink": 0.55, "orientation": "horizontal", "pad": 0.02})
axes[0, 1].set_title("Shift 2020 → 2024 (pp)")
for lab, col in PERSIST_COLORS.items():
sub = counties[counties["persistence"] == lab]
if len(sub):
sub.plot(ax=axes[0, 2], color=col, edgecolor="none")
axes[0, 2].set_title("LISA persistence 2020 → 2024")
gi_shift.plot(counties, ax=axes[1, 0])
axes[1, 0].set_title("Gi* hot spots of the shift (FDR)")
leg = axes[1, 0].get_legend()
if leg is not None:
leg.set_loc("lower left")
lim_h = float(np.nanpercentile(np.abs(counties["gwr_pct_hispanic"]), 98))
counties.plot(column="gwr_pct_hispanic", cmap="RdBu_r", norm=TwoSlopeNorm(vmin=-lim_h, vcenter=0, vmax=lim_h),
ax=axes[1, 1], edgecolor="none", legend=True,
legend_kwds={"shrink": 0.55, "orientation": "horizontal", "pad": 0.02})
axes[1, 1].set_title("GWR: % Hispanic slope on the shift")
counties.plot(column="p_right", cmap="RdBu_r", vmin=0, vmax=1, ax=axes[1, 2], edgecolor="none", legend=True,
legend_kwds={"shrink": 0.55, "orientation": "horizontal", "pad": 0.02})
axes[1, 2].set_title("BYM: P(moved right)")
for ax in axes.ravel():
ax.set_axis_off()
fig.suptitle("Presidential voting 2020 vs 2024: persistence and shift (one-page summary)",
fontsize=13, fontweight="bold")
plt.tight_layout()
# ALT: Six-panel CONUS summary: 2024 GOP share, the 2020-to-2024 shift, persistent and changing LISA clusters, Gi-star hot spots of the shift, the GWR Hispanic-share slope on the shift, and the BYM probability of a rightward move.
plt.show()