The project target

In this project I want to get an answer to the next research question:

Research question: is there any connection between crime rates and political orientation of the state?

Why connection can be possible: speaking in plain speculative language, political orientation can be presented as derivative of world-view. Different world-view means different norms and values, as well as different reactions to norms violations. So, people with different political orientations may treat crimes differently: don’t see much of a problem and be involved in crimes or on the opposite, see a huge problem and make all possible efforts to eradicate crimes (via different mechanism of political and citizen participation).

Operationalisation(-s)

Political orientation: state political orientation is marked by the party of candidate (republican or democrats), to whom a state gave the biggest amount of electoral college votes. The USArrests dataset describes situation as of 1973. The closest elections have been held in 1972, but I’ve decided to choose elections of 1976. The reason here is next: in 1972 we have a very tiny amount of category representatives: only 2/50 states voted blue. Using such a small amount of observations can lead to misleading conclusions. At the same time, in the case of 1976 we don’t have such a problem: 23 states voted blue and 27 states voted red (Crockett, 2016).

Figure 1. Crockett, Z. (2016). Presidential college voting in 1972 and 1976, by state. How your state voted in 2016, compared to 15 prior elections. Vox. Retrieved September 13, 2022, from https://www.vox.com/policy-and-politics/2016/11/8/13563106/election-map-historical-vote

 

Preparation

Actions done:

  • Libraries are uploaded;
  • Data is imported;
  • Rows’ names became a separate column;
  • Table with states’ political orientation was manually created on the basis of US Archives: https://www.archives.gov/electoral-college/1976. After it this table was joined with USArrests dataframe.
library(dplyr)
library(knitr)
library(plotly)
library(formattable)

data("USArrests")
raw_data = USArrests 
  
State = rownames(raw_data)
rownames(raw_data) = NULL
work_data = cbind(State, raw_data)

polit_or_data = read.csv("polit_orient.csv")

work_data = work_data %>% 
  inner_join(polit_or_data) %>% 
  select(State, Polit_orient, Murder, Assault, Rape, UrbanPop)

Final appearance of work dataframe:

pres_data = work_data %>% 
  rename('Political orientation' = Polit_orient)
kable(head(pres_data, 3))
State Political orientation Murder Assault Rape UrbanPop
Alabama Democrat 13.2 236 21.2 58
Alaska Republican 10.0 263 44.5 48
Arizona Republican 8.1 294 31.0 80

 

Preliminary analysis

Let’s see if there is visible difference in amount of crime depending on the political orientation of a state. For this purpose I will begin with simple — I will look at average amount of crimes per 100k people in groups of democrat and republican states.

Descriptive statistics: average crime rates

formattable(
  work_data %>% 
    group_by(Polit_orient) %>% 
    summarise(
      'Murder (avg)' = round(mean(Murder), 2),
      'Assault (avg)' = round(mean(Assault), 2),
      'Rape (avg)' = round(mean(Rape), 2),
    ) %>% 
    rename('Political orientation' = Polit_orient), 
  align = c("l", "l", "l", "l"),
  list(
    `Political orientation` = formatter("span", style = ~ style(color = "grey", font.weight = "bold")), 
    `Murder (avg)` = color_bar("lightgray"),
    `Assault (avg)` = color_bar("lightgray"),
    `Rape (avg)` = color_bar("lightgray")))
Political orientation Murder (avg) Assault (avg) Rape (avg)
Democrat 9.75 189.78 19.96
Republican 6.11 154.56 22.32

Description: on average, in democrat states there is noticeably higher amount of murders: 9.75 murders per 100k people, while in case of republicans this number is 6.11 per 100k people. As for assaults, situation on average hers is also worse for democrats (but not that noticeably as in case of murders): 189.78 assaults per 100k in blue states versus 154.56 per 100k in red states. In case of rapes situation is changing: now slightly higher average number can be seen in republican states: 22.32 rapes per 100k people, at the same time in democrat states — 19.96 rapes per 100k people.

Well, first impression is made, but we still cannot say something about connection between crime rates and state political orientation. Firstly, the can be some outlier-states that lead to misleading averages — so, let’s build box plots to annihilate this possibility. Secondly, at this point difference is not proved to be statistically significant — T-tests are needed.

Let’s dive deeper!

 

Full-fledged analysis

Murder

plot_ly(
  data = work_data,
  y = ~ Murder,
  x = ~ Polit_orient,
  type = "box",
  color = ~ Polit_orient,
  colors = c("blue", "red"),
  showlegend = FALSE, 
  boxpoints = "all",
  hoverinfo = "text",
  hovertext = 
    paste0(
      "State: ", work_data$State, " (", work_data$Polit_orient, ")" , 
      "<br>Murders per 100k: ", work_data$Murder)) %>% 
  layout(
    yaxis = list(title = 'Mudrers per 100k people'),
    xaxis = list(title = 'State political orientation'))

