Drug Substance Abuse

Author

Emma Wang

Dataset: https://corgis-edu.github.io/corgis/csv/drugs/

Introduction

The National Survey on Drug Use and Health (NSDUH) conducted a study within individual states collecting data regarding substance abuse in relation to age. The drugs involved in the dataset are: cigarettes, marijuana, cocaine, and alcohol.

Notes:

  • I will be examining yearly data and the cigarette values only pertain to monthly data; therefore I will not be using it.

  • Substance and Drug can be used interchangeably.

There are 53 variables: state, age group population (12-17, 18-25, 26+), total substance abuse for each drug and age group in the past year, rates of each substance abuse for each drug and age group in the past year, total substance abuse for each drug and age group in the past month, and rates of each substance abuse for each drug and age group in the past month.

Research Question:

Is there a statistically significant relationship between age group and the specific substance abused (alcohol, cocaine, and marijuana)?


Load Libraries

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(ggplot2)
library(readr)
library(psych)

Attaching package: 'psych'

The following objects are masked from 'package:ggplot2':

    %+%, alpha

Load the Dataset

drugs = read_csv("~/Downloads/drugs.csv")
Rows: 867 Columns: 53
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (1): State
dbl (52): Year, Population.12-17, Population.18-25, Population.26+, Totals.A...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Exploring the Dataset

names(drugs)
 [1] "State"                                            
 [2] "Year"                                             
 [3] "Population.12-17"                                 
 [4] "Population.18-25"                                 
 [5] "Population.26+"                                   
 [6] "Totals.Alcohol.Use Disorder Past Year.12-17"      
 [7] "Totals.Alcohol.Use Disorder Past Year.18-25"      
 [8] "Totals.Alcohol.Use Disorder Past Year.26+"        
 [9] "Rates.Alcohol.Use Disorder Past Year.12-17"       
[10] "Rates.Alcohol.Use Disorder Past Year.18-25"       
[11] "Rates.Alcohol.Use Disorder Past Year.26+"         
[12] "Totals.Alcohol.Use Past Month.12-17"              
[13] "Totals.Alcohol.Use Past Month.18-25"              
[14] "Totals.Alcohol.Use Past Month.26+"                
[15] "Rates.Alcohol.Use Past Month.12-17"               
[16] "Rates.Alcohol.Use Past Month.18-25"               
[17] "Rates.Alcohol.Use Past Month.26+"                 
[18] "Totals.Tobacco.Cigarette Past Month.12-17"        
[19] "Totals.Tobacco.Cigarette Past Month.18-25"        
[20] "Totals.Tobacco.Cigarette Past Month.26+"          
[21] "Rates.Tobacco.Cigarette Past Month.12-17"         
[22] "Rates.Tobacco.Cigarette Past Month.18-25"         
[23] "Rates.Tobacco.Cigarette Past Month.26+"           
[24] "Totals.Illicit Drugs.Cocaine Used Past Year.12-17"
[25] "Totals.Illicit Drugs.Cocaine Used Past Year.18-25"
[26] "Totals.Illicit Drugs.Cocaine Used Past Year.26+"  
[27] "Rates.Illicit Drugs.Cocaine Used Past Year.12-17" 
[28] "Rates.Illicit Drugs.Cocaine Used Past Year.18-25" 
[29] "Rates.Illicit Drugs.Cocaine Used Past Year.26+"   
[30] "Totals.Marijuana.New Users.12-17"                 
[31] "Totals.Marijuana.New Users.18-25"                 
[32] "Totals.Marijuana.New Users.26+"                   
[33] "Rates.Marijuana.New Users.12-17"                  
[34] "Rates.Marijuana.New Users.18-25"                  
[35] "Rates.Marijuana.New Users.26+"                    
[36] "Totals.Marijuana.Used Past Month.12-17"           
[37] "Totals.Marijuana.Used Past Month.18-25"           
[38] "Totals.Marijuana.Used Past Month.26+"             
[39] "Rates.Marijuana.Used Past Month.12-17"            
[40] "Rates.Marijuana.Used Past Month.18-25"            
[41] "Rates.Marijuana.Used Past Month.26+"              
[42] "Totals.Marijuana.Used Past Year.12-17"            
[43] "Totals.Marijuana.Used Past Year.18-25"            
[44] "Totals.Marijuana.Used Past Year.26+"              
[45] "Rates.Marijuana.Used Past Year.12-17"             
[46] "Rates.Marijuana.Used Past Year.18-25"             
[47] "Rates.Marijuana.Used Past Year.26+"               
[48] "Totals.Tobacco.Use Past Month.12-17"              
[49] "Totals.Tobacco.Use Past Month.18-25"              
[50] "Totals.Tobacco.Use Past Month.26+"                
[51] "Rates.Tobacco.Use Past Month.12-17"               
[52] "Rates.Tobacco.Use Past Month.18-25"               
[53] "Rates.Tobacco.Use Past Month.26+"                 
head(drugs)
# A tibble: 6 × 53
  State       Year `Population.12-17` `Population.18-25` `Population.26+`
  <chr>      <dbl>              <dbl>              <dbl>            <dbl>
