Matthew John Bentham (S3923076), John Fergus Murrowood (S3923075)
Last updated: 14 October, 2021
map of political affiliation of state executives
This report will investigate whether the government elected in each state and subsequently the general differences in the public health responses between the two political parties had any effect on the death rate of covid per 1000 people.
Covid-19 deaths per state
covid_deaths_usafacts <- read_csv("covid_deaths_usafacts.csv")[c(3,632)]
censusdata <- read_excel("censusdata.xlsx",skip = 3)[6:56,c(1,13)]data <- data %>% mutate('Deaths per 100,000 people' = (data$`No. of covid deaths
(22/01/2020-10/10/2021)`/data$`population (2019)`)*100000)dem <- c('CA','CO','CT','DE','DC','HI','IL','KS','LA','ME','MI','MN','NV','NJ','NM','NY','NC','OR','PA','RI','VA','WA',"WI","KY")
i <- 1
for (row in data$State){
if (row %in% dem){
data$`Political affiliation of state executive`[i] <- 'Democratic Party'
} else{
ifelse(row != 'MT', data$`Political affiliation of state executive`[i] <- 'Republican Party',i<i-1)
}
i <- i+1
}NOTE: Montana was removed from the dataset as it had a democrat and republican state executive during the data interval
| State | population (2019) | No. of covid deaths (22/01/2020-10/10/2021) | Deaths per 100,000 people | Political affiliation of state executive |
|---|---|---|---|---|
| AL | 4903185 | 14756 | 300.9472 | Republican Party |
| AK | 731545 | 566 | 77.3705 | Republican Party |
| AZ | 7278717 | 20319 | 279.1563 | Republican Party |
| AR | 3017804 | 7810 | 258.7975 | Republican Party |
pal <- c('#457b9d','#e63946')
plot <- ggplot(data = data,aes(x=`Deaths per 100,000 people`,y=`Political affiliation of state executive`,fill=`Political affiliation of state executive`))+
geom_boxplot(show.legend = FALSE)+coord_flip()+labs(title = "Covid deaths in democrat and rebpublican states")+theme(
panel.background = element_rect(fill ='#f1faee'),plot.background =element_rect(fill ='#f1faee') )+
scale_fill_manual(values = pal)
plotInitial inspection shows there is a slight difference in median deaths per 1000 people in red vs blue states
data_rep <- data %>% subset(`Political affiliation of state executive` == "Republican Party")
is_outlier <- function(x) {
return(x < quantile(x, 0.25) - 1.5 * IQR(x) | x > quantile(x, 0.75) + 1.5 * IQR(x))
}
loc <- which(is_outlier(data_rep$`Deaths per 100,000 people`))
out_state <- data_rep[loc,"State"] %>% as.character()
data <- data %>% filter(data$State !=out_state)na <- which(is.na(data))
nan <- sapply(data,is.nan)
inf <- sapply(data,is.infinite)
which(inf | nan | na )## integer(0)
No missing/special values found
data %>% group_by(`Political affiliation of state executive`) %>% summarise(Min = min(data$`Deaths per 100,000 people`,na.rm = TRUE),Q1 = quantile(`Deaths per 100,000 people`,probs = .25,na.rm = TRUE),
Median = median(`Deaths per 100,000 people`, na.rm = TRUE),
Q3 = quantile(`Deaths per 100,000 people`,probs = .75,na.rm = TRUE),
Max = max(`Deaths per 100,000 people`,na.rm = TRUE),
Mean = mean(`Deaths per 100,000 people`, na.rm = TRUE),
SD = sd(`Deaths per 100,000 people`, na.rm = TRUE),
n = n(),
Missing = sum(is.na(`Deaths per 100,000 people`))) -> table1
kbl(table1) %>% kable_classic( html_font = "Timesnewroman") %>% kable_styling(font_size = 16)| Political affiliation of state executive | Min | Q1 | Median | Q3 | Max | Mean | SD | n | Missing |
|---|---|---|---|---|---|---|---|---|---|
| Democratic Party | 58.33861 | 151.6586 | 202.8300 | 234.3376 | 304.8748 | 191.6956 | 68.15866 | 24 | 0 |
| Republican Party | 58.33861 | 182.5347 | 221.0928 | 254.5051 | 329.6542 | 213.8196 | 60.80173 | 26 | 0 |
\(\mu_2\) : mean of total covid-19 deaths in democrat states
Assumptions:
data_rep <- data %>% subset(`Political affiliation of state executive` == "Republican Party")
plot1 <- ggplot(data = data_rep ,mapping = aes(sample=`Deaths per 100,000 people`))+stat_qq_line()+ stat_qq_point()+stat_qq_band(alpha=0.5,distribution = "norm",fill ='#e63946') +
theme(panel.background = element_rect(fill ='#f1faee')
,plot.background =element_rect(fill ='#f1faee'))+
theme_light()+ labs(title = "Q-Q plot for republican data")+xlab( "Deaths per 100,000 people")
plot1 Non-normality is generally characterised by a defined s-shape , as there is only 2 points (with no continuing trend) that fall outside the 95% CI for the normal quantiles , it can be said the data only has a very minor departure from normality towards the lower tail of the distribution. A two sample t-test can still be performed as they are generally robust against minor departures from normality and will tend to maintain the desired significance level (e.g. 0.05) even if normality is not strictly met.
data_dem <- data %>% subset(`Political affiliation of state executive` == "Democratic Party")
plot2 <- ggplot(data = data_dem ,mapping = aes(sample=`Deaths per 100,000 people`))+stat_qq_line()+ stat_qq_point()+stat_qq_band(alpha=0.5,distribution = "norm",fill ='#457b9d') +
theme(panel.background = element_rect(fill ='#f1faee')
,plot.background =element_rect(fill ='#f1faee'))+
theme_light()+ labs(title = "Q-Q plot for democrat data")+xlab( "Deaths per 100,000 people")
plot2 As seen in the Q-Q plot above all the points of the democrat data is within the 95% confidence interval of the normal distribution , meaning normality can be assumed and a two-sample t-test can be performed on the datasets.
tab2 <- leveneTest(data$`Deaths per 100,000 people`~data$`Political affiliation of state executive`)
kbl(tab2) %>% kable_classic( html_font = "Timesnewroman") %>% kable_styling(font_size = 16)| Df | F value | Pr(>F) | |
|---|---|---|---|
| group | 1 | 0.6740034 | 0.4157182 |
| 48 | NA | NA |
The p-value for the Levene’s test of equal variance for no. covid deaths between red and blue states was 0.416. This values is greater than 0.05 , therefore, we fail to reject \(H_0\) and assume equal variance
t.test(data = data,`Deaths per 100,000 people`~`Political affiliation of state executive`,var.equal = TRUE,
alternative = "two.sided")##
## Two Sample t-test
##
## data: Deaths per 100,000 people by Political affiliation of state executive
## t = -1.213, df = 48, p-value = 0.2311
## alternative hypothesis: true difference in means between group Democratic Party and group Republican Party is not equal to 0
## 95 percent confidence interval:
## -58.79523 14.54738
## sample estimates:
## mean in group Democratic Party mean in group Republican Party
## 191.6956 213.8196
p > 0.05 , therefore we fail to reject \(H_0\).
There is no statistically significant difference between red and blue states covid-19 mortality means
Overall the investigation suggests that political affiliation of a state’s representative has no effect on Ovid mortality in said state.
Strengths:
Limitations:
Despite there being a higher mean death count in republican states during initial inspection, there was a statistically insignificant difference between the mean deaths of covid per 1000 people in republican run states compared with states that are run by Democrat governors and therefore no insight into the effectiveness of any political parties ability to reduce the mortality rate of covid was gained.