The dataset I chose for my analysis contains a balanced panel of data regarding gun ownership and crime in all 50 US states, plus the District of Columbia by year from 1977-99. The different parameters included in the dataset are:
Each observation in the dataset is given a state in a given year. There are a total of 51 states times 23 years = 1,173 observations.
There are a variety of directions to analyze this data, but I will focus on the following questions:
1.) What had the national trend (average) been for Violent Crime Rate, Murder Rate, and Robbery Rate over the years 1977-99? 2.) Which states had the lowest and highest rates of violent crime during this time period? 3.) What is the effect of having a Shall Carry Law, specifically in regards to Violent Crime Rate, Murder Rate, and Robbery Rate?
More information about this dataset can be sourced from the RDoc link here: https://vincentarelbundock.github.io/Rdatasets/doc/AER/Guns.html https://vincentarelbundock.github.io/Rdatasets/csv/AER/Guns.csv
1.) What had the national trend (average) been for Violent Crime Rate, Murder Rate, and Robbery Rate over the years 1977-99?
For this analysis, I will combine the average Violent Crime Rate, Murder Rate, and Robbery Rate from each year into an array, and the years from 1977-99 into an array. Then I will enter them into dataframes containing two columns (Years, ___ Rate).
From these three dataframes, I can create six different scatterplots; two for each different crime rate, with and without DC included in the data. This expression clearly shows that DC is an outlier and should not be included for a national average.
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
Following this point, all analysis will exclude DC to better represent a national average.
From the above plots, I can focus my analysis on the averages from each year for all states, and apply a line of fit with error. The below figures show that there have been ups and downs in all included crime rates, with a general trend upwards and a noticeable dip immediately following the Clinton Administration’s 1994 ‘Assault Weapons Ban’. It is interesting to ponder the effect this may have had on this data.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Next, I would like to see what a histogram distribution of each crime rate of interest. This will add context to how the data is distrubuted. From the below figure, you can see the data represents a right tailed distribution, with most data points in the lower range.
2.) Which states had the lowest and highest rates of violent crime during this
time period?
For this analysis, I will plot the average Violent Crime Rate for each state
over the years 1977-99 in ascending order, to distinguish the highest from the
lowest average rates.
** Below charts couldn't be compiled, please submission for code. At one point
I did have the chart I wanted, but made some changes and never got it back.
** As stated above, no charts here, but the below results still hold true.
From the above bar chart, you can see that Florida, New York and California had
the highest rates of Violent Crime from 1977-99, respectively. You can also see
that North Dakota, New Hampshire, and Vermont had the lowest rates of Violent
Crime from 1977-99, respectively.
3.) What is the effect of having a Shall Carry Law, specifically in regards to Violent Crime Rate, Murder Rate, and Robbery Rate?
For this analysis, I will separate the data based on whether or not the State had a ‘Shall Carry Law’ in effect. The Shall Carry Law is an interesting variable, because it is defined as follows:
” Shall issue means that as long as an applicant passes the basic requirements set out by state law, the issuing authority (county sheriff, police department, state police, etc.) is compelled to issue a permit. ”
(Source: https://www.usconcealedcarry.com/resources/terminology/types-of- concealed-carry-licensurepermitting-policies/shall-issue/)
It is worth noting that until ~1990, very few states had Shall Issue Laws in place, however in 2023 48 states have a similar law in effect.
I will attempt to relate the effect that having a Shall Carry Law has to the Violent Crime Rate of any given State.
# Find the mean Violent Crime Rate based on a 'Yes' or 'No' Shall Carry Law
# If means are sufficiently apart, further analysis is worth pursuing
gun_YLaw <- data.frame(subset(gun_noDC, gun_noDC$Shall_Carry_Law != 'no'))
gun_NLaw <- data.frame(subset(gun_noDC, gun_noDC$Shall_Carry_Law != 'yes'))
mean_V_YLaw <- mean(gun_YLaw$Violent_Crime_Rate, na.rm = TRUE)
mean_V_NLaw <- mean(gun_NLaw$Violent_Crime_Rate, na.rm = TRUE)
# Boxplots comparing different crime rates based on a 'Yes' or 'No' Shall Carry Law
V_Law <- ggplot(gun_noDC, aes(Shall_Carry_Law, Violent_Crime_Rate)) + geom_boxplot() +xlab('Shall Carry Law') + ylab('Violent Crime Rate (per 100k)') + ggtitle('Effectiveness of Shall Carry Law on Violent Crime Rate')
V_Law
M_Law <- ggplot(gun_noDC, aes(Shall_Carry_Law, Murder_Rate)) + geom_boxplot() +xlab('Shall Carry Law') + ylab('Murder Rate (per 100k)') + ggtitle('Effectiveness of Shall Carry Law on Murder Rate')
M_Law
R_Law <- ggplot(gun_noDC, aes(Shall_Carry_Law, Robbery_Rate)) + geom_boxplot() +xlab('Shall Carry Law') + ylab('Robbery Rate (per 100k)') + ggtitle('Effectiveness of Shall Carry Law on Robbery Rate')
R_Law
As you can see from the above figures, there is a clear decrease in all
Crime Rates when any given state institutes a ‘Shall Carry Law’. There
is such significance, that the mean of the ‘Yes’ category is frequently
at the same level as Q1 of the ‘No’ category.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From all of the above analysis, I have determined the following:
1.) National Crime Rates increased over the period of 1977-94, and then had a steep decline from 1994-99.
2.) Florida, New York and California had the highest crime rates. North Dakota, New Hampshire, and Vermont had the lowest crime rates.
3.) A ‘Shall Carry Law’ had a negative association with crime rates, indicating they may be effective at reducing violent crime.
Forrest