1 Alabama     2002             380805             499453          2812905
2 Alaska      2002              69400              62791           368460
3 Arizona     2002             485521             602265          3329482
4 Arkansas    2002             232986             302029          1687337
5 California  2002            3140739            3919577         21392421
6 Colorado    2002             385648             493921          2798960
# ℹ 48 more variables: `Totals.Alcohol.Use Disorder Past Year.12-17` <dbl>,
#   `Totals.Alcohol.Use Disorder Past Year.18-25` <dbl>,
#   `Totals.Alcohol.Use Disorder Past Year.26+` <dbl>,
#   `Rates.Alcohol.Use Disorder Past Year.12-17` <dbl>,
#   `Rates.Alcohol.Use Disorder Past Year.18-25` <dbl>,
#   `Rates.Alcohol.Use Disorder Past Year.26+` <dbl>,
#   `Totals.Alcohol.Use Past Month.12-17` <dbl>, …

Cleaning the Data

#clean the data so that it only displays yearly drug abuse disorder
cleaned = select(drugs, Year, starts_with("Total") & contains("Year")) |> 
  #rename variables so that they are easier to work with 
  rename(
    'Alcohol 12-17' = 'Totals.Alcohol.Use Disorder Past Year.12-17', 
    'Alcohol 18-25' = 'Totals.Alcohol.Use Disorder Past Year.18-25',
    'Alcohol 26+' = 'Totals.Alcohol.Use Disorder Past Year.26+', 
    'Cocaine 12-17' = 'Totals.Illicit Drugs.Cocaine Used Past Year.12-17', 
    'Cocaine 18-25'= 'Totals.Illicit Drugs.Cocaine Used Past Year.18-25', 
    'Cocaine 26+' = 'Totals.Illicit Drugs.Cocaine Used Past Year.26+', 
    'Marijuana 12-17' = 'Totals.Marijuana.Used Past Year.12-17', 
    'Marijuana 18-25' = 'Totals.Marijuana.Used Past Year.18-25', 
    'Marijuana 26+' = 'Totals.Marijuana.Used Past Year.26+'
  ) |> 
  group_by(Year) |>  #group data by year(row)
  summarise(across(where(is.numeric), \(x) sum(x, na.rm = TRUE)))  #add numeric values so that we have the full total of drug abuse for each year (instead of separated by state)
head(cleaned)
# A tibble: 6 × 10
   Year `Alcohol 12-17` `Alcohol 18-25` `Alcohol 26+` `Cocaine 12-17`
  <dbl>           <dbl>           <dbl>         <dbl>           <dbl>
1  2002            1464            5467         11016             473
2  2003            1491            5538         11198             425
3  2004            1459            5651         11545             415
4  2005            1385            5735         11640             417
5  2006            1366            5655         11752             398
6  2007            1290            5627         11664             351
# ℹ 5 more variables: `Cocaine 18-25` <dbl>, `Cocaine 26+` <dbl>,
#   `Marijuana 12-17` <dbl>, `Marijuana 18-25` <dbl>, `Marijuana 26+` <dbl>

Now that we have cleaned and mutated the data, we can visualize it.


Visualizing the Data

First begin by comparing total substance abuse across age groups.

#create a new column to display total drug disorder use 
age_abuse = cleaned |> 
  mutate(
    'Total Drug Abuse 12-17' = `Alcohol 12-17` + `Cocaine 12-17`+ `Marijuana 12-17`, #add together drug abuse for age group 12-17
    'Total Drug Abuse 18-25' = `Alcohol 18-25`+ `Cocaine 18-25`+ `Marijuana 18-25`, #add together drug abuse for age group 18-25
    'Total Drug Abuse 26+' = `Alcohol 26+`+ `Cocaine 26+`+ `Marijuana 26+`) #add together drug abuse for age group 26+
