There was always a controversy within society about guns control, whether or not people should be allowed to carry guns. If there are no guns, people can’t defend themselves. If there are guns, people can murder someone around or commit a suicides. The data set to study included violent crime, information about population, ethnicity, gun control laws in the United States between 1977-1999 collected by John Lott and David Mustard. The effect of concealed-carry laws on violent crime rate among 50 states + the District of Colombia was the research question using a Linear Mixed Effects model. The model was created to answer the question if there is relationship between concealed-carry laws and violent crime rate using population density, the percentage of males between 10-29 years old and incarceration rate as predictors. State/year were random effects for the model. To reduce the selection bias, propensity scores were calculated using a logistic regression model. Based on the results of the model, there is a negative correlation between if there is “yes” to guns and violent crime rate. Population density, the percentage of males between 10-29 years old and incarceration rate (p < 0.001) were positively correlated with violent crime rate. There was still a selection bias and some data can be dependent, we failed to reject the null-hypothesis.
Does the right-to-Carry Concealed Handguns reduce crime rate?
For many of years, there was always an argue about this topic. People are divided into two camps “Yes guns” and “No guns”. The purpose of the project is to check the study that covered many years of violence and if the guns in hands of civil (concealed-carry laws) can actually control crime.
The data was collected by John Lott and David Mustard for a paper “Crime, Deterrence, and Right-to-Carry Concealed Handguns”. The study presents the results of the statistical analysis of crime data for every county in the United States during 23 years from 1977 to 1999. The study was extended to 2005 and formed in the book.
The data describes the impact of right-to-carry concealed Handguns laws on crime rate and is a balanced panel of data on 50 US states, plus the District of Columbia (for a total of 51 states), by year for 1977–1999. Each observation is a given state in a given year. There are a total of 51 states times 23 years = 1,173 observations. A data frame containing 1,173 observations on 13 variables. #### 2.3 Type of study This is an observational study.
Data is collected by John Lott and David Mustard. The dataset is provided by Ian Ayres and John J. Donohue of Stanford University the paper “Shooting Down the ’More Guns Less Crime Hypothesis” (Stanford Law Review 2003) The dataset is available online at the following link: https://raw.githubusercontent.com/ex-pr/Dataset/main/guns.csv Or via the R package “AER”.
Response variable is violent rate (quantitative): violent crime rate (incidents per 100,000 members of the population).
Laws (Does the state have a concealed-carry laws in effect in that year?) is qualitative variable, the incarceration rate in the state in the previous year (sentenced prisoners per 100,000 residents; value for the previous year) which is quantitative variable.
# load data
library(tidyverse)
library(infer)
library(ggplot2)
library (readr)
library(Hmisc)
library(psych)
library(stats)
library(corrplot)
library(gplots)
library(lme4)
library(plotly)
library(lmerTest)
library(redres)
guns <- read.csv("https://raw.githubusercontent.com/ex-pr/Dataset/main/guns_606.csv")
#create additional column No, Yes for gun laws. Add average crime per year
guns <- guns %>%
add_column(if_laws = if_else(.$laws == 0, "No", "Yes"))
Let’s overview the data set. The violent crime rate (incidents per 100,000 members of the population) varies from 47 incidents to 2921.8. The murder rate (incidents per 100,000) varies from 0.2 to 80.6 incidents. The robbery rate (incidents per 100,000) varies from 6.4 to 1635.1 incidents.
summary (guns)
## X year violent murder
## Min. : 1 Min. :1977 Min. : 47.0 Min. : 0.200
## 1st Qu.: 294 1st Qu.:1982 1st Qu.: 283.1 1st Qu.: 3.700
## Median : 587 Median :1988 Median : 443.0 Median : 6.400
## Mean : 587 Mean :1988 Mean : 503.1 Mean : 7.665
## 3rd Qu.: 880 3rd Qu.:1994 3rd Qu.: 650.9 3rd Qu.: 9.800
## Max. :1173 Max. :1999 Max. :2921.8 Max. :80.600
## robbery prisoners afam cauc
## Min. : 6.4 Min. : 19.0 Min. : 0.2482 Min. :21.78
## 1st Qu.: 71.1 1st Qu.: 114.0 1st Qu.: 2.2022 1st Qu.:59.94
## Median : 124.1 Median : 187.0 Median : 4.0262 Median :65.06
## Mean : 161.8 Mean : 226.6 Mean : 5.3362 Mean :62.95
## 3rd Qu.: 192.7 3rd Qu.: 291.0 3rd Qu.: 6.8507 3rd Qu.:69.20
## Max. :1635.1 Max. :1913.0 Max. :26.9796 Max. :76.53
## male population income density
## Min. :12.21 Min. : 0.4027 Min. : 8555 Min. : 0.000707
## 1st Qu.:14.65 1st Qu.: 1.1877 1st Qu.:11935 1st Qu.: 0.031911
## Median :15.90 Median : 3.2713 Median :13402 Median : 0.081569
## Mean :16.08 Mean : 4.8163 Mean :13725 Mean : 0.352038
## 3rd Qu.:17.53 3rd Qu.: 5.6856 3rd Qu.:15271 3rd Qu.: 0.177718
## Max. :22.35 Max. :33.1451 Max. :23647 Max. :11.102120
## laws state if_laws
## Min. :0.000 Length:1173 Length:1173
## 1st Qu.:0.000 Class :character Class :character
## Median :0.000 Mode :character Mode :character
## Mean :0.243
## 3rd Qu.:0.000
## Max. :1.000
prop.table(table(guns$law, useNA='ifany')) * 100
##
## 0 1
## 75.70332 24.29668
The graphs below will help to visualize and understand the relation between response variable and explanatory variables. First, histograms for the response and explanatory variables. There will be 2 graphs for each case: the first will show how the crime rate in general, the second one will show the change of crime rate if there are concealed-carry laws or not.
We see that the frequency of crime is much higher for states with “no gun” laws.
ggplot(guns) +
aes(x = violent) +
geom_histogram(fill='lightblue') +
labs(x = "Crime Rate (Incidents per 100,000)", y = "Frequency", title = "Frequency Of Crime incidents") +
theme_light()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(guns) +
aes(x = violent) +
geom_histogram(bins = 30L) +
labs(x = "Crime Rate (Incidents per 100,000)", y = "Frequency", title = "Frequency Of Crime incidents with concealed-carry laws and without") +
facet_wrap(vars(if_laws)) +
theme_light()
We can repeat the graph above for different type of crime and check how the prisoners rate relate to concealed-carry laws. And the result is the same, the frequency of crime is much higher for states with “no gun” laws.
ggplot(guns) +
aes(x = murder) +
geom_histogram(bins = 30L) +
labs(x = "Murder Rate (Incidents per 100,000)", y = "Frequency", title = "Frequency Of Murder incidents with concealed-carry laws and without") +
facet_wrap(vars(if_laws)) +
theme_light()
ggplot(guns) +
aes(x = robbery) +
geom_histogram() +
labs(x = "Robbery Rate (Incidents per 100,000)", y = "Frequency", title = "Frequency Of Robbery incidents with concealed-carry laws and without") +
facet_wrap(vars(if_laws))+
theme_light()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Next, we can check the Incarceration rate and how it relates to concealed-carry laws. The result is obvious, the frequency of prisoning incidents is much higher for states with “no gun” laws, as such states has much higher crime rate.
ggplot(guns) +
aes(x = prisoners) +
geom_histogram() +
labs(x = "Incarceration rate (sentenced prisoners per 100,000 residents)", y = "Frequency", title = "Frequency Of prisoning incidents")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(guns) +
aes(x = prisoners) +
geom_histogram(bins = 30L, fill='lightblue') +
labs(x = "Incarceration rate (sentenced prisoners per 100,000 residents)", y = "Frequency", title = "Frequency Of prisoning incidents with concealed-carry laws and without") +
facet_wrap(vars(if_laws)) +
theme_light()
Further, it would be good to see how the crime rate changed from year to year in the states with concealed-carry laws and without it. The crime rate in states with gun laws is pretty constant whereas the states with no guns have fluctuation but still comparatively high.
ggplot(guns) +
aes(x = year, y = violent) +
geom_point(colour="blue", size=1) +
labs(x = "Year", y = "Crime Rate (per 100,000)", title = "Year vs Crime Rate by concealed-carry laws") +
facet_wrap(vars(if_laws))
cor(guns$violent,guns$year)
## [1] 0.1214497
plotmeans(guns$violent~guns$year,xlab = "Year",ylab = "Crime Rate)")
We can also check how crime rate differs from state to state. We see that DC state is an outlier but not because of the issue from our end, it happened in reality, that DC has huge crime rate in 1980 and 1990.
state_crime = guns %>%
ggplot(
aes(x=year,
y=violent,
group=state,
color=state)) +
geom_line() +
labs(
title="Crime rate by Year/State",
x="Year",
y = "Crime Rate, per 100k") +
theme(
text = element_text(
size=10,
face = 'bold'),
axis.text.x = element_text(angle=75,hjust=1),
axis.ticks.x = element_line(size=0.5)) +
scale_x_discrete(
guide = guide_axis(n.dodge =1),
expand=c(0, 0)) +
scale_fill_discrete(name = "State")
ggplotly(state_crime)
The graph below decribes how the Incarceration rate changes from year to year in the states with concealed-carry laws and without it.We see that as crime rate goes down, the prisoners rate foes down.
ggplot(guns) +
aes(x = year, y = prisoners) +
geom_point(colour="blue", size=1) +
labs(x = "Year", y = "Incarceration rate (sentenced prisoners per 100,000 residents)", title = "Year vs Prisoning Rate by concealed-carry laws") +
facet_wrap(vars(if_laws))
cor(guns$prisoners,guns$year)
## [1] 0.5040576
plotmeans(guns$prisoners~guns$year,xlab = "Year",ylab = "Incarceration rate")
The graph below shows that in general, the states with guns laws has less crime and, as a result, less prisoning cases.
ggplot(guns) +
aes(x = violent, y = prisoners) +
geom_point(color="blue", size=0.8) +
labs(x = "Crime Rate(per 100,000)", y = "Incarceration Rate (sentenced prisoners per 100,000 residents)", title="Crime vs Prisoning rate by concealed-carry laws") +
facet_wrap(vars(if_laws))
cor(guns$violent,guns$prisoners)
## [1] 0.70266
Also, the population can be determining factor for crime rate as well. More people, more crime can happen. There seems to be a positive correlation between population and crime rate.
ggplot(guns) +
aes(x = population, y = violent, colour = if_laws) +
geom_point(size = 1L) +
labs(x = "Population(in Millions)", y = "Crime Rate(per 100,000)", title = "Population Vs Crime Rate by concealed-carry laws")
cor(guns$violent,guns$population)
## [1] 0.3189665
ggplot(guns) +
aes(x = density, y = violent) +
geom_point(size = 1L) +
labs(x = "Density", y = "Crime Rate(per 100,000)", title = "Density Vs Crime Rate by concealed-carry laws") +
facet_wrap(vars(if_laws))
cor(guns$violent,guns$density)
## [1] 0.664726
Now, let’s be more specific in terms of relation between variables and check the correlation. We see a strong positive correlation between crime and population (density) as well as prisoners and crime. Also, income affects the crime rate.
guns_for_corr <- select_if(guns, is.numeric)
corrplot(cor(guns_for_corr[,c(-(15:39))]),method = "shade")
The boxplots below will help to learn more about relation between variables. We see that crime rate is higher in the states with no guns.
ggplot(guns) +
aes(x = if_laws, y = violent, fill = if_laws) +
geom_boxplot() +
labs(x = "Concealed-carry laws", y = "Crime Rate(per100,000)", fill = "Concealed-carry laws")
Conditions for interference are reasonable: the sample observations are independent, the sample must be large enough that np>10 and n(1-p)>10.
Below is an inferential analysis of the dataset to determine if gun laws (yes carry-on guns or no) affect crime. From the data illustration above, we assume that multiple factors affect crime rate: different types of crime, density, gender and gun laws, prisoners rate.
The data contains a multiple observations for different states for 20 years, there are random, immeasurable effects were present in the data. As a result, we define state and year random effects that are out of control in our model.
The linear mixed models is used in this project as a method for analyzing data that are non independent, multilevel/hierarchical, longitudinal, or correlated. The fixed variables are assumed independent.
H0: There is no relation between gun laws and crime rate. HA: There is a relation between gun laws and crime rate. As a result, the intercept (p value < 2e-16), male (p value 7.35e-10), prisoners (p value 0.000778) are significant.
We have failed to reject the null-hypothesis, there is no relation between gun laws and crime rate.
par(mfrow=c(1,2))
hist(guns$violent,
xlab="Crime Rate",
main= "Original",
col="yellow")
hist(log(guns$violent),
xlab="log(Crime Rate)",
main="Log-Transformed",
col="lightgreen")
model_laws = lmer(log(violent)~if_laws+male+prisoners+density + (1|state)+(1|year), data=guns)
summary(model_laws)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(violent) ~ if_laws + male + prisoners + density + (1 | state) +
## (1 | year)
## Data: guns
##
## REML criterion at convergence: -836.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.1611 -0.5550 0.0241 0.6161 5.0740
##
## Random effects:
## Groups Name Variance Std.Dev.
## state (Intercept) 0.33736 0.5808
## year (Intercept) 0.03318 0.1822
## Residual 0.01977 0.1406
## Number of obs: 1173, groups: state, 51; year, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.933e+00 1.889e-01 3.873e+02 26.118 < 2e-16 ***
## if_lawsYes -1.830e-02 1.652e-02 1.124e+03 -1.108 0.268305
## male 6.347e-02 1.010e-02 4.890e+02 6.283 7.35e-10 ***
## prisoners 2.283e-04 6.759e-05 6.201e+02 3.377 0.000778 ***
## density 7.635e-02 4.187e-02 1.463e+02 1.823 0.070293 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) if_lwY male prsnrs
## if_lawsYes 0.142
## male -0.868 -0.189
## prisoners -0.256 0.013 0.153
## density -0.117 -0.020 -0.006 0.552
anova(model_laws)
To check how if the model is appropriate for out analysis, we can check the distribution of residuals. There is no pattern and residuals are normally distributed.
plot_redres(model_laws, type = "std_cond")
## Загрузка требуемого пакета: testthat
hist(summary(model_laws)$residuals, breaks=30, main="Residuals Distribution", xlab="Residuals")
plot_resqq(model_laws)
As it was mentioned at the beginning, the gun laws are usually a hot topic, there are usually 2 opinions “no guns” and “yes guns”. The statistical analysis of the data related to crime rate and whether or not there is concealed-carry laws or not should at least show us the direction to the answer. The dataset contains huge amount of data. Each variable can be affected by some other factors that are not included in the dataset but are necessary in understanding how gun control affects crime level. It was assumed that there is a relation between guns laws, male, density, prisoner rate and crime rate. Though the main question is still about the relation between gun laws and crime rate.
A linear mixed effects model was fit to answer this question with state/year as random effects, violent crime rate as the response variable, young male population percentage, population density, guns-carry laws as predictors.
The model indicated a negative correlation between if_laws=“yes” and violent crime rates. Density, prisoners rate, and young male population percent were positively correlated with violent crime rate.
Model assumptions were accepted based on the residuals distribution. The issue with the model can be that there are some confounders that were violated as not all data variables were included in the model.
As a result, we can not accept that there is a relation between concealed-carry laws and crime rate, that more guns reduce crime as there is a selection bias remains in the model: we to removed “insignificant” predictors and use information criteria to find the most parsimonious model. We can balance weights to reduce bias and fit a new model.
Though the affect of the gun laws on crime rate was significantly law comparing to other variables in the dataset.
Overall, there is no straight relation between gun control and crime rate. Though there are definitely a lot of factors that affect crime rate but not listed in the data as well as some variables can be related in reality. For example, low income within the high population/high density society with a lot of young people can affect the crime level. The question should be not if concealed-carry laws reduce crime but what things affect crime level and should be studied in each particular state separately.