gov = read_csv("https://pages.stat.wisc.edu/~karlrohe/lr333/governor_2026.csv",
col_types = cols(fips = col_character()))The 2026 midterm
Which way did people vote, and who turned out?
I’m curious about the 2026 midterm
Two things:
- Direction. Which way did people vote, compared with last time?
- Turnout. Who showed up to vote?
What can we measure?
- Unit of analysis: a county.
- The race: governor. Most states that elected a governor in 2026 also elected one in 2022. Same office, same place, four years apart.
- The measurement: each county’s votes for the Democrat and the Republican, in both years. 2022 is the official count. 2026 is the unofficial count the day after the election.
28 states. Left out: the New England states, which report by town; Alaska, which reports by legislative district; New York, whose 2022 county counts we could not reconcile.
The data
gov |> select(state_abbr, county, dem_2022, rep_2022, dem_2026, rep_2026, pct_in_2026)# A tibble: 2,014 × 7
state_abbr county dem_2022 rep_2022 dem_2026 rep_2026 pct_in_2026
<chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 AL Autauga 3515 13387 7952 12188 95
2 AL Baldwin 10296 58823 26005 59310 99
3 AL Barbour 2549 3888 3874 3580 99
4 AL Bibb 930 4681 1781 4357 95
5 AL Blount 930 14895 3486 14296 95
6 AL Bullock 1806 802 2880 786 99
7 AL Butler 1937 3856 3239 3496 95
8 AL Calhoun 6912 22158 13386 19006 95
9 AL Chambers 2890 5961 5026 5307 95
10 AL Cherokee 653 6971 1771 6701 87
# ℹ 2,004 more rows
One row is one county. pct_in_2026 is the news site’s estimate of the percent of the vote counted.
2026: NBC News results pages, fetched Nov 4, 2026, about 2 pm Central. 2022: state canvasses, MIT Election Lab, OpenElections.
Two numbers for each county
Direction. The Democrat’s share of the two-party vote, and its change:
\text{share} = \frac{\text{Dem}}{\text{Dem} + \text{Rep}}, \qquad \text{swing} = \text{share}_{2026} - \text{share}_{2022}
Turnout. Votes in 2026 compared with 2022:
\text{turnout} = \frac{2 \times \text{votes}_{2026}}{\text{votes}_{2022} + \text{votes}_{2026}}
1 means the same number of votes as 2022. 1.1 means about 10% more votes in 2026 than in the average of the two years.
gov = gov |> mutate(
share_2022 = dem_2022 / (dem_2022 + rep_2022),
share_2026 = dem_2026 / (dem_2026 + rep_2026),
swing = share_2026 - share_2022,
turnout = 2 * (dem_2026 + rep_2026) / (dem_2022 + rep_2022 + dem_2026 + rep_2026))Direction: every county, every state
Code
gov |> mutate(state = fct_reorder(state, swing, median)) |>
ggplot(aes(100 * swing, state, fill = incumbent_2026)) +
geom_boxplot(outlier.size = 0.6) + geom_vline(xintercept = 0) +
scale_fill_manual(values = party_colors) +
labs(x = "County swing toward the Democrat (percentage points)", y = NULL, fill = "2026 incumbent")The county average is not the state
gov |> group_by(state_abbr) |>
summarise(state_swing = sum(dem_2026) / sum(dem_2026 + rep_2026) - sum(dem_2022) / sum(dem_2022 + rep_2022),
mean_county = mean(swing),
weighted_county = weighted.mean(swing, dem_2026 + rep_2026)) |>
mutate(across(-state_abbr, \(x) round(100 * x, 1))) |>
arrange(desc(state_swing - mean_county)) |> head(8)# A tibble: 8 × 4
state_abbr state_swing mean_county weighted_county
<chr> <dbl> <dbl> <dbl>
1 AL 17.6 13.8 16.8
2 KS -0.9 -4.3 -1.3
3 IL 5.2 2 5.3
4 NE 7.6 4.7 7.5
5 NV 4.7 1.9 4.2
6 OH 16.6 13.9 16.1
7 OK 4 1.4 3.5
8 TN 14.9 12.3 13.7
The mean of the counties counts a county of 2,000 votes as much as a county of 2 million. Weight each county by its votes, and you get the state back.
Groups as columns of 0s and 1s
incumbent_2026 is a word: “open”, “D” (a Democratic governor ran again), or “R” (a Republican governor ran again). lm cannot multiply a word by \beta. So R makes dummy variables, columns of 0s and 1s:
- D_i = 1 if a Democratic governor ran again in county i’s state, and 0 if not.
- R_i = 1 if a Republican governor ran again, and 0 if not.
An open-seat county has 0 in both. “open” is the baseline.
\text{swing}_i = \beta_0 + \beta_1 D_i + \beta_2 R_i + \epsilon_i
| D_i | R_i | expected swing | |
|---|---|---|---|
| open seat | 0 | 0 | \beta_0 |
| Democratic incumbent | 1 | 0 | \beta_0 + \beta_1 |
| Republican incumbent | 0 | 1 | \beta_0 + \beta_2 |
\beta_1 is the difference between counties with a Democratic incumbent and open-seat counties. \beta_2 is the same for a Republican incumbent.
gov = gov |> mutate(incumbent_2026 = factor(incumbent_2026, levels = c("open", "D", "R")))
fit_inc = lm(swing ~ incumbent_2026, data = gov)
rows = match(c("open", "D", "R"), gov$incumbent_2026)
cbind(gov[rows, c("state_abbr", "county", "incumbent_2026")], model.matrix(fit_inc)[rows, ]) state_abbr county incumbent_2026 (Intercept) incumbent_2026D
1 AL Autauga open 1 0
68 AZ Apache D 1 1
83 AR Arkansas R 1 0
incumbent_2026R
1 0
68 0
83 1
Fit it
summary(fit_inc)
Call:
lm(formula = swing ~ incumbent_2026, data = gov)
Residuals:
Min 1Q Median 3Q Max
-0.194653 -0.040774 -0.002093 0.037254 0.295611
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.058426 0.001698 34.410 <2e-16 ***
incumbent_2026D -0.035378 0.004169 -8.486 <2e-16 ***
incumbent_2026R 0.003495 0.003050 1.146 0.252
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.05935 on 2011 degrees of freedom
Multiple R-squared: 0.03915, Adjusted R-squared: 0.0382
F-statistic: 40.97 on 2 and 2011 DF, p-value: < 2.2e-16
Open-seat counties swung 5.8 points toward the Democrat, on average. Where a Democratic governor ran again, counties swung 3.5 points less. Where a Republican governor ran again, 0.3 points more, which is not distinguishable from 0.
State is a column of words
fit_state = lm(swing ~ state, data = gov)
summary(fit_state)
Call:
lm(formula = swing ~ state, data = gov)
Residuals:
Min 1Q Median 3Q Max
-0.13460 -0.01797 -0.00124 0.01690 0.29874
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1381192 0.0037171 37.158 < 2e-16 ***
stateArizona -0.0800828 0.0086909 -9.215 < 2e-16 ***
stateArkansas -0.0932390 0.0051146 -18.230 < 2e-16 ***
stateCalifornia -0.0714157 0.0054569 -13.087 < 2e-16 ***
stateColorado -0.1147554 0.0053180 -21.579 < 2e-16 ***
stateFlorida -0.0571193 0.0052567 -10.866 < 2e-16 ***
stateGeorgia -0.0766252 0.0044316 -17.291 < 2e-16 ***
stateHawaii -0.0348211 0.0156603 -2.224 0.02629 *
stateIdaho -0.0422042 0.0059039 -7.149 1.23e-12 ***
stateIllinois -0.1181962 0.0048332 -24.455 < 2e-16 ***
stateIowa 0.0191476 0.0048132 3.978 7.20e-05 ***
stateKansas -0.1812489 0.0047574 -38.098 < 2e-16 ***
stateMaryland -0.1708034 0.0072380 -23.598 < 2e-16 ***
stateMichigan -0.1477082 0.0049970 -29.559 < 2e-16 ***
stateMinnesota -0.1218353 0.0049454 -24.636 < 2e-16 ***
stateNebraska -0.0913316 0.0048755 -18.733 < 2e-16 ***
stateNevada -0.1186937 0.0082626 -14.365 < 2e-16 ***
stateNew Mexico -0.0983455 0.0064706 -15.199 < 2e-16 ***
stateOhio 0.0008536 0.0049332 0.173 0.86264
stateOklahoma -0.1244939 0.0050832 -24.491 < 2e-16 ***
stateOregon -0.1035987 0.0062874 -16.477 < 2e-16 ***
statePennsylvania -0.1093719 0.0052567 -20.806 < 2e-16 ***
stateSouth Carolina -0.0681307 0.0058259 -11.694 < 2e-16 ***
stateSouth Dakota -0.1427161 0.0052766 -27.047 < 2e-16 ***
stateTennessee -0.0151231 0.0048540 -3.116 0.00186 **
stateTexas -0.0513869 0.0041787 -12.297 < 2e-16 ***
stateWisconsin -0.1317225 0.0051822 -25.418 < 2e-16 ***
stateWyoming -0.1397454 0.0073529 -19.005 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.03043 on 1986 degrees of freedom
Multiple R-squared: 0.7507, Adjusted R-squared: 0.7473
F-statistic: 221.4 on 27 and 1986 DF, p-value: < 2.2e-16
28 states, so R makes 27 dummies, one for each state except the first, Alabama. Each coefficient compares that state’s average county swing to Alabama’s.
State or incumbent?
c(state = summary(fit_state)$r.squared, incumbent = summary(fit_inc)$r.squared) state incumbent
0.7506625 0.0391538
Incumbent explains 4% of the variation in county swing. State explains 75%. Most of the variation is between states, and most of the difference between states is not about who was running.
A dummy times a number
Does a county’s 2022 share predict its 2026 share the same way in every kind of race?
\text{share}_{2026,i} = \beta_0 + \beta_1 \, \text{share}_{2022,i} + \beta_2 D_i + \beta_3 R_i + \beta_4 \, \text{share}_{2022,i} D_i + \beta_5 \, \text{share}_{2022,i} R_i + \epsilon_i
- Open seat: intercept \beta_0, slope \beta_1.
- Democratic incumbent: intercept \beta_0 + \beta_2, slope \beta_1 + \beta_4.
- Republican incumbent: intercept \beta_0 + \beta_3, slope \beta_1 + \beta_5.
Three lines, each with its own intercept and slope.
fit_slopes = lm(share_2026 ~ share_2022 * incumbent_2026, data = gov)
summary(fit_slopes)
Call:
lm(formula = share_2026 ~ share_2022 * incumbent_2026, data = gov)
Residuals:
Min 1Q Median 3Q Max
-0.175378 -0.038404 -0.001125 0.034921 0.294238
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.100186 0.003996 25.071 < 2e-16 ***
share_2022 0.877719 0.010665 82.299 < 2e-16 ***
incumbent_2026D -0.097262 0.010517 -9.248 < 2e-16 ***
incumbent_2026R -0.036740 0.006235 -5.892 4.46e-09 ***
share_2022:incumbent_2026D 0.174193 0.025555 6.816 1.23e-11 ***
share_2022:incumbent_2026R 0.115665 0.020769 5.569 2.90e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.05748 on 2008 degrees of freedom
Multiple R-squared: 0.8695, Adjusted R-squared: 0.8692
F-statistic: 2676 on 5 and 2008 DF, p-value: < 2.2e-16
Code
ggplot(gov, aes(share_2022, share_2026, color = incumbent_2026)) +
geom_point(size = 0.8, alpha = 0.4) +
geom_smooth(method = "lm", formula = y ~ x, se = FALSE) +
geom_abline(linetype = "dashed") +
scale_color_manual(values = party_colors) +
labs(x = "Democrat's two-party share, 2022", y = "Democrat's two-party share, 2026", color = "2026 incumbent")The dashed line is no change. In open-seat races the slope is 0.88: counties that were more Republican in 2022 moved further toward the Democrat. With a Democratic incumbent, the slope is 1.05; with a Republican incumbent, 0.99.
Inside each state
Take out each state’s average, and the 2022 share. What is left over?
gov = as.data.frame(gov)
rownames(gov) = paste(gov$county, gov$state_abbr)
fit = lm(swing ~ state + share_2022, data = gov)The residuals on a map
Code
county_map = map_data("county") |>
mutate(polyname = paste(region, subregion, sep = ",")) |>
left_join(maps::county.fips |> mutate(fips = sprintf("%05d", fips), polyname = str_remove(polyname, ":.*")) |> distinct(),
by = "polyname")
gov$resid = resid(fit)
county_map |> left_join(select(gov, fips, resid), by = "fips") |>
ggplot(aes(long, lat, group = group, fill = pmax(pmin(resid, 0.08), -0.08))) +
geom_polygon() +
geom_polygon(data = map_data("state"), aes(long, lat, group = group), fill = NA, color = "grey40", linewidth = 0.2) +
scale_fill_gradient2(low = "#e66101", mid = "grey95", high = "#2166ac", na.value = "white", name = "residual") +
coord_quickmap() + theme_void(base_size = 13)Blue: the county swung further toward the Democrat than its state and its 2022 share predict. Orange: less.
The biggest residuals
Only counties with at least 90% of the vote counted:
r = resid(fit)[gov$pct_in_2026 >= 90]
sort(r, decreasing = TRUE)[1:8] Seward KS Dakota NE Ford KS Finney KS Thurston NE Texas OK
0.1965715 0.1365648 0.1240442 0.1147155 0.1108246 0.1085853
Hendry FL Colfax NE
0.1082852 0.1078210
sort(r)[1:8] Teton WY Schuyler IL Mora NM McPherson NE Coal OK Johnson IA
-0.14001146 -0.11695164 -0.10449852 -0.09782446 -0.08325829 -0.07991369
Albany WY Latah ID
-0.07767445 -0.07719278
What do the top counties have in common? The bottom ones?
Turnout on a map
Code
county_map |> left_join(select(filter(gov, pct_in_2026 >= 95), fips, turnout), by = "fips") |>
ggplot(aes(long, lat, group = group, fill = pmax(pmin(turnout, 1.2), 0.8))) +
geom_polygon() +
geom_polygon(data = map_data("state"), aes(long, lat, group = group), fill = NA, color = "grey40", linewidth = 0.2) +
scale_fill_gradient2(low = "#e66101", mid = "grey95", high = "#5e3c99", midpoint = 1, na.value = "white", name = "turnout") +
coord_quickmap() + theme_void(base_size = 13)Counties with at least 95% counted. Purple: more votes than 2022. Orange: fewer.
Did the places that turned out also swing?
counted = filter(gov, pct_in_2026 >= 95)
fit_t = lm(swing ~ state + share_2022 + turnout, data = counted)
summary(fit_t)
Call:
lm(formula = swing ~ state + share_2022 + turnout, data = counted)
Residuals:
Min 1Q Median 3Q Max
-0.142462 -0.016990 -0.001124 0.016165 0.156860
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.113855 0.020024 -5.686 1.52e-08 ***
stateArkansas -0.054847 0.005655 -9.699 < 2e-16 ***
stateColorado -0.091973 0.028333 -3.246 0.00119 **
stateFlorida -0.040916 0.005066 -8.076 1.23e-15 ***
stateGeorgia -0.058870 0.004386 -13.421 < 2e-16 ***
stateIdaho -0.059848 0.005736 -10.433 < 2e-16 ***
stateIllinois -0.100799 0.004956 -20.337 < 2e-16 ***
stateIowa 0.026361 0.004514 5.840 6.20e-09 ***
stateKansas -0.167662 0.004598 -36.461 < 2e-16 ***
stateMichigan -0.131371 0.005088 -25.819 < 2e-16 ***
stateMinnesota -0.114535 0.004685 -24.446 < 2e-16 ***
stateNebraska -0.081140 0.004683 -17.328 < 2e-16 ***
stateNevada -0.094959 0.010730 -8.850 < 2e-16 ***
stateNew Mexico -0.079144 0.006292 -12.578 < 2e-16 ***
stateOhio 0.014704 0.004710 3.122 0.00183 **
stateOklahoma -0.096405 0.005273 -18.283 < 2e-16 ***
stateOregon -0.097173 0.008302 -11.705 < 2e-16 ***
statePennsylvania -0.076431 0.005749 -13.293 < 2e-16 ***
stateSouth Carolina -0.068671 0.005450 -12.600 < 2e-16 ***
stateSouth Dakota -0.110842 0.005532 -20.038 < 2e-16 ***
stateTennessee 0.002098 0.004719 0.445 0.65669
stateTexas -0.043993 0.003947 -11.146 < 2e-16 ***
stateWisconsin -0.114097 0.005153 -22.140 < 2e-16 ***
stateWyoming -0.109370 0.007298 -14.987 < 2e-16 ***
share_2022 -0.012388 0.005828 -2.126 0.03368 *
turnout 0.238217 0.018944 12.575 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.02803 on 1751 degrees of freedom
Multiple R-squared: 0.7942, Adjusted R-squared: 0.7913
F-statistic: 270.3 on 25 and 1751 DF, p-value: < 2.2e-16
Within a state, a county whose turnout ratio is 0.1 higher swung, on average, 2.4 points more toward the Democrat.
New voters, or the same voters changing their minds? These data cannot say.
What would you look at next?
- What do the counties with the biggest residuals have in common? What could you join on the county FIPS code to find out?
- The 2026 counts are not final. Which numbers will move when the rest of the vote comes in?
- Which counties are you curious about?
All the code: midterm.R