age_abuse
# A tibble: 17 × 13
    Year `Alcohol 12-17` `Alcohol 18-25` `Alcohol 26+` `Cocaine 12-17`
   <dbl>           <dbl>           <dbl>         <dbl>           <dbl>
 1  2002            1464            5467         11016             473
 2  2003            1491            5538         11198             425
 3  2004            1459            5651         11545             415
 4  2005            1385            5735         11640             417
 5  2006            1366            5655         11752             398
 6  2007            1290            5627         11664             351
 7  2008            1176            5573         11869             278
 8  2009            1121            5377         11858             242
 9  2010            1047            5121         11123             236
10  2011             902            4946         11345             204
11  2012             777            4745         11988             154
12  2013             689            4406         12050             148
13  2014             654            4054         11662             158
14  2015             557            3749         11088             141
15  2016             464            3562         10753             131
16  2017             421            3433         10808             114
17  2018             405            3277         10977             104
# ℹ 8 more variables: `Cocaine 18-25` <dbl>, `Cocaine 26+` <dbl>,
#   `Marijuana 12-17` <dbl>, `Marijuana 18-25` <dbl>, `Marijuana 26+` <dbl>,
#   `Total Drug Abuse 12-17` <dbl>, `Total Drug Abuse 18-25` <dbl>,
#   `Total Drug Abuse 26+` <dbl>
#wide --> long ,, collapsing data into two standarized columns 
pivot = age_abuse %>% 
  pivot_longer(
    cols = c(`Total Drug Abuse 12-17`, `Total Drug Abuse 18-25`, `Total Drug Abuse 26+`), 
    names_to = "Age Groups",
    values_to = "Drug Abuse Totals"
  )
#assigning x and y axes 
ggplot(pivot, aes(x = Year, y = `Drug Abuse Totals`, fill = `Age Groups`)) +
  #use exact values in dataset 
  geom_bar(stat = "identity", position = "dodge") + #prevents the graphs from overlapping, and instead places them side-by-side for easy comparison
  theme_minimal() + 
  labs(title = "Total Substance Abuse Across Age Groups", #adding an appropriate title 
       subtitle = "Drugs including: Alcohol, Cocaine, and Marijuana", #subtitle 
       caption = "Source: CORGIS, gathered by NSDUH", #data source 
       y = "Drug Abuse Totals") + #adding a subtitle to specifiy the drugs included
  scale_fill_manual(values = c("deeppink3", "lightblue4", "gray80")) #customizing the colors of each bar

pivot
# A tibble: 51 × 12
    Year `Alcohol 12-17` `Alcohol 18-25` `Alcohol 26+` `Cocaine 12-17`
   <dbl>           <dbl>           <dbl>         <dbl>           <dbl>
 1  2002            1464            5467         11016             473
 2  2002            1464            5467         11016             473
 3  2002            1464            5467         11016             473
 4  2003            1491            5538         11198             425
 5  2003            1491            5538         11198             425
 6  2003            1491            5538         11198             425
 7  2004            1459            5651         11545             415
 8  2004            1459            5651         11545             415
 9  2004            1459            5651         11545             415
10  2005            1385            5735         11640             417
# ℹ 41 more rows
# ℹ 7 more variables: `Cocaine 18-25` <dbl>, `Cocaine 26+` <dbl>,
#   `Marijuana 12-17` <dbl>, `Marijuana 18-25` <dbl>, `Marijuana 26+` <dbl>,
#   `Age Groups` <chr>, `Drug Abuse Totals` <dbl>

#wide data --> long data ,, creating two new categories and tidying numerical data within categories 
substance_pivot = age_abuse %>% 
  pivot_longer(
    cols = c(`Alcohol 12-17`, `Alcohol 18-25`, `Alcohol 26+`, `Cocaine 12-17`, `Cocaine 18-25`, `Cocaine 26+`, `Marijuana 12-17`, `Marijuana 18-25`, `Marijuana 26+`),
    names_to = c("Substance", "Age Group"), 
    names_sep = " ", 
    values_to = "Abuse Counts"
  )
ggplot(substance_pivot, aes(x = `Age Group`, y = `Abuse Counts`, color = Substance, group = Substance,)) + 
  geom_boxplot(alpha = .3, outlier.colour = "slateblue3") + #changing the color of the two outlier points 
  theme_minimal() +
  stat_summary(fun = mean, geom = "line", linewidth = .8) + #graphing line to connect average points  
  stat_summary(fun = mean, geom = "point", size = 1.6) + #graphing the average points 
  labs(
    title = "Relationship Between Substance Abuse Across Age Groups", #title
    subtitle = "Tracking Average Substance Abuse of Each Age Group", #subtitle 
    caption = "Source: CORGIS, gathered by NSDUH", #data source
    y = "Average Abuse") + #y-axis
  scale_color_manual(values = c("hotpink3", "turquoise3", "snow4")) + #custom colors 
  scale_fill_manual(values = c("hotpink3","turquoise3", "snow4" )) #custom colors 


