Null Hypothesis #3
Hypothesis
“US 2020 Presidential Elections went completely different from normal”.
Dataset
MIT U.S. President 1976–2020, with 4287 records, where each record includes
- year and state,
- name of the candidate,
- party of reference (simplified in “democrat”, “republican”, “libertarian”, “other”),
- number of votes collected by the candidate,
- total votes in the state.
Source: Harvard Dataverse, https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/42MVDX
Analysis
Let’s test for significative difference in average votes for presidential candidates, comparing 2020 elections with previous years from 1976, for all parties, then with a special focus on democrats and republicans only.
t.test(us_president_elections_1976_2020$candidatevotes[us_president_elections_1976_2020$year == 2020], us_president_elections_1976_2020$candidatevotes[us_president_elections_1976_2020$year != 2020])Welch Two Sample t-test
t = -0.60784, df = 649.51, p-value = 0.5435
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-107134.71 56485.88
sample estimates:
mean of 2020 mean of other years
289814.4 315138.9###t.test(us_president_elections_1976_2020$candidatevotes[us_president_elections_1976_2020$year == 2020 & us_president_elections_1976_2020$party_simplified == "DEMOCRAT"], us_president_elections_1976_2020$candidatevotes[us_president_elections_1976_2020$year != 2020 & us_president_elections_1976_2020$party_simplified == "DEMOCRAT"])Welch Two Sample t-testGet Giancarlo Vercellino’s stories in your inbox
Join Medium for free to get updates from this writer.
t = 2.2173, df = 53.239, p-value = 0.03089
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
57710.76 1150676.60
sample estimates:
mean of 2020 mean of other years
1593508.0 989314.3###t.test(us_president_elections_1976_2020$candidatevotes[us_president_elections_1976_2020$year == 2020 & us_president_elections_1976_2020$party_simplified == "REPUBLICAN"], us_president_elections_1976_2020$candidatevotes[us_president_elections_1976_2020$year != 2020 & us_president_elections_1976_2020$party_simplified == "REPUBLICAN"])Welch Two Sample t-test
t = 2.2842, df = 54.493, p-value = 0.02628
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
56563.54 867089.52
sample estimates:
mean of 2020 mean of other years
1455219 993392
Comparing 2020 with previous years could allow for understanding if something went south during the last election and the comparison of average votes for each state is quite clear. Let’s go deeper comparing the average of vote differences between democrats and republicans, first comparing all states, then only swing states in 2020 election.
reshaped <- dcast(us_president_elections_1976_2020, year + state ~ party_simplified, value.var = "candidatevotes", fun.aggregate = sum)reshaped$delta_perc_dem_rep <- abs(reshaped$DEMOCRAT - reshaped$REPUBLICAN)/(reshaped$DEMOCRAT + reshaped$REPUBLICAN)t.test(reshaped$delta_perc_dem_rep[reshaped$year == 2020],reshaped$delta_perc_dem_rep[reshaped$year != 2020])Welch Two Sample t-test
t = 1.2645, df = 58.357, p-value = 0.2111
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.01626120 0.07206901
sample estimates:
mean of 2020 mean of other years
0.1922552 0.1643513###swing_states <- c("NEW HAMPSHIRE", "MINNESOTA", "MICHIGAN", "NEVADA", "PENNSYLVANIA", "WISCONSIN", "ARIZONA", "GEORGIA", "NORTH CAROLINA", "FLORIDA", "TEXAS")t.test(reshaped$delta_perc_dem_rep[reshaped$year == 2020 & reshaped$state %in% swing_states],reshaped$delta_perc_dem_rep[reshaped$year != 2020 & reshaped$state %in% swing_states])Welch Two Sample t-test
t = -5.9659, df = 40.446, p-value = 5.076e-07
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.09422931 -0.04655249
sample estimates:
mean of 2020 mean of other years
0.02985205 0.10024295
Comment
2020 US Presidential Election was not statistically different from the previous elections since 1976. The relevant fact was the increase of the electoral base, that significantly grew, both for democrats and republicans. That was surely a truly divisive election, a lot of people went to vote the two main parties, and, if you look at the average percentage differences between democrats and republicans votes inside swing states, well, there was a significant close run between democrats and republicans. And that’s what is called democracy.
Next
The next issue of Null Hypothesis will deepen the bias that are hindering our judgement when it comes to assessing risk in a virtual world. Stay tuned.









