GDP components over time and among countries
2020-10-05
At the risk of oversimplifying things, the main components of gross domestic product, GDP are personal consumption (C), business investment (I), government spending (G) and net exports (exports - imports). You can read more about GDP and the different approaches in calculating at the Wikipedia GDP page.
The GDP data we will look at is from the United Nations’ National Accounts Main Aggregates Database, which contains estimates of total GDP and its components for all countries from 1970 to today. We will look at how GDP and its components have changed over time, and compare different countries and how much each component contributes to that country’s GDP. The file we will work with is GDP and its breakdown at constant 2010 prices in US Dollars and it has already been saved in the Data directory. Have a look at the Excel file to see how it is structured and organised
library(openxlsx)
UN_GDP_data <- openxlsx::read.xlsx(here::here("data", "Download-GDPconstant-USD-countries.xlsx"))
glimpse(UN_GDP_data)
## Rows: 3,685
## Columns: 51
## $ CountryID <dbl> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8…
## $ Country <chr> "Afghanistan", "Afghanistan", "Afghanistan", "Afghanist…
## $ IndicatorName <chr> "Final consumption expenditure", "Household consumption…
## $ `1970` <dbl> 5.56e+09, 5.07e+09, 3.72e+08, 9.85e+08, 9.85e+08, 1.12e…
## $ `1971` <dbl> 5.33e+09, 4.84e+09, 3.82e+08, 1.05e+09, 1.05e+09, 1.45e…
## $ `1972` <dbl> 5.20e+09, 4.70e+09, 4.02e+08, 9.19e+08, 9.19e+08, 1.73e…
## $ `1973` <dbl> 5.75e+09, 5.21e+09, 4.21e+08, 9.19e+08, 9.19e+08, 2.18e…
## $ `1974` <dbl> 6.15e+09, 5.59e+09, 4.31e+08, 1.18e+09, 1.18e+09, 3.00e…
## $ `1975` <dbl> 6.32e+09, 5.65e+09, 5.98e+08, 1.37e+09, 1.37e+09, 3.16e…
## $ `1976` <dbl> 6.37e+09, 5.68e+09, 6.27e+08, 2.03e+09, 2.03e+09, 4.17e…
## $ `1977` <dbl> 6.90e+09, 6.15e+09, 6.76e+08, 1.92e+09, 1.92e+09, 4.31e…
## $ `1978` <dbl> 7.09e+09, 6.30e+09, 7.25e+08, 2.22e+09, 2.22e+09, 4.57e…
## $ `1979` <dbl> 6.92e+09, 6.15e+09, 7.08e+08, 2.07e+09, 2.07e+09, 4.89e…
## $ `1980` <dbl> 6.69e+09, 5.95e+09, 6.85e+08, 1.98e+09, 1.98e+09, 4.53e…
## $ `1981` <dbl> 6.81e+09, 6.06e+09, 6.97e+08, 2.06e+09, 2.06e+09, 4.60e…
## $ `1982` <dbl> 6.96e+09, 6.19e+09, 7.12e+08, 2.08e+09, 2.08e+09, 4.77e…
## $ `1983` <dbl> 7.30e+09, 6.49e+09, 7.47e+08, 2.19e+09, 2.19e+09, 4.96e…
## $ `1984` <dbl> 7.43e+09, 6.61e+09, 7.60e+08, 2.23e+09, 2.23e+09, 5.06e…
## $ `1985` <dbl> 7.45e+09, 6.63e+09, 7.63e+08, 2.23e+09, 2.23e+09, 5.08e…
## $ `1986` <dbl> 7.68e+09, 6.83e+09, 7.85e+08, 2.30e+09, 2.30e+09, 5.23e…
## $ `1987` <dbl> 6.89e+09, 6.12e+09, 7.05e+08, 2.07e+09, 2.07e+09, 4.69e…
## $ `1988` <dbl> 6.32e+09, 5.62e+09, 6.46e+08, 1.90e+09, 1.90e+09, 4.31e…
## $ `1989` <dbl> 5.87e+09, 5.22e+09, 6.01e+08, 1.76e+09, 1.76e+09, 4.00e…
## $ `1990` <dbl> 5.69e+09, 5.06e+09, 5.82e+08, 1.71e+09, 1.71e+09, 3.88e…
## $ `1991` <dbl> 5.28e+09, 4.70e+09, 5.40e+08, 1.51e+09, 1.51e+09, 4.15e…
## $ `1992` <dbl> 5.59e+09, 4.97e+09, 5.72e+08, 1.52e+09, 1.52e+09, 4.92e…
## $ `1993` <dbl> 4.36e+09, 3.87e+09, 4.46e+08, 1.13e+09, 1.13e+09, 4.22e…
## $ `1994` <dbl> 3.52e+09, 3.13e+09, 3.59e+08, 8.70e+08, 8.70e+08, 3.69e…
## $ `1995` <dbl> 5.46e+09, 4.86e+09, 5.60e+08, 1.29e+09, 1.29e+09, 6.16e…
## $ `1996` <dbl> 5.36e+09, 4.76e+09, 5.48e+08, 1.21e+09, 1.21e+09, 6.42e…
## $ `1997` <dbl> 5.25e+09, 4.67e+09, 5.36e+08, 1.14e+09, 1.14e+09, 6.64e…
## $ `1998` <dbl> 5.18e+09, 4.60e+09, 5.33e+08, 1.08e+09, 1.08e+09, 6.87e…
## $ `1999` <dbl> 5.09e+09, 4.52e+09, 5.17e+08, 1.02e+09, 1.02e+09, 7.04e…
## $ `2000` <dbl> 4.95e+09, 4.41e+09, 5.04e+08, 9.53e+08, 9.53e+08, 7.13e…
## $ `2001` <dbl> 4.70e+09, 4.17e+09, 4.95e+08, 1.00e+09, 1.00e+09, 6.54e…
## $ `2002` <dbl> 7.18e+09, 6.40e+09, 7.02e+08, 1.37e+09, 1.37e+09, 9.49e…
## $ `2003` <dbl> 8.87e+09, 7.89e+09, 9.06e+08, 1.54e+09, 1.54e+09, 1.41e…
## $ `2004` <dbl> 8.73e+09, 7.66e+09, 1.05e+09, 1.90e+09, 1.90e+09, 1.11e…
## $ `2005` <dbl> 1.01e+10, 9.00e+09, 1.06e+09, 2.06e+09, 2.06e+09, 1.14e…
## $ `2006` <dbl> 1.07e+10, 9.34e+09, 1.40e+09, 2.06e+09, 2.06e+09, 1.09e…
## $ `2007` <dbl> 1.20e+10, 1.04e+10, 1.71e+09, 2.17e+09, 2.17e+09, 1.03e…
## $ `2008` <dbl> 1.23e+10, 1.06e+10, 1.73e+09, 2.14e+09, 2.14e+09, 1.24e…
## $ `2009` <dbl> 1.29e+10, 1.10e+10, 2.15e+09, 3.12e+09, 3.12e+09, 1.53e…
## $ `2010` <dbl> 1.79e+10, 1.57e+10, 2.25e+09, 2.81e+09, 2.81e+09, 1.58e…
## $ `2011` <dbl> 1.97e+10, 1.70e+10, 2.69e+09, 2.61e+09, 2.61e+09, 1.72e…
## $ `2012` <dbl> 2.91e+10, 2.59e+10, 2.81e+09, 2.85e+09, 2.85e+09, 1.31e…
## $ `2013` <dbl> 3.48e+10, 3.14e+10, 2.81e+09, 2.75e+09, 2.75e+09, 8.34e…
## $ `2014` <dbl> 3.35e+10, 3.02e+10, 2.76e+09, 2.13e+09, 2.13e+09, 1.20e…
## $ `2015` <dbl> 3.53e+10, 3.19e+10, 2.81e+09, 2.29e+09, 2.29e+09, 9.10e…
## $ `2016` <dbl> 3.50e+10, 3.16e+10, 2.84e+09, 2.34e+09, 2.34e+09, 7.54e…
## $ `2017` <dbl> 3.51e+10, 3.16e+10, 2.85e+09, 2.24e+09, 2.24e+09, 7.60e…
The first thing we need to do is to tidy the data, as it is in wide format. We will make it into long, tidy format, expressing all figures in billions (divide values by 1e9, or \(10^9\)), and renaming the indicators into something shorter.
library(reshape)
tidy_GDP_data <- UN_GDP_data %>%
pivot_longer(cols = 4:51, names_to = "Year", values_to = "Obs") %>%
mutate(Obs = Obs / 1e9) %>%
#Rename indicators:
mutate(IndicatorName=case_when(IndicatorName=="Exports of goods and services" ~ "Exports",
IndicatorName=="Imports of goods and services" ~ "Imports",
IndicatorName=="General government final consumption expenditure" ~ "Gov_Expenditure",
IndicatorName=="Gross capital formation" ~ "Capital_formation",
IndicatorName=="Household consumption expenditure (including Non-profit institutions serving households)" ~ "Household_Consumption",
IndicatorName=="Gross Domestic Product (GDP)" ~ "GDP")) %>%
#Filter only relevant indicators:
filter(IndicatorName %in% c("Exports", "Imports", "Gov_Expenditure", "Capital_formation", "Household_Consumption", "GDP"))
glimpse(tidy_GDP_data)
## Rows: 63,072
## Columns: 5
## $ CountryID <dbl> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4…
## $ Country <chr> "Afghanistan", "Afghanistan", "Afghanistan", "Afghanist…
## $ IndicatorName <chr> "Household_Consumption", "Household_Consumption", "Hous…
## $ Year <chr> "1970", "1971", "1972", "1973", "1974", "1975", "1976",…
## $ Obs <dbl> 5.07, 4.84, 4.70, 5.21, 5.59, 5.65, 5.68, 6.15, 6.30, 6…
# Let us compare GDP components for these 3 countries
country_list <- c("United States","India", "Germany")
We now produce a plot for comparing the GDP components over time for three countries: United States, India and Germany. We see that household consumption expenditure in the US has increased strongly.
Secondly, recall that GDP is the sum of Household Expenditure (Consumption C), Gross Capital Formation (business investment I), Government Expenditure (G) and Net Exports (exports - imports). Even though there is an indicator Gross Domestic Product (GDP) in your dataframe, we would like to calculate it given its components discussed above.
We will also check the % difference between what we calculated as GDP and the GDP figure included in the dataframe.
## # A tibble: 10,560 x 3
## Year Country GDP_Difference_Percentage
## <chr> <chr> <dbl>
## 1 1970 Afghanistan -40.8
## 2 1971 Afghanistan -42.5
## 3 1972 Afghanistan -33.6
## 4 1973 Afghanistan -29.4
## 5 1974 Afghanistan -26.9
## 6 1975 Afghanistan -27.5
## 7 1976 Afghanistan -24.6
## 8 1977 Afghanistan -17.7
## 9 1978 Afghanistan -19.0
## 10 1979 Afghanistan -19.6
## # … with 10,550 more rows
Lastly, this last chart shows us the different dynamic among these three countries (Germany, India and United States). In Germany, in 40 years there have no been important variations in the proportion of household or government expenditure among the total GDP. However, the proportion of net exports did increase, something that did not happen in India and in the US when compared to 1970. Moreover, India has experienced an important reduction in household expenditure and an increase in gross capital formation. A possible explanation of this is that households save more money and it ends up in investments and creation of new family businesses.
## # A tibble: 10,560 x 6
## Year Country Gov_Expenditure… Net_Exports_prop Capital_formati…
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 1970 Afghan… 5.87 -1.13 15.5
## 2 1971 Afghan… 6.21 -2.01 17.1
## 3 1972 Afghan… 6.77 -1.45 15.5
## 4 1973 Afghan… 6.49 -0.923 14.2
## 5 1974 Afghan… 6.08 -1.52 16.7
## 6 1975 Afghan… 8.00 -1.91 18.3
## 7 1976 Afghan… 7.65 -1.80 24.8
## 8 1977 Afghan… 7.96 -2.92 22.6
## 9 1978 Afghan… 8.08 -3.02 24.7
## 10 1979 Afghan… 8.15 -2.92 23.9
## # … with 10,550 more rows, and 1 more variable:
## # Household_Consumption_prop <dbl>