Linear Regression

fit1 = lm(`Abuse Counts` ~ `Age Group`* Substance, data = substance_pivot)
summary(fit1)

Call:
lm(formula = `Abuse Counts` ~ `Age Group` * Substance, data = substance_pivot)

Residuals:
    Min      1Q  Median      3Q     Max 
-5258.9  -317.5   -12.5   322.5 12993.1 

Coefficients:
                                    Estimate Std. Error t value Pr(>|t|)    
(Intercept)                            980.5      475.4   2.063 0.040948 *  
`Age Group`18-25                      3838.1      672.3   5.709 6.25e-08 ***
`Age Group`26+                       10451.1      672.3  15.546  < 2e-16 ***
SubstanceCocaine                      -722.3      672.3  -1.074 0.284427    
SubstanceMarijuana                    2362.8      672.3   3.515 0.000589 ***
`Age Group`18-25:SubstanceCocaine    -2203.8      950.7  -2.318 0.021854 *  
`Age Group`26+:SubstanceCocaine      -7694.8      950.7  -8.094 2.21e-13 ***
`Age Group`18-25:SubstanceMarijuana   3148.2      950.7   3.311 0.001173 ** 
`Age Group`26+:SubstanceMarijuana     3992.6      950.7   4.200 4.66e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1960 on 144 degrees of freedom
Multiple R-squared:  0.8957,    Adjusted R-squared:   0.89 
F-statistic: 154.7 on 8 and 144 DF,  p-value: < 2.2e-16

P-Value = 2.2e-16 <0.05

Adjusted R-Squared = .89

Equation: Y = 980.5 + 3838.1 (18-25) + 10451.1 (26+) - 722.3 (Cocaine) + 2362.8 (Marijuana) -2203.8 (18-25 Cocaine) - 7694.8 (26+ Cocaine) + 3148.2 (18-25 Marijuana) + 3992.6 (26+ Marijuana)


Conclusions

Cleaning

I began by cleaning the dataset, as it contained a lot of data. Using the select() function and incorporating both starts_with() / contains() functions allowed me to keep the total substance abuse from the past year for every age group and substance type. The data was separated by state and year, so each year had 50 entries. To refine the data, I made use of the group_by() function and totaled the values for each year entry, leaving one row per year.

Visualizations

The first visualization dealt with comparing the total substance abuse across age groups. Each variable had its own column, resulting in wide data. In order to visualize it, I utilized pivot_longer() to collapse my data into two standard columns.

I then turned the data into a bar graph to easily compare the substance abuse of each age group visually. The visualization displayed a considerable difference in total substance abuse across age groups. The total substance abuse of those 26 and older was substantially higher compared to 12-17 and 18-25. Total substance abuse among 12-17 presented a downward trend (decrease in total substance abuse) as time went on, whereas 26+ exhibited an upward trend (increasing substance abuse). Total substance abuse among 18-25 was between the two and stayed relatively stable throughout the years.

Again, I used pivot_longer() to make the data suitable for the box plot and linear regression. This time, pivot_longer() created two new categories and tidied the numerical data within them.

I then used the new pivot data to create a box plot. Geom = “point” graphed the points of substance abuse averages for each age group. Geom = “line” connected the points, allowing comparison to be easier. Among the three substance types, marijuana had the highest abuse for all age groups. Cocaine had the lowest average use, and alcohol was in the middle.

Linear Regression

The linear regression was meant to evaluate the relationship between age groups (12-17, 18-25, 26+) and specific substance abuse (Alcohol, Cocaine, Marijuana). The p-value was extremely statistically significant at 2.2e-16 (almost 0). The p-value being as small as it was proved that there is a highly significant relationship between age group and specific substance use. We can understand that the model is highly accurate, as adjusted R-squared = .89. Overall, the model suggests there is a significant relationship between age group and specific substance abuse.


Technical Challenges

One technical challenge I faced was actually visualizing the data. Since I had wide data, I needed to incorporate the pivot() function to convert it into long data to visualize it properly. I struggled with the pivot() function even with the assistance of class slides and an RStudio Guide. It was definitely a trial-and-error process, with many errors.