library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── 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
GDP_data <- read.csv("C:/Users/nika/Downloads/R/csv/GDP_data.csv", skip = 4)

Introduction

Did the 2008 financial crisis and COVID-19 pandemic affect GDP growth rates differently across continents? The data set used in this project was taken from the World Bank Open Data: GDP Growth https://data.worldbank.org/indicator/NY.GDP.MKTP.KD.ZG. The data set shows the GDP values per year per country, looking at rate changes from 1961 to the present (2025). The data set holds a variety of different variable and is formulated to show the years as columns with rate changes as dependent variables. The main variables that will be used throughout this study are: GDP Growth Rate, Continent, Crisis Period, Country, and Year.

Data Analysis

To answer the research question, I will create two graphs, a line plot comparing the GDP of continents over the years as well as box plots of the two financial crises for each continent. The line graph would give us a general overview of the trend between each continent and allow us to identify if any of the continents experienced outlines. The box plot on the other hand, will allow us to compare the medium growth rate change between continents during the crisis and establish possible patterns in the data.

colnames(GDP_data)
##  [1] "Country.Name"   "Country.Code"   "Indicator.Name" "Indicator.Code"
##  [5] "X1960"          "X1961"          "X1962"          "X1963"         
##  [9] "X1964"          "X1965"          "X1966"          "X1967"         
## [13] "X1968"          "X1969"          "X1970"          "X1971"         
## [17] "X1972"          "X1973"          "X1974"          "X1975"         
## [21] "X1976"          "X1977"          "X1978"          "X1979"         
## [25] "X1980"          "X1981"          "X1982"          "X1983"         
## [29] "X1984"          "X1985"          "X1986"          "X1987"         
## [33] "X1988"          "X1989"          "X1990"          "X1991"         
## [37] "X1992"          "X1993"          "X1994"          "X1995"         
## [41] "X1996"          "X1997"          "X1998"          "X1999"         
## [45] "X2000"          "X2001"          "X2002"          "X2003"         
## [49] "X2004"          "X2005"          "X2006"          "X2007"         
## [53] "X2008"          "X2009"          "X2010"          "X2011"         
## [57] "X2012"          "X2013"          "X2014"          "X2015"         
## [61] "X2016"          "X2017"          "X2018"          "X2019"         
## [65] "X2020"          "X2021"          "X2022"          "X2023"         
## [69] "X2024"          "X"
head(GDP_data)
##                  Country.Name Country.Code        Indicator.Name
## 1                       Aruba          ABW GDP growth (annual %)
## 2 Africa Eastern and Southern          AFE GDP growth (annual %)
## 3                 Afghanistan          AFG GDP growth (annual %)
## 4  Africa Western and Central          AFW GDP growth (annual %)
## 5                      Angola          AGO GDP growth (annual %)
## 6                     Albania          ALB GDP growth (annual %)
##      Indicator.Code X1960     X1961    X1962    X1963    X1964    X1965
## 1 NY.GDP.MKTP.KD.ZG    NA        NA       NA       NA       NA       NA
## 2 NY.GDP.MKTP.KD.ZG    NA 0.4697078 7.868623 5.622472 4.689533 5.159536
## 3 NY.GDP.MKTP.KD.ZG    NA        NA       NA       NA       NA       NA
## 4 NY.GDP.MKTP.KD.ZG    NA 1.8696369 3.725941 7.039191 5.364761 4.105616
## 5 NY.GDP.MKTP.KD.ZG    NA        NA       NA       NA       NA       NA
## 6 NY.GDP.MKTP.KD.ZG    NA        NA       NA       NA       NA       NA
##       X1966     X1967    X1968     X1969     X1970     X1971    X1972    X1973
## 1        NA        NA       NA        NA        NA        NA       NA       NA
## 2  4.822258  5.373938 4.153383  5.091807  1.135154  5.479342 2.771158 4.606450
## 3        NA        NA       NA        NA        NA        NA       NA       NA
## 4 -1.512989 -8.967443 1.558993 15.127190 17.382531 10.453272 3.153188 3.952264
## 5        NA        NA       NA        NA        NA        NA       NA       NA
## 6        NA        NA       NA        NA        NA        NA       NA       NA
##      X1974     X1975    X1976    X1977     X1978    X1979    X1980     X1981
## 1       NA        NA       NA       NA        NA       NA       NA        NA
## 2 5.475813  1.404329 2.382201 1.120648  1.508609 2.930523 5.464293  4.014091
## 3       NA        NA       NA       NA        NA       NA       NA        NA
## 4 9.975607 -2.077795 8.394825 4.551447 -1.917931 5.001670 1.905791 -6.701354
## 5       NA        NA       NA       NA        NA       NA       NA -4.400001
## 6       NA        NA       NA       NA        NA       NA       NA  5.745635
##        X1982       X1983      X1984      X1985    X1986      X1987     X1988
## 1         NA          NA         NA         NA       NA 16.0784314 18.648649
## 2  0.3151527  0.03932852  3.3652804 -0.1280365 2.266005  3.9545238  4.274110
## 3         NA          NA         NA         NA       NA         NA        NA
## 4 -3.2229169 -6.25245904  0.5418582  5.3946427 1.337552  1.4297519  4.679828
## 5  0.0000000  4.20000143  6.0000022  3.4999995 2.900002  4.0827486  6.128890
## 6  2.9485968  1.10493826 -1.2515966  1.7806440 5.637243 -0.7878427 -1.420040
##         X1989      X1990        X1991     X1992       X1993      X1994
## 1 12.12984055  3.9614017   7.96287173  5.882354   7.3076932  8.2039013
## 2  2.69634244  0.1758673  -0.09546367 -2.350160  -0.5994377  1.9320314
## 3          NA         NA           NA        NA          NA         NA
## 4  1.72672657  5.6968803   1.06723219  2.350220  -1.3626449 -0.2831964
## 5  0.04162146 -3.4500987   0.99135930 -5.838281 -23.9834174  1.3393634
## 6  9.83654897 -9.5756402 -28.00214165 -7.187111   9.5594117  8.3028666
##       X1995     X1996      X1997    X1998     X1999    X2000     X2001
## 1  2.547144  1.185789   7.046875 1.991984  1.238042 7.622921  4.182002
## 2  4.282648  5.454335   3.841977 1.752629  2.649285 3.212167  3.505488
## 3        NA        NA         NA       NA        NA       NA -9.431974
## 4  1.859801  4.629126   4.403075 3.623420  1.528189 3.842479  5.207033
## 5 15.000000 13.544370   7.274277 4.691146  2.181490 3.054624  4.205999
## 6 13.322333  7.336329 -11.711573 8.310025 12.250728 7.462859  8.863731
##        X2002    X2003     X2004      X2005     X2006     X2007     X2008
## 1 -0.9449535 1.110505  7.293728 -0.3831377  1.127411  3.089544  1.835755
## 2  3.8338481 2.952939  5.554448  6.1624933  6.577439  6.646935  4.366173
## 3 28.6000012 8.832278  1.414118 11.2297148  5.357403 13.826320  3.924984
## 4  9.9688021 5.597677  8.094673  5.9121109  5.355184  5.502329  6.276135
## 5 13.6656888 2.990000 10.950000 15.0300000 11.550000 14.010000 11.170000
## 6  4.6283959 5.333264  5.266262  5.1308219  6.018981  6.500093  6.907062
##         X2009     X2010     X2011      X2012    X2013     X2014      X2015
## 1 -11.6777414 -2.733457 3.3692372 -1.0407999 6.431483 -1.586575 -0.6236259
## 2   0.8926514  5.207943 4.0589233  1.7679695 4.317725  4.014351  3.0033669
## 3  21.3905284 14.362441 0.4263548 12.7522871 5.600745  2.724543  1.4513147
## 4   6.1255292  7.032025 4.9466662  5.1405756 6.028023  5.712459  2.9280096
## 5   0.8600000  4.398376 3.4720531  8.5421071 4.954613  4.822559  0.9435716
## 6   2.6907515  2.973154 2.4635168  0.9841299 1.707228  2.240227  2.2277041
##        X2016      X2017     X2018     X2019       X2020      X2021     X2022
## 1  1.7196250  7.0485334  2.397086 -2.232442 -26.2118202  24.132627  8.517918
## 2  2.1959912  2.6962378  2.665038  2.200340  -2.8597839   4.563568  3.555769
## 3  2.2603142  2.6470032  1.189228  3.911603  -2.3511007 -20.738839 -6.240172
## 4  0.1941775  2.2961675  2.904654  3.282163  -0.9841174   4.030000  3.974964
## 5 -2.5800496 -0.1472129 -1.316362 -0.702273  -5.6382147   1.199211  3.044727
## 6  3.9089355  3.2831759  3.671419  2.062578  -3.3137564   8.969576  4.826696
##      X2023    X2024  X
## 1 4.263719       NA NA
## 2 1.891307 2.766804 NA
## 3 2.266944       NA NA
## 4 3.357987 4.176103 NA
## 5 1.078100 4.423905 NA
## 6 3.936617 3.961719 NA
GDP_data_clean <- GDP_data |>
  pivot_longer(cols = starts_with("X"), names_to = "Year", values_to = "growth_rate") |>
  mutate(Year = as.numeric(substring(Year, 2))) |>
  filter(!is.na(growth_rate)) |>
  filter(Year >= 2006 & Year <= 2024) |>
  select('Country.Name', Year, growth_rate) |>
  mutate(Covid = Year %in% c(2020, 2021), Financial_Crisis = Year %in% c(2008, 2009)) |>
  mutate(Continent = case_when(
    `Country.Name` %in% c("Argentina", "Bolivarian Republic of Venezuela", "Brazil", "Chile", "Colombia", "Ecuador", "Guyana", "Paraguay", "Plurinational State of Bolivia", "Peru", "Suriname", "Uruguay", "Aruba", "Bolivia", "Curacao", "Latin America & Caribbean") ~ "South America",
    
    `Country.Name` %in% c("Antigua and Barbuda", "Bahamas", "Barbados", "Belize", "Canada", "Costa Rica", "Cuba", "Dominica", "Dominican Republic", "El Salvador", "Grenada", "Guatemal", "Haiti", "Honduras", "Jamaica", "Mexico", "Nicaragua", "Panama", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Trinidad and Tobago", "United States", "Bahamas, The", "Bermuda", "Caribbean small states", "Cayman Islands", "Greenland", "St. Kitts and Nevis", "St. Lucia", "St. Martin", "North America", "Puerto Rico (US)", "Sint Maarten (Dutch part)", "Turks and Caicos Islands", "St. Vincent and the Grenadines", "Virgin Islands (U.S.)") ~ "North America",
    
    `Country.Name` %in% c("Albania", "Andorra", "Armenia", "Austria", "Azerbaijan", "Belarus", "Belgium", "Bosnia and Herzegovina", "Bulgaria", "Croatia", "Czechia", "Denmark", "Estonia", "Finland", "France", "Georgia", "Germany", "Greece", "Hungary", "Iceland", "Ireland", "Italy", "Netherlands", "Latvia", "Liechtenstein", "Lithuania", "Luxembourg", "Malta", "Monaco", "Montenegro", "North Macedonia", "Norway", "Poland", "Portugal", "Republic of Moldova", "Romania", "Russian Federation", "San Marino", "Serbia", "Slovakia", "Slovenia", "Spain", "Sweden", "Switzerland", "Türkiye", "Ukraine", "United Kingdom", "Central Europe and the Baltics", "Channel Islands", "Europe & Central Asia", "Euro area", "European Union", "Faroe Islands", "Isle of Man", "Moldova", "Slovak Republic", "Kosovo") ~ "Europe",
    
    `Country.Name` %in% c("Afghanistan", "Bahrain", "Bangladesh", "Bhutan", "Brunei Darussalam", "Cambodia", "China", "Cyprus", "North Korea", "India", "Indonesia", "Iraq", "Islamic Republic of Iran", "Israel", "Japan", "Jordan", "Kazakhstan", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic", "Lebanon", "Malaysia", "Maldives", "Mongolia", "Myanmar", "Nepal", "Oman", "Pakistan", "Philippines", "Qatar", "Korea", "Saudi Arabia", "Singapore", "Sri Lanka", "Syrian Arab Republic", "Tajikistan", "Thailand", "Timor-Leste", "Turkmenistan", "United Arab Emirates", "Uzbekistan", "Viet Nam", "Yemen", "East Asia & Pacific", "Hong Kong SAR, China", "Iran, Islamic Rep.", "Kyrgyz Republic", "Korea, Rep.", "Macao SAR, China", "Middle East, North Africa, Afghanistan & Pakistan", "West Bank and Gaza", "South Asia", "Turkiye", "Yemen, Rep.") ~ "Asia",
    
    `Country.Name` %in% c("Algeria", "Angola", "Benin", "Botswana", "Burkina Faso", "Burundi", "Cabo Verde", "Cameroon", "Central African Republic", "Chad", "Comoros", "Congo", "Côte d'Ivoire", "Democratic Republic of the Congo", "Djibouti", "Egypt", "Equatorial Guinea", "Eritrea", "Eswatini", "Ethiopia", "Gabon", "Gambia", "Ghana", "Guinea", "Guinea Bissau", "Kenya", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi", "Mali", "Mauritania", "Mauritius", "Morocco", "Mozambique", "Namibia", "Niger", "Nigeria", "Rwanda", "São Tomé and Príncipe", "Senegal", "Seychelles", "Sierra Leone", "Somalia", "South Africa", "South Sudan", "Sudan", "Togo", "Tunisia", "Uganda", "United Republic of Tanzania", "Zambia", "Zimbabwe", "Africa Eastern and Southern", "Africa Western and Central", "Arab World", "Cote d'Ivoire", "Congo, Dem. Rep.", "Egypt, Arab Rep.", "Gambia, The", "Guinea-Bissau", "Somalia, Fed. Rep.", "Sub-Saharan Africa", "Sao Tome and Principe", "Tanzania") ~ "Africa",
    
    `Country.Name` %in% c("Australia", "Federated States of Micronesia", "Fiji", "Kiribati", "Marshall Islands", "Nauru", "New Zealand", "Palau", "Papua New Guinea", "Samoa", "Solomon Islands", "Tonga", "Tuvalu", "Vanuatu", "American Samoa", "Micronesia, Fed. Sts.", "Guam", "Northern Mariana Islands", "New Caledonia", "Pacific island small states", "French Polynesia") ~ "Oceania",
    TRUE ~ NA_character_
  )) |>
    mutate(crisis_type = case_when(Financial_Crisis == TRUE ~ "Financial Crisis", Covid == TRUE ~ "COVID-19"))

summary(GDP_data_clean)
##  Country.Name            Year       growth_rate        Covid        
##  Length:4842        Min.   :2006   Min.   :-54.336   Mode :logical  
##  Class :character   1st Qu.:2010   1st Qu.:  1.307   FALSE:4328     
##  Mode  :character   Median :2015   Median :  3.424   TRUE :514      
##                     Mean   :2015   Mean   :  3.180                  
##                     3rd Qu.:2020   3rd Qu.:  5.604                  
##                     Max.   :2024   Max.   : 91.137                  
##  Financial_Crisis  Continent         crisis_type       
##  Mode :logical    Length:4842        Length:4842       
##  FALSE:4331       Class :character   Class :character  
##  TRUE :511        Mode  :character   Mode  :character  
##                                                        
##                                                        
## 
GDP_data_clean |>
  group_by(Covid) |>
    summarize(mean_growth = mean(growth_rate, na.rm = TRUE), median_growth = median(growth_rate, na.rm = TRUE), sd_growth = sd(growth_rate, na.rm = TRUE), min_growth = min(growth_rate, na.rm = TRUE), max_growth = max(growth_rate, na.rm = TRUE), count = n())
## # A tibble: 2 × 7
##   Covid mean_growth median_growth sd_growth min_growth max_growth count
##   <lgl>       <dbl>         <dbl>     <dbl>      <dbl>      <dbl> <int>
## 1 FALSE       3.50           3.52      5.06      -50.3       91.1  4328
## 2 TRUE        0.521          1.30      8.66      -54.3       43.5   514
GDP_data_clean |>
  group_by(Financial_Crisis) |>
    summarize(mean_growth = mean(growth_rate, na.rm = TRUE), median_growth = median(growth_rate, na.rm = TRUE), sd_growth = sd(growth_rate, na.rm = TRUE))
## # A tibble: 2 × 4
##   Financial_Crisis mean_growth median_growth sd_growth
##   <lgl>                  <dbl>         <dbl>     <dbl>
## 1 FALSE                   3.33          3.50      5.64
## 2 TRUE                    1.90          2.75      5.36
GDP_data_clean |>
  filter(!is.na(Continent)) |>
  group_by(Continent, Year) |>
  summarize(mean_growth = mean(growth_rate, na.rm = TRUE)) |>
  ggplot(aes(x = Year, y = mean_growth, color = Continent)) +
  geom_line(size = 1.2) +
  geom_point(size = 2) +
  geom_vline(xintercept = c(2008, 2020), linetype = "dashed", color = "gray50") +
  labs(title = "Mean GDP Growth by Continent (2006-2024)",
       x = "Year", 
       y = "Mean GDP Growth Rate (%)",
       color = "Continent") +
  theme_minimal() +
  theme(legend.position = "bottom")
## `summarise()` has grouped output by 'Continent'. You can override using the
## `.groups` argument.
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

GDP_data_clean |>
  filter(!is.na(crisis_type), !is.na(Continent)) |>
  ggplot(aes(x = Continent, y = growth_rate, fill = crisis_type)) +
  geom_boxplot() +
  labs(title = "GDP Growth Rate Distribution: Financial Crisis vs COVID-19 by Continent",
       x = "Continent", 
       y = "GDP Growth Rate (%)",
       fill = "Crisis Type") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Statistical Analysis

Hypothesis \(H_0\): \(\mu_1\) = \(\mu_2\) = \(\mu_3\) = \(\mu_4\) = \(\mu_5\) = \(\mu_6\) \(H_a\): not all \(\mu_i\) are equal

(\(\mu_1\) = mean GDP growth rate for Africa, \(\mu_2\) = mean GDP growth rate for Asia, \(\mu_3\) = mean GDP growth rate for Europe, \(\mu_4\) = mean GDP growth rate for North America, \(\mu_5\) = mean GDP growth rate for South America, \(\mu_6\) = mean GDP growth rate for Oceania)

GDP_crisis <- GDP_data_clean |>
  filter(!is.na(crisis_type), !is.na(Continent))

anova_result <- aov(growth_rate ~ Continent * crisis_type, data = GDP_crisis)
summary(anova_result)
##                        Df Sum Sq Mean Sq F value   Pr(>F)    
## Continent               5   1909   381.7   7.015 1.94e-06 ***
## crisis_type             1    353   352.9   6.486 0.011042 *  
## Continent:crisis_type   5   1225   245.1   4.504 0.000465 ***
## Residuals             865  47064    54.4                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

From the results, we see that the p-value is relatively small (1.94e-06, which is smaller than an a of 0.05) indicating strong evidence against the null hypothesis. Overall, this test suggests that there are significant differences in mean GDP growth rates between continents.

Conclusion

The analysis examined the effect of the 2008 financial crisis and COVID 19 on GDP growth rates across different continents. The line plot revealed that Europe was most affected by the 2008 financial crisis, quickly followed by North America. On the other hand, during COVID 19, North America was most affected, seconded by South America. We also see that during COVID 19, all continents experience a much more drastic and severe drop than during the 2008 financial crisis. The box plot analysis demonstrates considerable variation in the experience of each continent during each crisis.During the 2008 financial crisis, Europe experienced the widest distribution of growth rates with several extremely negative outliers, indicating that some European countries were hit particularly hard. During COVID 19, the box plots show that all continents have much wider distributions than what they experienced during the 2008 financial crisis, with South America experiencing a particularly wide growth rate distribution. The ANOVA test confirmed these visual observations, with a highly significant p-value which lead us to reject the null hypothesis. This statistical evidence confirms that mean GDP growth rates vary significantly across continents.

These findings are important to understanding global economics and interconnections between countries/continents. The shorter but deeper impact of COVID 19 compared to the prolonged 2008 financial crisis suggests that health related global shocks affect economics differently than that of financial system failures. Furthermore, from the relatively strong performance of Asian and African economies during both crises may reflect lower integration with global financial and public health markets. For policymakers, these results highlight the importance of region-specific economic strategies during global crises. Understanding these impacts can help create better crisis preparedness and recovery strategies.

Future research can deepen this discussion and look at the differences in GDP growth rates between individual countries within each continent and identify national factors that contribute to vulnerability. Furthermore, future research can examine the recovery trajectories of each continent, providing insight into which regions recover fastest and why. Lastly, future studies can expand the time frame to include earlier economic crises to identify long term patterns in responses to shocks between different regions.

References:

https://tidyr.tidyverse.org/reference/pivot_longer.html

https://data.worldbank.org/indicator/NY.GDP.MKTP.KD.ZG