Code
library(tidyverse)
library(gt)
Mark Rieke
May 23, 2023
National polling of the American electorate can highlight broad-stroke public opinion, but elections and ballot measures are won or lost at the regional level. In a presidential election, for example, statewide deviations from the national polling can result in close national race but skewed electoral college result (see for example, the results of the 2016 election). Since 1997, Cook Political has published a simple metric to measure regional deviations from national sentiment: the Partisan Voter Index (PVI).
To be explicit, the 2022 PVI in any given state,
where
Notably, PVI only considers the two-party voteshare, but not everyone votes for one of the two major parties! There’s always a subset of the electorate that votes for third parties — sometimes third party candidates can siphon a meaningful percentage of the vote. Even when there isn’t an individual third party candidate shaking up the race, regional differences in the general appetite for third parties can make an impact.
For example, in the 2016 election, only 63% of Utah’s electorate voted for Donald Trump or Hillary Clinton, despite the fact that, nationally, the two frontrunners received a total of 94% of votes cast.1 Utah was a far more republican-leaning than the nation in 2016, but the strength of this partisanship was far weaker. Mississippi, on the other hand, was a much stronger partisan state than the nation, sending 98% of votes to either Trump or Clinton.
1 21% of Utah voters cast their ballot for an independent, Evan McMullin, and the remaining split their votes among other minor candidates.
These differences in partisanship across states are important, but so too are the differences in the strength in partisanship. To account for all three, I propose a new metric, 3PVI, defined as follows for a given state,
where
pvi3 <- read_csv("https://raw.githubusercontent.com/markjrieke/2024-potus/main/data/cpvi.csv")
# national results (d/r/o):
# 20: 0.513 / 0.468 / 0.019
# 16: 0.482 / 0.461 / 0.057
pvi3 %>%
# calculate 3pvi
select(-CPVI) %>%
mutate(oth_20 = 1 - (dem_20 + rep_20),
oth_16 = 1 - (dem_16 + rep_16),
pvi_3d20 = dem_20 - 0.513,
pvi_3r20 = rep_20 - 0.468,
pvi_3o20 = oth_20 - 0.019,
pvi_3d16 = dem_16 - 0.482,
pvi_3r16 = rep_16 - 0.461,
pvi_3o16 = oth_16 - 0.057,
pvi_3d = pvi_3d20*0.75 + pvi_3d16*0.25,
pvi_3r = pvi_3r20*0.75 + pvi_3r16*0.25,
pvi_3o = pvi_3o20*0.75 + pvi_3o16*0.25) %>%
select(state = State,
pvi_3d, pvi_3r, pvi_3o,
dem_20, rep_20, oth_20,
dem_16, rep_16, oth_16) %>%
# summarize
gt() %>%
tab_header(title = md("**3-PVI**"),
subtitle = "A new metric for measuring regional partisanship") %>%
cols_label(state = "",
pvi_3d = "PVI-D",
pvi_3r = "PVI-R",
pvi_3o = "PVI-O",
dem_20 = "2020\nBiden",
rep_20 = "2020\nTrump",
oth_20 = "2020\nOther",
dem_16 = "2016\nClinton",
rep_16 = "2016\nTrump",
oth_16 = "2016\nOther") %>%
fmt_percent(-state, decimals = 1) %>%
tab_style(style = cell_fill("#214eba", alpha = 0.25),
locations = cells_body(columns = c(pvi_3d, starts_with("dem")))) %>%
tab_style(style = cell_fill("#ba214e", alpha = 0.25),
locations = cells_body(columns = c(pvi_3r, starts_with("rep")))) %>%
tab_style(style = cell_fill("gray60", alpha = 0.25),
locations = cells_body(columns = c(pvi_3o, starts_with("oth")))) %>%
tab_style(style = cell_text(font = google_font("Libre Franklin"),
weight = 800),
locations = cells_title(groups = "title")) %>%
cols_align(align = "center",
columns = -state) %>%
tab_options(heading.align = "left",
column_labels.border.top.style = "none",
table.border.top.style = "none",
column_labels.border.bottom.style = "none",
column_labels.border.bottom.width = 1,
column_labels.border.bottom.color = "#334422",
table_body.border.top.style = "none",
table_body.border.bottom.color = "white",
heading.border.bottom.style = "none",
data_row.padding = px(7),
column_labels.font.size = px(12)) %>%
opt_interactive()
Like any metric, 3PVI is imperfect and doesn’t capture the full complexity of any given region. The additional utility provided by 3PVI also comes at the cost of additional complexity, which requires more thorough analysis to fully interpret. In situations where this additional complexity is warranted, however, 3PVI is a useful metric that places pastisan strength alongside partisan preferences.
@online{rieke2023,
author = {Rieke, Mark},
title = {3-PVI},
date = {2023-05-23},
url = {https://www.thedatadiary.net/posts/2023-05-23-3pvi/},
langid = {en}
}