For this assignment, revisit Question 3 of the tutorial example on leader assassination attempts. (The questions, complete solutions and the data file are available on cuLearn.) The dataset set in the file leaders.csv contains the following variables :

Name Description
country The name of the country
year Year of assassination
leadername Name of leader who was targeted
age Age of the targeted leader
politybefore Average polity score during the 3 year period prior to the attempt
polityafter Average polity score during the 3 year period after the attempt
civilwarbefore 1 if country is in civil war during the 3 year period prior to the attempt, or 0
civilwarafter 1 if country is in civil war during the 3 year period after the attempt, or 0
interwarbefore 1 if country is in international war during the 3 year period prior to the attempt, or 0
interwarafter 1 if country is in international war during the 3 year period after the attempt, or 0
result Result of the assassination attempt, one of 10 categories described below

The polity variable represents the so-called polity score from the Polity Project. The Polity Project systematically documents and quantifies the regime types of all countries in the world from 1800. The polity score is a 21-point scale ranging from -10 (hereditary monarchy) to 10 (consolidated democracy). The result variable is a 10 category factor variable describing the result of each assassination attempt.

Note that Question 3 explores the assumption discussed in Question 2, and that the answer to Question 3 will build on R code used in the answers to Questions 1 and 2. Make sure to include the relevant code from those Answers.

Question 3 in the tutorial investigated whether the average polity score over 3 years prior to an assassination attempt differs on average between successful and failed attempts. You were asked to do this by comparing means and to interpret the results in light of the validity of the aforementioned assumption.

For this assignments, investigate whether the distribution of polity scores over 3 years prior to an assassination attempt differs between successful and failed attempts. (The difference here is that you are examining the distribution rather than only the mean.) To do this, plot the histograms for both distributions. Make sure that these histograms are easily comparable, i.e. that they have the same number of bins and the same scales. Assign informative labels to both axes and title your graphs. Add vertical lines to each graph to represent the mean and median values of the two distributions, and make those lines “solid” and “dashed”, respectively. Note that QSS~3.3.2 explains in detail how to do this. Finally, instead of using the text() function to label the vertical lines, add the following code for each plot and note what this does:

legend("topright", legend = c("mean", "median"), lty = c("solid", "dashed"))

Again, briefly interpret the results in light of the validity of the aforementioned assumption.

## loading in data and necessary code
leaders <- read.csv("leaders.csv")
## create variable, 1 if died "from" attack, 0 otherwise
lev <- levels(leaders$result) 
lev # shows response categories
##  [1] "dies between a day and a week"              
##  [2] "dies between a week and a month"            
##  [3] "dies within a day after the attack"         
##  [4] "dies, timing unknown"                       
##  [5] "hospitalization but no permanent disability"
##  [6] "not wounded"                                
##  [7] "plot stopped"                               
##  [8] "survives but wounded severely"              
##  [9] "survives, whether wounded unknown"          
## [10] "wounded lightly"
leaders$success <- 
    ifelse(leaders$result == lev[1] | leaders$result == lev[2] |
               leaders$result == lev[3] | leaders$result == lev[4], 1, 0)
## avg polity score for successful/unsuccessful before
mean(leaders$politybefore[leaders$success == 1])
## [1] -0.7037037
mean(leaders$politybefore[leaders$success == 0])
## [1] -1.743197
## avg age for successful/unsuccessful
mean(leaders$age[leaders$success == 1])
## [1] 56.46296
mean(leaders$age[leaders$success == 0])
## [1] 52.71429
## making histogram for succesful attempts
hist(leaders$politybefore[leaders$success == 1],freq = FALSE,
     xlim = c(-10,10), xlab= "Polity Score Before",
     ylim = c(0,0.1),
     breaks = seq(from = -10, to = 10, by = 5),
     main = "Distribution of Polity Scores Prior to Succesful Ass",
     )
legend("topright", legend = c("mean", "median"), lty = c("solid", "dashed"))
abline(v=mean(leaders$politybefore[leaders$success == 1]))
abline(v=median(leaders$politybefore[leaders$success == 1]),lty=2)

## making histogram for unsuccesful attempts
hist(leaders$politybefore[leaders$success == 0],freq = FALSE,
     xlim = c(-10,10), xlab= "Polity Score Before",
     ylim = c(0,0.1),
     breaks = seq(from = -10, to = 10, by = 5),
     main = "Distribution of Polity Scores Prior to Unsuccesful Ass",
     )
legend("topright", legend = c("mean", "median"), lty = c("solid", "dashed"))
abline(v=mean(leaders$politybefore[leaders$success == 0]))
abline(v=median(leaders$politybefore[leaders$success == 0]),lty=2)

Explanation time: Looking at the two distributions, the first thing to jump out is the large skew towards lower polity scores in the unsuccessful assassination attempts. This would indicate that more authoritarian countries have a larger amount of unsuccesful attempts, due to there possibly being more attempts in general in authoritarian countries. The histogram also shows that the density of unsuccesful assassinations is lower in democratic countries (5-10 polity score), again perhaps indicating that there are just fewer attempts overall. With regards to the succesful assassination attempts, the mean and median are fairly similar to those of the unsuccesful attempts. What’s interesting in the succesful attempts is that the distribution appears to be even across polity scores, save for the 0-5 range, which makes it harder to derive a conclusion on whether polity before affects the success of an assassination attempt. However, like the unsuccesful attempts histogram, the majority of the distribution remains below 0 on the polity score, indicating that overall more authoritarian countries experience more frequent assassination attempts.