This analysis explores healthcare spending as a percentage of GDP across countries over the past 10 years from 2014-2023. The guiding question for this is: How did current healthcare expenditure as a percentage of GDP vary across countries and overtime from 2014-2023?
Two analyses were conducted by comparing healthcare expenditure across countries and looking at how it changed over time.
The data was obtained from the World Bank website.
Data Source: World Bank - Current Health Expenditure (% of GDP)
# Import R packages
library(readr)
library(dplyr)
library(ggplot2)
#Import the healthcare expenditure CSV datafile
health <- read_csv("Heath Expenditure vs GDP.csv", skip =4)
## New names:
## Rows: 265 Columns: 71
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (4): Country Name, Country Code, Indicator Name, Indicator Code dbl (25): 2000,
## 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, ... lgl (42): 1960,
## 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, ...
## ℹ 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.
## • `` -> `...71`
health
## # A tibble: 265 × 71
## `Country Name` `Country Code` `Indicator Name` `Indicator Code` `1960` `1961`
## <chr> <chr> <chr> <chr> <lgl> <lgl>
## 1 Aruba ABW Current health … SH.XPD.CHEX.GD.… NA NA
## 2 Africa Easter… AFE Current health … SH.XPD.CHEX.GD.… NA NA
## 3 Afghanistan AFG Current health … SH.XPD.CHEX.GD.… NA NA
## 4 Africa Wester… AFW Current health … SH.XPD.CHEX.GD.… NA NA
## 5 Angola AGO Current health … SH.XPD.CHEX.GD.… NA NA
## 6 Albania ALB Current health … SH.XPD.CHEX.GD.… NA NA
## 7 Andorra AND Current health … SH.XPD.CHEX.GD.… NA NA
## 8 Arab World ARB Current health … SH.XPD.CHEX.GD.… NA NA
## 9 United Arab E… ARE Current health … SH.XPD.CHEX.GD.… NA NA
## 10 Argentina ARG Current health … SH.XPD.CHEX.GD.… NA NA
## # ℹ 255 more rows
## # ℹ 65 more variables: `1962` <lgl>, `1963` <lgl>, `1964` <lgl>, `1965` <lgl>,
## # `1966` <lgl>, `1967` <lgl>, `1968` <lgl>, `1969` <lgl>, `1970` <lgl>,
## # `1971` <lgl>, `1972` <lgl>, `1973` <lgl>, `1974` <lgl>, `1975` <lgl>,
## # `1976` <lgl>, `1977` <lgl>, `1978` <lgl>, `1979` <lgl>, `1980` <lgl>,
## # `1981` <lgl>, `1982` <lgl>, `1983` <lgl>, `1984` <lgl>, `1985` <lgl>,
## # `1986` <lgl>, `1987` <lgl>, `1988` <lgl>, `1989` <lgl>, `1990` <lgl>, …
#Select country information and healthcare expenditure data from 2014 to 2023
health_10yr <- health %>% select('Country Name', 'Country Code', '2014':'2023')
health_10yr
## # A tibble: 265 × 12
## `Country Name` `Country Code` `2014` `2015` `2016` `2017` `2018` `2019`
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Aruba ABW NA NA NA NA NA NA
## 2 Africa Eastern and … AFE 5.71 5.89 6.01 5.86 5.73 5.75
## 3 Afghanistan AFG 9.53 10.1 11.8 12.6 14.2 14.8
## 4 Africa Western and … AFW 3.60 3.81 3.80 3.73 3.29 3.25
## 5 Angola AGO 2.16 2.30 2.39 2.44 2.30 2.20
## 6 Albania ALB 6.36 6.39 6.65 6.50 6.59 6.78
## 7 Andorra AND 6.77 6.91 6.94 7.07 7.38 7.32
## 8 Arab World ARB 4.50 5.01 5.29 5.16 4.87 4.95
## 9 United Arab Emirates ARE 3.53 3.47 3.90 4.01 4.10 4.40
## 10 Argentina ARG 9.80 10.3 10.1 10.3 10.2 10.1
## # ℹ 255 more rows
## # ℹ 4 more variables: `2020` <dbl>, `2021` <dbl>, `2022` <dbl>, `2023` <dbl>
#Check for missing NA values
colSums(is.na(health_10yr))
## Country Name Country Code 2014 2015 2016 2017
## 0 0 27 27 27 26
## 2018 2019 2020 2021 2022 2023
## 25 25 25 25 26 26
#Calculate the average for 2014-2023 for each country
health_10yr$average_health <- rowMeans( health_10yr[, c("2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023")], na.rm = TRUE)
health_10yr
## # A tibble: 265 × 13
## `Country Name` `Country Code` `2014` `2015` `2016` `2017` `2018` `2019`
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Aruba ABW NA NA NA NA NA NA
## 2 Africa Eastern and … AFE 5.71 5.89 6.01 5.86 5.73 5.75
## 3 Afghanistan AFG 9.53 10.1 11.8 12.6 14.2 14.8
## 4 Africa Western and … AFW 3.60 3.81 3.80 3.73 3.29 3.25
## 5 Angola AGO 2.16 2.30 2.39 2.44 2.30 2.20
## 6 Albania ALB 6.36 6.39 6.65 6.50 6.59 6.78
## 7 Andorra AND 6.77 6.91 6.94 7.07 7.38 7.32
## 8 Arab World ARB 4.50 5.01 5.29 5.16 4.87 4.95
## 9 United Arab Emirates ARE 3.53 3.47 3.90 4.01 4.10 4.40
## 10 Argentina ARG 9.80 10.3 10.1 10.3 10.2 10.1
## # ℹ 255 more rows
## # ℹ 5 more variables: `2020` <dbl>, `2021` <dbl>, `2022` <dbl>, `2023` <dbl>,
## # average_health <dbl>
# Clean up data and sort countries by average healthcare expenditure from highest to lowest
health_highest <- health_10yr %>% arrange(desc(average_health))
health_highest
## # A tibble: 265 × 13
## `Country Name` `Country Code` `2014` `2015` `2016` `2017` `2018` `2019`
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Tuvalu TUV 14.5 13.4 18.3 24.5 18.4 22.2
## 2 United States USA 16.1 16.4 16.7 16.6 16.5 16.5
## 3 North America NAC 15.6 16.0 16.3 16.2 16.1 16.1
## 4 Afghanistan AFG 9.53 10.1 11.8 12.6 14.2 14.8
## 5 Marshall Islands MHL 12.0 14.8 14.6 12.0 14.5 15.0
## 6 Post-demographic di… PST 12.3 12.6 12.8 12.7 12.7 12.9
## 7 Naoero NRU 8.12 13.9 11.0 11.5 11.1 11.6
## 8 OECD members OED 11.8 12.2 12.3 12.3 12.2 12.4
## 9 High income HIC 11.5 12.0 12.1 12.1 12.0 12.2
## 10 Micronesia, Fed. St… FSM 11.8 12.6 13.3 12.4 11.9 11.9
## # ℹ 255 more rows
## # ℹ 5 more variables: `2020` <dbl>, `2021` <dbl>, `2022` <dbl>, `2023` <dbl>,
## # average_health <dbl>
# Remove non-country categories from the data
health_countries <- health_highest %>%
filter(!`Country Code` %in% c("NAC", "PST", "OED", "HIC", "EMU", "EUU", "WLD", "PSE", "ECS"))
# Select the top 15 countries with the highest average healthcare expenditure
health_top15 <- health_countries %>% slice_max(average_health, n=15)
health_top15
## # A tibble: 15 × 13
## `Country Name` `Country Code` `2014` `2015` `2016` `2017` `2018` `2019`
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Tuvalu TUV 14.5 13.4 18.3 24.5 18.4 22.2
## 2 United States USA 16.1 16.4 16.7 16.6 16.5 16.5
## 3 Afghanistan AFG 9.53 10.1 11.8 12.6 14.2 14.8
## 4 Marshall Islands MHL 12.0 14.8 14.6 12.0 14.5 15.0
## 5 Naoero NRU 8.12 13.9 11.0 11.5 11.1 11.6
## 6 Micronesia, Fed. St… FSM 11.8 12.6 13.3 12.4 11.9 11.9
## 7 Lesotho LSO 9.99 9.25 9.20 10.5 11.1 21.9
## 8 Palau PLW 10.7 9.76 10.0 10.9 11.2 12.2
## 9 Cuba CUB 12.1 12.8 12.2 11.5 11.0 11.1
## 10 France FRA 11.6 11.5 11.6 11.4 11.3 11.2
## 11 Germany DEU 10.8 10.9 11.0 11.1 11.2 11.4
## 12 Switzerland CHE 10.7 11.0 11.2 11.4 11.2 11.4
## 13 Canada CAN 10.3 10.8 11.1 10.9 10.9 11.0
## 14 Japan JPN 10.7 10.7 10.7 10.7 10.7 11.0
## 15 Sweden SWE 11.1 10.9 11.0 10.9 11.1 10.9
## # ℹ 5 more variables: `2020` <dbl>, `2021` <dbl>, `2022` <dbl>, `2023` <dbl>,
## # average_health <dbl>
library(tidyr)
health_long <- health_top15 %>% pivot_longer(cols = `2014`:`2023`, names_to = "Year", values_to = "Health")
health_long
## # A tibble: 150 × 5
## `Country Name` `Country Code` average_health Year Health
## <chr> <chr> <dbl> <chr> <dbl>
## 1 Tuvalu TUV 19.6 2014 14.5
## 2 Tuvalu TUV 19.6 2015 13.4
## 3 Tuvalu TUV 19.6 2016 18.3
## 4 Tuvalu TUV 19.6 2017 24.5
## 5 Tuvalu TUV 19.6 2018 18.4
## 6 Tuvalu TUV 19.6 2019 22.2
## 7 Tuvalu TUV 19.6 2020 17.9
## 8 Tuvalu TUV 19.6 2021 18.6
## 9 Tuvalu TUV 19.6 2022 21.3
## 10 Tuvalu TUV 19.6 2023 27.1
## # ℹ 140 more rows
Question: Which countries had the highest average healthcare expenditure as a percentage of GDP during this period?
To answer this question, the data were grouped by country and the mean healthcare expenditure was calculated for the 2014–2023 period.
# Group by country and calculate the average healthcare expenditure
health_summary <- health_long %>% group_by(`Country Name`) %>% summarize(average_health=mean(Health, na.rm=TRUE))%>%arrange(desc(average_health))
health_summary
## # A tibble: 15 × 2
## `Country Name` average_health
## <chr> <dbl>
## 1 Tuvalu 19.6
## 2 United States 16.8
## 3 Afghanistan 14.8
## 4 Marshall Islands 13.5
## 5 Naoero 12.6
## 6 Micronesia, Fed. Sts. 12.3
## 7 Lesotho 11.9
## 8 Palau 11.8
## 9 Cuba 11.8
## 10 France 11.6
## 11 Germany 11.6
## 12 Switzerland 11.4
## 13 Canada 11.3
## 14 Japan 11.1
## 15 Sweden 11.1
# Count the number of available yearly observations for each country
health_long %>% filter(!is.na(Health)) %>% count(`Country Name`)
## # A tibble: 15 × 2
## `Country Name` n
## <chr> <int>
## 1 Afghanistan 10
## 2 Canada 10
## 3 Cuba 10
## 4 France 10
## 5 Germany 10
## 6 Japan 10
## 7 Lesotho 10
## 8 Marshall Islands 10
## 9 Micronesia, Fed. Sts. 10
## 10 Naoero 10
## 11 Palau 10
## 12 Sweden 10
## 13 Switzerland 10
## 14 Tuvalu 10
## 15 United States 10
# Create a bar chart of the 15 countries with the highest average healthcare expenditure
ggplot(health_summary, aes(x = reorder(`Country Name`, average_health),y = average_health, fill = `Country Name`)) + geom_col() +
coord_flip() + labs(
title = "15 Countries with the Highest Healthcare Expenditures",
subtitle = "Average healthcare expenditure as a percentage of GDP from 2014–2023",
x = "Country",
y = "Average Health Expenditure (% of GDP)") + theme(legend.position = "none")
Insight: Tuvalu had the highest average current healthcare expenditure as a percentage of GDP from 2014-2023 followed by the U.S. Several small Pacific island countries also ranked among the highest. However, because the measure is expressed as a percentage of GDP, a higher percentage does not necessarily mean that a country spent more on healthcare overall. This may indicate that healthcare spending represented a larger share of its economy.
Question: How did healthcare expenditure change over time among selected major economies?
For the second analysis, I selected the United States, Canada, United Kingdom, France, Germany, Italy, Japan, China, India, South Korea, and Sweden to compare healthcare expenditure trends across a group of major economies.
# Select major economies for comparison
major <- health_10yr %>% filter(`Country Code` %in% c("CAN", "FRA", "DEU", "ITA", "JPN", "GBR", "USA", "CHN", "IND", "KOR", "SWE"))
major_long <- major %>% pivot_longer(cols= `2014`:`2023`, names_to = "Year", values_to = "Health")
# Create a line graph to compare healthcare spending over time among selected nations
ggplot(major_long, aes(x = Year, y = Health, group = `Country Name`, color = `Country Name`)) + geom_line(linewidth = 0.5) + geom_point() + labs( title = "Healthcare Expenditure Among Selected Major Economies Across 10 years", subtitle = "Current health expenditure as a % of GDP from 2014–2023", x = "Year", y = "Health Expenditure (% of GDP)", color = "Country")
Insight: Healthcare expenditure as a percentage of GDP varied among the selected major economies from 2014–2023. The U.S. consistently had the highest percentage while several countries showed an increase around 2020 followed by a decline in later years.
Overall, the analysis shows substantial differences in healthcare expenditure as a share of GDP across countries. The countries with the highest average expenditure were not limited to large economies, while the selected major economies also showed different spending patterns over the 2014–2023 period. These results demonstrate how healthcare expenditure can vary both across countries and over time.