Nowadays, scarcely a day goes by when we don’t hear about gun crime in the news. Last month’s Super Bowl championship event, in which one person was killed and as many as 20 others were injured, remains fresh in our memories. In the U.S., participating in an event is no longer a matter of risking one’s life. Today, being involved in a gun crime in the U.S. is so severe that we must assume that anyone can be involved in a gun crime. This data set is extensive, and selecting a single visualization took a long time. In the process of creating the various visualization plots, I was reminded of the seriousness of gun crime in the United States when I discovered that the lowest age of the victim was a 0-year-old child. For this reason, I decided to focus our analysis on the age of the victims in this assignment.
library(tidyverse)
library(ggfortify)
library(plotly)
library(ggplot2)
setwd("C:/Users/sayaka/Desktop/Downloads")
us_gun <- read_csv("us_gun_deaths.csv")
head(us_gun)
## # A tibble: 6 × 21
## ...1 year month region state victim_age victim_sex victim_race
## <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 0 1985 2 Southeast AL 27 Male White (includes Mexic…
## 2 1 1985 3 Southeast AL 61 Male White (includes Mexic…
## 3 2 1985 4 Southeast AL 29 Female White (includes Mexic…
## 4 3 1985 5 Southeast AL 45 Male White (includes Mexic…
## 5 4 1985 7 Southeast AL 30 Male White (includes Mexic…
## 6 5 1985 7 Southeast AL 31 Male White (includes Mexic…
## # ℹ 13 more variables: victim_race_plus_hispanic <chr>, victim_ethnicity <chr>,
## # weapon_used <chr>, victim_offender_split <chr>,
## # offenders_relationship_to_victim <chr>,
## # offenders_relationship_to_victim_grouping <chr>, offender_sex <chr>,
## # circumstance <chr>, circumstance_grouping <chr>,
## # extra_circumstance_info <chr>, multiple_victim_count <dbl>,
## # incident_id <dbl>, additional_victim <lgl>
names(us_gun)
## [1] "...1"
## [2] "year"
## [3] "month"
## [4] "region"
## [5] "state"
## [6] "victim_age"
## [7] "victim_sex"
## [8] "victim_race"
## [9] "victim_race_plus_hispanic"
## [10] "victim_ethnicity"
## [11] "weapon_used"
## [12] "victim_offender_split"
## [13] "offenders_relationship_to_victim"
## [14] "offenders_relationship_to_victim_grouping"
## [15] "offender_sex"
## [16] "circumstance"
## [17] "circumstance_grouping"
## [18] "extra_circumstance_info"
## [19] "multiple_victim_count"
## [20] "incident_id"
## [21] "additional_victim"
gun_select <- us_gun |>
select(victim_age, victim_sex, victim_race, region, weapon_used, victim_offender_split, offenders_relationship_to_victim_grouping,offender_sex, circumstance_grouping)
First of all, a simple age-group treemap is presented by displaying the age group of the victims and the weapon used to kill them in the visualization data. As for the “Unkonwn gun,” a former Japanese prime minister was killed by a homemade weapon, so it is not excluded from the data but is shown in the visualization plot.
library(dplyr)
library(ggplot2)
library(treemapify)
library(RColorBrewer)
gun_select$victim_age <- as.numeric(gun_select$victim_age)
## Warning: 強制変換により NA が生成されました
v_age1 <- gun_select |>
mutate(age_group = cut(victim_age,
breaks = c(-Inf, 18, 30, 45, 60, 74, Inf),
labels = c("0-18", "19-30", "31-45", "46-60", "61-74", "75+"),
right = FALSE))
age_weapon_counts <- v_age1 |>
group_by(age_group, weapon_used) |>
summarise(incident_count = n(), .groups = 'drop')
plot1 <- ggplot(age_weapon_counts, aes(area = incident_count, fill = weapon_used, label = age_group, color = "Set2")) +
geom_treemap(alpha = 0.8) +
geom_treemap_text(fontface = "italic", colour = "white", place = "centre", grow = TRUE) +
theme_minimal() +
labs(subtitle = "source: us_gun_deaths") +
ggtitle("Treemap of victim age groups and weapon")
plot1
## Warning: Removed 5 rows containing missing values or values outside the scale range
## (`geom_treemap_text()`).
The treemap visualization shows that sufferers aged 19 to 45 years are the most common age institution in gun violence incidents. Within this institution, handguns appear as the most commonly used weapon, highlighting a capacity link between age and weapon kind. Further research can explore this connection in extra detail.
The next step was to determine if there was a correlation between the age of the victim and race, region, gender of the offender, weapon, and offense background.
gun_select <- us_gun
gun_select$victim_age <- as.numeric(as.character(gun_select$victim_age))
## Warning: 強制変換により NA が生成されました
gun_select_dropna <- na.omit(gun_select)
gun_select_dropna$region <- factor(gun_select_dropna$region,
levels = c('Southeast', 'Southwest', 'Midwest', 'Northeast'))
gun_select_dropna$victim_sex <- factor(gun_select_dropna$victim_sex,
levels = c('Male', 'Female', 'Unknown'))
gun_select_dropna$victim_race <- factor(gun_select_dropna$victim_race,
levels = c('Black', 'White (includes Mexican-Americans)',
'Asian or Pacific Islander', 'Unknown'))
gun_select_dropna$weapon_used <- factor(gun_select_dropna$weapon_used,
levels = c('handgun', 'firearm', 'shotgun', 'rifle'))
gun_select_dropna$offenders_relationship_to_victim_grouping <- factor(
gun_select_dropna$offenders_relationship_to_victim_grouping,
levels = c('Unknown Relationship', 'Outside Family But Known to Victim',
'Offender Not Known to Victim', 'Within Family'))
gun_select_dropna$offender_sex <- factor(gun_select_dropna$offender_sex,
levels = c('Male', 'Unknown', 'Female'))
gun_select_dropna$age_group <- cut(gun_select_dropna$victim_age,
breaks = c(-Inf, 18, 30, 45, 60, Inf),
labels = c("0-18", "19-30", "31-45", "46-60", "60+"),
right = FALSE)
model <- lm(formula = victim_age ~ victim_race + region + offender_sex + victim_sex + weapon_used+
circumstance_grouping + age_group,
data = gun_select_dropna)
summary(model)
##
## Call:
## lm(formula = victim_age ~ victim_race + region + offender_sex +
## victim_sex + weapon_used + circumstance_grouping + age_group,
## data = gun_select_dropna)
##
## Residuals:
## Min 1Q Median 3Q Max
## -15.5437 -3.1292 -0.1831 2.8169 23.5466
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 15.96898 0.13219
## victim_raceWhite (includes Mexican-Americans) 0.53490 0.05958
## victim_raceAsian or Pacific Islander 0.14768 0.23198
## victim_raceUnknown 1.01582 0.33937
## regionSouthwest -0.10883 0.06889
## regionMidwest -0.17142 0.08165
## regionNortheast -0.05485 0.08760
## offender_sexUnknown -0.10039 0.10555
## offender_sexFemale 0.18905 0.12715
## victim_sexFemale 0.50284 0.16189
## victim_sexUnknown -2.90902 1.74022
## weapon_usedfirearm 0.14870 0.10683
## weapon_usedshotgun -0.00976 0.11897
## weapon_usedrifle 0.26487 0.11883
## circumstance_groupingUnable to Determine Circumstances -0.96156 1.22429
## age_group19-30 7.26901 0.13040
## age_group31-45 19.51984 0.13293
## age_group46-60 34.01891 0.14961
## age_group60+ 50.73946 0.20720
## t value Pr(>|t|)
## (Intercept) 120.804 < 2e-16 ***
## victim_raceWhite (includes Mexican-Americans) 8.977 < 2e-16 ***
## victim_raceAsian or Pacific Islander 0.637 0.52439
## victim_raceUnknown 2.993 0.00276 **
## regionSouthwest -1.580 0.11417
## regionMidwest -2.099 0.03580 *
## regionNortheast -0.626 0.53122
## offender_sexUnknown -0.951 0.34161
## offender_sexFemale 1.487 0.13707
## victim_sexFemale 3.106 0.00190 **
## victim_sexUnknown -1.672 0.09461 .
## weapon_usedfirearm 1.392 0.16398
## weapon_usedshotgun -0.082 0.93462
## weapon_usedrifle 2.229 0.02583 *
## circumstance_groupingUnable to Determine Circumstances -0.785 0.43223
## age_group19-30 55.746 < 2e-16 ***
## age_group31-45 146.841 < 2e-16 ***
## age_group46-60 227.378 < 2e-16 ***
## age_group60+ 244.877 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.802 on 19591 degrees of freedom
## ( 1052 個の観測値が欠損のため削除されました )
## Multiple R-squared: 0.8943, Adjusted R-squared: 0.8942
## F-statistic: 9210 on 18 and 19591 DF, p-value: < 2.2e-16
The multiple regression model found an 89.42% correlation between age, race, region, gender of the offender, weapon, and offense background. By race, whites or persons of unknown race, including Mexican-Americans, indicate a higher risk of homicide. Also, by gender, women are at higher risk of victimization. The Midwest and Northeast suggest lower rates of killing than the Southwest. There is a significant correlation between rifle use and the rate of killing, clearly indicating that rifles have a high capacity to kill. The multiple regression model has a very small p-value, and the p-values for all coefficients are very small, indicating that they are very unlikely to have been obtained by chance.
Examine differences in race, region, gender of offender, and offending circumstances in the Anova test
library(ggplot2)
library(RColorBrewer)
gun_select$victim_age <- as.numeric(gun_select$victim_age)
gun_select$victim_race <- factor(gun_select$victim_race)
gun_select$region <- factor(gun_select$region)
missing_values <- sum(is.na(gun_select$victim_age))
if (missing_values > 0) {
}
## NULL
anova_result <- aov(victim_age ~ victim_race + region + offender_sex + circumstance_grouping, data = gun_select)
summary(anova_result)
## Df Sum Sq Mean Sq F value Pr(>F)
## victim_race 4 2044231 511058 3130.9 <2e-16 ***
## region 4 638189 159547 977.5 <2e-16 ***
## offender_sex 2 473433 236717 1450.2 <2e-16 ***
## circumstance_grouping 5 786728 157346 964.0 <2e-16 ***
## Residuals 384975 62838628 163
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 4739 個の観測値が欠損のため削除されました
The outcome was that in all categories, there are factors that influence the age of the victim. There is a powerful relationship between race and age.
All victims are to be honored and Unknown race victims are also to be shown on the plot.
library(dplyr)
library(ggplot2)
library(plotly)
ncolors <- 6
palette <- brewer.pal(ncolors, "Set3")
plot2 <- ggplot(gun_select, aes(x = victim_race, y = victim_age, color = weapon_used)) +
geom_boxplot(aes(fill = weapon_used), alpha = 0.3) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
theme(legend.title = element_text(size = 10)) +
theme(legend.position = "right") +
labs(x = "Victim Race", y = "Victim Age", fill = "Weapon Used") +
labs(subtitle = "source: us_gun_deaths") +
ggtitle("Boxplot of Victim Age by Victim Race and Weapon")
plot2
## Warning: Removed 4739 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
Analysis suggests handguns are the most frequently used weapon, evident
in their prominence in boxplots throughout races. However, the
information has some nuance. While there is no apparent racial
segregation in weapon desire, overlap in sufferer age distributions
throughout races for unique guns shows different guns like shotguns and
rifles are also used.
Since this data set had many similar values (circumstance and circumstance grouping, etc.), it was possible to organize the data by narrowing it down to a single value. Since the data set still had many values, the analysis was focused on the victims to create a sense of consistency in the overall analysis.
This evaluation analyzed data on the victims of gun violence in the United States. The analysis found that the 19-45 age group was the most likely and that handguns were by far the most common type of crime. While there was no clear racial segregation in weapon selection, the age distribution of victims for handguns was found to be highly correlated across racial groups. Regression models were also adopted in the prevalence of these gun crimes, finding an 89.42% correlation between age of victim, race, region, sex of perpetrator, weapon used, and circumstances of the incident. Again, race emerged as a major issue, indicating that whites (including Mexican-Americans) and affected persons of unknown race are at higher risk of gun crime. It also suggests that women may be more potentially at risk of being more vulnerable. Statistics show that the Midwest and Northeast have lower murder rates than the Southwest. It is no overstatement to say that gun crime in the U.S. is now a negative legacy. Although my data analysis focused on the victims, further study of the background of the crime and the relationship between the victims and the perpetrators may provide clues to solving this horrific legacy. I sincerely feel that freedom in the U.S. does not mean the freedom to carry weapons and kill.
As I mentioned in b, in the DRAFT phase, I created visualization plots of the crime background, including Alluvium, streamgraph, etc., but I excluded this because we feared it would lack the overall unity of the assignment submission. I would like to try again in the next assignment or in the finals, because I think that the gun problem may provide results other than those obtained in this test by analyzing the data from various viewpoints instead of focusing only on the victims.