Description: no extreme outliers. Clear picture of the fact that there is lower murders (on average) in republican states compared to democrat ones: the box plot describing democrat states is noticeably above the box plot describing republican states.

t.test(work_data$Murder ~ as.factor(work_data$Polit_orient))
## 
##  Welch Two Sample t-test
## 
## data:  work_data$Murder by as.factor(work_data$Polit_orient)
## t = 3.1301, df = 39.441, p-value = 0.003284
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  1.287704 5.987015
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 9.752174                 6.114815

T-test confirmation: true, p-value is 0.003284 which is lower than 0.05. It means that difference in amount of murders depending on state political orientation can be treated as statistically significant.

 

Assault

plot_ly(
  data = work_data,
  y = ~ Assault,
  x = ~ Polit_orient,
  type = "box",
  color = ~ Polit_orient,
  colors = c("blue", "red"),
  showlegend = FALSE, 
  boxpoints = "all",
  hoverinfo = "text",
  hovertext = 
    paste0(
      "State: ", work_data$State, " (", work_data$Polit_orient, ")" , 
      "<br>Assaults per 100k: ", work_data$Assault)) %>% 
  layout(
    yaxis = list(title = 'Assaults per 100k people'),
    xaxis = list(title = 'State political orientation'))

Description: no extreme outliers. It is possible to see difference in median, 75 percentile and maximum — in case of democrat these mark are markedly higher compared to the ones of republican party. At the same time in case of minimum and 25 percentile difference are barely seen.

t.test(work_data$Assault ~ as.factor(work_data$Polit_orient))
## 
##  Welch Two Sample t-test
## 
## data:  work_data$Assault by as.factor(work_data$Polit_orient)
## t = 1.4962, df = 44.805, p-value = 0.1416
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -12.20017  82.65427
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 189.7826                 154.5556

T-test confirmation: false, p-value is 0.1416 which is higher than 0.05. It means that difference in amount of assaults depending on state political orientation can be treated as statistically non-significant.

 

Rape

plot_ly(
  data = work_data,
  y = ~ Rape,
  x = ~ Polit_orient,
  type = "box",
  color = ~ Polit_orient,
  colors = c("blue", "red"),
  showlegend = FALSE, 
  boxpoints = "all",
  hoverinfo = "text",
  hovertext = 
    paste0(
      "State: ", work_data$State, " (", work_data$Polit_orient, ")" , 
      "<br>Rapes per 100k: ", work_data$Rape)) %>% 
  layout(
    yaxis = list(title = 'Rapes per 100k people'),
    xaxis = list(title = 'State political orientation'))

Description: no extreme outliers. Although median of both boxplots are more or less the same, republican states are much-much more varying compared to democrat ones: its IQR is twice as big as the IQR of democrat. Going deeper, 25 percentile of republican is lower than the same mark of democrat — so, it won’t be correct to say that democrat states have less amount of rapes. But, at the same time it won’t be correct to say the opposite, to say that democrat states have bigger amount of rapes — its 75 percentile is lower than the same mark of republican.

t.test(work_data$Rape ~ as.factor(work_data$Polit_orient))
## 
##  Welch Two Sample t-test
## 
## data:  work_data$Rape by as.factor(work_data$Polit_orient)
## t = -0.92533, df = 41.993, p-value = 0.3601
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.513400  2.789406
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 19.95652                 22.31852

T-test confirmation: false, p-value is 0.1416 which is higher than 0.05. It means that difference in amount of rapes depending on state political orientation can be treated as statistically non-significant.

 

Conclusion

The key result of this mini-research is the positive answer to RQ: yes, there is connection between crime rates and political orientation of a state. Such connection is represented by the next fact: in democrat states (on average) there are significantly more murders per 100k compared to republican ones. To complete the picture, two points should be noted. The 1-st, there is no statistically significant connection between other types of crimes in USArrests (rape and assault) and political orientation. The 2-nd, between time when crime rates were recorded and political orientation was defined there is 3 years gap. Within these 3 years lots of things could happen — such things that could greatly change states’ averages, make significant connections non-significant and vice-versa. So, to make more solid conclusion some deeper research is needed.

What was done beyond necessary

4 extra things

  • Usage of statistical tests: T-tests were used to see if difference between red and blue states are statistically significant;
  • Advanced usage of Plotly: custom hover text of data points, presence of boxpoints;
  • Change of HTML-output: now background of HTML-page is slightly green;
  • Usage of formattable: there is the table with bars inside.

Bibliography

Crockett, Z. (2016). Presidential college voting in 1972 and 1976, by state. How your state voted in 2016, compared to 15 prior elections. Vox. Retrieved September 13, 2022, from https://www.vox.com/policy-and-politics/2016/11/8/13563106/election-map-historical-vote