I am using a data set from a survey about guns from kaggle. I am looking to see if US region, gender, political affiliation, and people’s opinions on whether or not gun control will reduce mass shootings will have an effect on one’s support for civilians owning guns. It is a common stereotype that males namely from the Southeast US region who are typically politically right wing believe that everyone should be able to buy guns whenever they want because it is our Second Amendment right. I am looking to see what the data has to say about this. According to https://www.factcheck.org/2018/02/nra-chiefs-bogus-background-check-claims/, the NRA still opposes background checks even though its members support background checks https://www.politifact.com/ohio/statements/2018/feb/27/tim-ryan/after-parkland-shooting-ohio-congressman-said-70-8/ .
library(radiant.data)
library(tidyverse)
library(dplyr)
library(magrittr)
library(readr)
guncontrol <- read_csv("C:/Users/abbys/Downloads/gun_control.csv")
Parsed with column specification:
cols(
gender = [31mcol_character()[39m,
age = [31mcol_character()[39m,
region = [31mcol_character()[39m,
political_affiliation = [31mcol_character()[39m,
`should_background_checks_on_gun_buyers_be_more_extensive愼㸰` = [31mcol_character()[39m,
should_there_be_more_restrictions_on_who_can_buy_a_gun = [31mcol_character()[39m,
will_further_gun_control_reduce_the_possibilities_of_mass_shootings = [31mcol_character()[39m,
`should_civilians_be_allowed_to_own_guns愼㸰` = [31mcol_character()[39m
)
head(guncontrol)
str(guncontrol)
Classes ‘spec_tbl_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 560 obs. of 8 variables:
$ gender : chr "Female" "Female" "Female" "Female" ...
$ age : chr "17 or younger" "17 or younger" "17 or younger" "17 or younger" ...
$ region : chr "East North Central (Illinois, Indiana, Michigan, Ohio, and Wisconsin)" "East South Central (Alabama, Kentucky, Mississippi, and Tennessee)" "East South Central (Alabama, Kentucky, Mississippi, and Tennessee)" "West North Central (Iowa, Kansas, Minnesota, Missouri, Nebraska, North Dakota, and South Dakota)" ...
$ political_affiliation : chr "Libertarian Party" "Green Party" "Democratic Party" "Green Party" ...
$ should_background_checks_on_gun_buyers_be_more_extensive : chr "No" "Yes" "Yes" "Yes" ...
$ should_there_be_more_restrictions_on_who_can_buy_a_gun : chr "No" "Yes" "Yes" "Yes" ...
$ will_further_gun_control_reduce_the_possibilities_of_mass_shootings: chr "Yes" "Yes" "Yes" "Yes" ...
$ should_civilians_be_allowed_to_own_guns : chr "Yes" "Yes" "Yes" "No" ...
- attr(*, "spec")=
.. cols(
.. gender = [31mcol_character()[39m,
.. age = [31mcol_character()[39m,
.. region = [31mcol_character()[39m,
.. political_affiliation = [31mcol_character()[39m,
.. `should_background_checks_on_gun_buyers_be_more_extensive ` = [31mcol_character()[39m,
.. should_there_be_more_restrictions_on_who_can_buy_a_gun = [31mcol_character()[39m,
.. will_further_gun_control_reduce_the_possibilities_of_mass_shootings = [31mcol_character()[39m,
.. `should_civilians_be_allowed_to_own_guns ` = [31mcol_character()[39m
.. )
dim(guncontrol)
[1] 560 8
There are 560 observations and 8 categories.
I recoded ‘should_civilians_be_allowed_to_own_guns’ to be my binary dependent variable and renaming it as ‘civilians_owning_guns’. I am also recoding ‘will_further_gun_control_reduce_the_possibilities_of_mass_shootings’ to shorten its name to ‘gun_control_reduce_massshootings’ (just for my convenience):
guncontrol <- gun_control %>%
rename(`civilians_own_guns`=`should_civilians_be_allowed_to_own_guns `,`gun_control_reduce_massshootings`=`will_further_gun_control_reduce_the_possibilities_of_mass_shootings`)%>%
mutate(civilians_own_guns = sjmisc::rec(civilians_own_guns, rec = "No=0; Yes=1"))
head(guncontrol)
guncontrol$region=recode(guncontrol$region,
"East North Central (Illinois, Indiana, Michigan, Ohio, and Wisconsin)"="Midwest",
"East South Central (Alabama, Kentucky, Mississippi, and Tennessee)"="Southeast",
"West North Central (Iowa, Kansas, Minnesota, Missouri, Nebraska, North Dakota, and South Dakota)"="Midwest",
"Mid-Atlantic (New Jersey, New York, and Pennsylvania)"="Northeast",
"New England (Connecticut, Maine, Massachusetts, New Hampshire, Rhode Island, and Vermont)"="Northeast",
"Pacific (Alaska, California, Hawaii, Oregon, and Washington)"="West",
"South Atlantic (Delaware, Florida, Georgia, Maryland, North Carolina, South Carolina, Virginia, District of Columbia, and West Virginia)"="Southeast",
"West South Central (Arkansas, Louisiana, Oklahoma, and Texas)"="Southwest",
"Mountain (Arizona, Colorado, Idaho, Montana, Nevada, New Mexico, Utah, and Wyoming)"="Southwest")
guncontrol$political_affiliation=recode(guncontrol$political_affiliation,"Green Party"="Left-Wing","Democratic Party"="Left-Wing", "Republican Party"="Right-Wing","Constitution Party"="Right-Wing")
str(guncontrol)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 560 obs. of 8 variables:
$ gender : chr "Female" "Female" "Female" "Female" ...
$ age : chr "17 or younger" "17 or younger" "17 or younger" "17 or younger" ...
$ region : chr "Midwest" "Southeast" "Southeast" "Midwest" ...
$ political_affiliation : chr "Libertarian Party" "Left-Wing" "Left-Wing" "Left-Wing" ...
$ should_background_checks_on_gun_buyers_be_more_extensive : chr "No" "Yes" "Yes" "Yes" ...
$ should_there_be_more_restrictions_on_who_can_buy_a_gun : chr "No" "Yes" "Yes" "Yes" ...
$ gun_control_reduce_massshootings : chr "Yes" "Yes" "Yes" "Yes" ...
$ civilians_own_guns : num 1 1 1 0 0 1 1 1 1 0 ...
m0 <- glm(civilians_own_guns ~ gender, family = binomial, data = guncontrol)
summary(m0)
Call:
glm(formula = civilians_own_guns ~ gender, family = binomial,
data = guncontrol)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8399 0.6378 0.6378 0.7585 0.7585
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.0986 0.1400 7.846 4.31e-15 ***
genderMale 0.3907 0.2067 1.890 0.0588 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 584.52 on 559 degrees of freedom
Residual deviance: 580.92 on 558 degrees of freedom
AIC: 584.92
Number of Fisher Scoring iterations: 4
m1 <- glm(civilians_own_guns ~ gender+region+political_affiliation, family = binomial, data = guncontrol)
summary(m1)
Call:
glm(formula = civilians_own_guns ~ gender + region + political_affiliation,
family = binomial, data = guncontrol)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.2323 0.4157 0.5795 0.7191 1.0921
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.9902 0.2739 3.615 0.000301 ***
genderMale 0.3733 0.2134 1.749 0.080228 .
regionNortheast -0.7863 0.3262 -2.410 0.015937 *
regionSoutheast 0.3981 0.3260 1.221 0.221927
regionSouthwest 0.0553 0.3614 0.153 0.878385
regionWest -0.4325 0.3613 -1.197 0.231357
political_affiliationLibertarian Party 0.3356 0.3975 0.844 0.398494
political_affiliationRight-Wing 0.6436 0.2425 2.654 0.007961 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 584.52 on 559 degrees of freedom
Residual deviance: 555.03 on 552 degrees of freedom
AIC: 571.03
Number of Fisher Scoring iterations: 4
Our nation is currently politically polarized. I think it would be interesting to see how gun_control_reduce_massshootings interacts with political_affiliation.
m2 <- glm(civilians_own_guns ~ gender+region+political_affiliation*gun_control_reduce_massshootings, family = binomial, data = guncontrol)
summary(m2)
Call:
glm(formula = civilians_own_guns ~ gender + region + political_affiliation *
gun_control_reduce_massshootings, family = binomial, data = guncontrol)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.9049 0.1664 0.4536 0.7726 1.2054
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.04998 0.43600 4.702 2.58e-06 ***
genderMale 0.38407 0.22215 1.729 0.083829 .
regionNortheast -0.78916 0.34164 -2.310 0.020892 *
regionSoutheast 0.33268 0.33647 0.989 0.322782
regionSouthwest 0.06882 0.37397 0.184 0.853985
regionWest -0.40253 0.37310 -1.079 0.280650
political_affiliationLibertarian Party -0.16012 0.71516 -0.224 0.822838
political_affiliationRight-Wing 1.77034 0.80265 2.206 0.027411 *
gun_control_reduce_massshootingsYes -1.32636 0.38564 -3.439 0.000583 ***
political_affiliationLibertarian Party:gun_control_reduce_massshootingsYes 0.31068 0.87605 0.355 0.722860
political_affiliationRight-Wing:gun_control_reduce_massshootingsYes -1.66511 0.84734 -1.965 0.049401 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 584.52 on 559 degrees of freedom
Residual deviance: 507.44 on 549 degrees of freedom
AIC: 529.44
Number of Fisher Scoring iterations: 6
The model with the best fit is the third one (m2), which is shown by looking at the smallest AIC and BIC numbers.
library(texreg)
htmlreg(list(m0, m1, m2), doctype = FALSE)
| Model 1 | Model 2 | Model 3 | ||
|---|---|---|---|---|
| (Intercept) | 1.10*** | 0.99*** | 2.05*** | |
| (0.14) | (0.27) | (0.44) | ||
| genderMale | 0.39 | 0.37 | 0.38 | |
| (0.21) | (0.21) | (0.22) | ||
| regionNortheast | -0.79* | -0.79* | ||
| (0.33) | (0.34) | |||
| regionSoutheast | 0.40 | 0.33 | ||
| (0.33) | (0.34) | |||
| regionSouthwest | 0.06 | 0.07 | ||
| (0.36) | (0.37) | |||
| regionWest | -0.43 | -0.40 | ||
| (0.36) | (0.37) | |||
| political_affiliationLibertarian Party | 0.34 | -0.16 | ||
| (0.40) | (0.72) | |||
| political_affiliationRight-Wing | 0.64** | 1.77* | ||
| (0.24) | (0.80) | |||
| gun_control_reduce_massshootingsYes | -1.33*** | |||
| (0.39) | ||||
| political_affiliationLibertarian Party:gun_control_reduce_massshootingsYes | 0.31 | |||
| (0.88) | ||||
| political_affiliationRight-Wing:gun_control_reduce_massshootingsYes | -1.67* | |||
| (0.85) | ||||
| AIC | 584.92 | 571.03 | 529.44 | |
| BIC | 593.58 | 605.65 | 577.04 | |
| Log Likelihood | -290.46 | -277.51 | -253.72 | |
| Deviance | 580.92 | 555.03 | 507.44 | |
| Num. obs. | 560 | 560 | 560 | |
| p < 0.001, p < 0.01, p < 0.05 | ||||
In the third model, females (intercept, when gender=0) support civilians owning guns at a log odds of 2.04998. Males (when gender=1) have an increase in log odds by .38407 of supporting civilians owning guns (but this is only statistically significant at the .1 level). The Northeast region has a decrease in log odds for supporting civilians owning guns by 0.78916. People who are politically right wing have an increase in log odds by 1.77034 for supporting civilians owning guns. People who feel that gun control will reduce mass shootings have a decrease in log odds by 1.32636 in supporting civilians owning guns. People who belong to the interaction term of being politically right wing and believing that gun control will reduce mass shootings will have decreased log odds in supporting civilians owning guns by 1.66511.
The third model has the smallest p value, making it the best fit model.
lmtest::lrtest(m0, m1, m2)
Likelihood ratio test
Model 1: civilians_own_guns ~ gender
Model 2: civilians_own_guns ~ gender + region + political_affiliation
Model 3: civilians_own_guns ~ gender + region + political_affiliation *
gun_control_reduce_massshootings
#Df LogLik Df Chisq Pr(>Chisq)
1 2 -290.46
2 8 -277.51 6 25.893 0.0002331 ***
3 11 -253.72 3 47.589 2.604e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
visreg(m2, "gender", by= "political_affiliation", scale="response")
The probability of supporting civilians owning guns is highest with Libertarian males (highest with males across all political affiliations), whereas politically left wing females have the least support for civilians owning guns. This is not surprising, as women tend to be more liberal than men. As a whole, politically left wing people support civilians owning guns slightly less than right wing or libertarians.
visreg(m2, "gun_control_reduce_massshootings", by= "gender", scale="response")
Males who believe that gun control won’t reduce mass shootings have greater support for civilians owning guns than females do. The probability of having support for civilians owning guns is lowest with females who believe that gun control reduces mass shootings. Again, this is not surprising, since women have lower support for civilians owning guns than males as the previous plot shows.
library(visreg)
visreg(m2, "gun_control_reduce_massshootings", by= "political_affiliation",scale = "response")
Politically right wing people who believe that gun control does not reduce mass shootings are more likely to support civilians owning guns than other political affiliations. Politically left wing people who believe that gun control reduces mass shootings are more likely to not support civilians owning guns than other political affiliations.