Project 2

Author

Jeffrey Ren

Introduction

This dataset is an extensive dataset about suicide rates and socioeconomic factors I found on Kaggle using World Bank and World Health Organization as sources for the data. It includes data from almost every country, as well as almost every year from 1990 to 2022. The suicide rates variables include the total number, crude rate per 100,000, and also an age-standardized rate for more accuracy. The socioeconomic variables include population, GDP, GNI, GPD and GNI per capita, inflation rate, and employment-population ratio. I chose this data set because me and my friend were discussing this topic recently and it caught my eye when I saw a data set about this.I decided to clean the data set for five specific countries, and the reasoning for that would be discussed in the conclusion essay.

Loaded in the necessary libraries and read the csv.

library(tidyverse)
library (dplyr)
library (ggfortify)
library(plotly)
setwd("/Users/jeffreyren/Downloads/Directory")
suidata <- read_csv("sui.csv")

I filtered for these countries because these are the five highest countries (that exist in the dataset) in terms of depression rate according to https://gitnux.org/countries-with-highest-depression-rate/

filter1 <- suidata |> 
  filter((CountryCode %in% c("USA", "UKR", "NLD", "COL", "BRA")) & (Year == 2019)) 
filter2 <- suidata |> 
  filter((CountryCode %in% c("USA", "UKR", "NLD", "COL", "BRA")) & (Year %in% 1990:2020) & (Sex == "Male")) 

Analyze the linear regression.

datalm <- lm (StdDeathRate ~ GDPPerCapita, data = filter2)
summary(datalm)

Call:
lm(formula = StdDeathRate ~ GDPPerCapita, data = filter2)

Residuals:
    Min      1Q  Median      3Q     Max 
-11.615  -8.267  -3.377   4.082  31.410 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)   1.712e+01  1.244e+00  13.761   <2e-16 ***
GDPPerCapita -6.447e-05  4.414e-05  -1.461    0.146    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 10.78 on 145 degrees of freedom
  (5 observations deleted due to missingness)
Multiple R-squared:  0.0145,    Adjusted R-squared:  0.007708 
F-statistic: 2.134 on 1 and 145 DF,  p-value: 0.1462
autoplot(datalm, 1:4, nrow=2, ncol=2)

Created a line graph of suicide rates of males in 5 countries with some of the highest depression rates from 1990 to 2020 using geom line and geom point. Used ggplotly to add interactivity.

linegraph <- ggplot(filter2, aes(x = Year, y = StdDeathRate, color = CountryName)) +
  geom_line() +
  geom_point() +
  labs(x = "Year", y = "Age Standardized Suicide Rate (Per 100,000)",
       title = "Suicide Rates of Males in 5 Countries With Some of the Highest Depression Rates (1990-2020)",
       caption = "Data sources: World Health Organization, World Bank Data, and Gitnux.org") +
  theme_minimal() +
  scale_color_manual(values = c(Ukraine = "blue", Brazil = "green", Colombia = "yellow", Netherlands = "purple", `United States of America` = "red"))

ggplotly(linegraph)

I couldn’t include both male and female in the line graph so I made a bar graph of the countries with both genders in 2019 using geom col.

barplot <- ggplot(filter1, aes(x = CountryName, y = StdDeathRate, fill = Sex)) +
  geom_col(position = "dodge") +
  labs(title = "Suicide Rates by Country in 2019",
       x = "Country",
       y = "Suicide Rate",
       fill = "Gender") +
  scale_fill_manual(values = c("red", "blue", "gray"))

ggplotly(barplot)

Conclusion

Given common knowledge that depression directly affects suicide rates, I decided to research the countries with the highest depression rates. I found Gitnux.org has an extensive list of all the countries and their depression rates ranked. I used five of the highest ranked countries, not the exact top 5 because some countries didn’t have much data. The 5 I chose are in this order from highest to lowest depression rates: Ukraine, USA, Colombia, Netherlands, and Brazil. I decided to use these countries to filter out my data set for.

My visualization shows the suicide rates of males in 5 countries with some of the highest depression rates from 1990 to 2020. What I found is that the ranking for depression rates for the five countries was almost the same ranking as shown in the visualization. If Colombia and Netherlands swapped it would’ve been the exact same ranking. The grouping was also very similar. USA and Ukraine had the highest depression rates by far while the other three are generally pretty close in depression rates. As you can see in the visualization that’s how they’re kind of grouped as well in terms of suicide rates. Also something interesting is how high Ukraine used to be with a spike in 1991 but its dropped down to around USA levels recently. Something I wish I could’ve got to do is make a visualization with the suicide rates of both male and female added together in one total rate for each country. I only used one gender because I couldn’t figure out how to add data from two different rows in the data set together, and in the dataset there’s two rows with two data points for suicide rates of two genders instead of a collective one. I made a bar graph showing rates for female and male in 2019 to showcase the female rates and it’s much lower than the male rates so I decided to focus on the male rates instead. Also my caption for sources disappeared when I added interactivity with plotly.