Social Expenditure - Aggregated data - SOCX_AGG

Data - OECD

Info

Last observation: A: 2022 (N = 27)

First observation: A: 1980 (N = 15915)

Last data update: 02 aoû 2026, 09:13. Last compile: 18 aoû 2026, 03:19

Structure

Number of Observations

Code
SOCX_AGG |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  group_by(BRANCH, Branch, TYPEXP, Typexp, SOURCE, TYPROG, UNIT) |>
  summarise(Nobs = n()) |>
  arrange(-Nobs) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

obsTime

Code
SOCX_AGG |>
  group_by(obsTime) |>
  summarise(Nobs = n()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Social aggregate, Public

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH %in% c(90, 1), 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  group_by(COUNTRY, Country, Branch) |>
  arrange(obsTime) |>
  summarise(obsTime = last(obsTime),
            obsValue = last(obsValue)) |>
  select(-obsTime) |>
  arrange(-obsValue)  |>
  spread(Branch, obsValue) |>
  mutate(`Total - Old age` = Total - `Old age`) |>
  arrange(-`Total - Old age`)
# # A tibble: 39 × 5
# # Groups:   COUNTRY, Country [39]
#    COUNTRY Country `Old age` Total `Total - Old age`
#    <chr>   <chr>       <dbl> <dbl>             <dbl>
#  1 CAN     Canada       4.94  24.9              20.0
#  2 BEL     Belgium     10.2   29.0              18.8
#  3 ESP     Spain        9.58  28.1              18.5
#  4 FRA     France      13.3   31.6              18.3
#  5 DEU     Germany      8.68  26.7              18.0
#  6 ISL     Iceland      3.24  20.8              17.5
#  7 AUT     Austria     12.1   29.4              17.2
#  8 CHL     Chile        2.65  19.6              17.0
#  9 ITA     Italy       13.4   30.1              16.6
# 10 FIN     Finland     12.7   29.0              16.3
# # ℹ 29 more rows

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH %in% c("90",  "1_2"), 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  group_by(COUNTRY, Country, Branch) |>
  arrange(obsTime) |>
  summarise(obsTime = last(obsTime),
            obsValue = last(obsValue)) |>
  select(-obsTime) |>
  arrange(-obsValue)  |>
  spread(Branch, obsValue) |>
  mutate(`Total - Old age and Survivors` = Total - `Old age and Survivors`) |>
  arrange(-`Total - Old age and Survivors`)
# # A tibble: 39 × 5
# # Groups:   COUNTRY, Country [39]
#    COUNTRY Country        `Old age and Survivors` Total Total - Old age and Su…¹
#    <chr>   <chr>                            <dbl> <dbl>                    <dbl>
#  1 CAN     Canada                            5.27  24.9                     19.6
#  2 ISL     Iceland                           3.26  20.8                     17.5
#  3 BEL     Belgium                          11.8   29.0                     17.2
#  4 FRA     France                           14.9   31.6                     16.7
#  5 CHL     Chile                             3.13  19.6                     16.5
#  6 DEU     Germany                          10.4   26.7                     16.3
#  7 ESP     Spain                            11.9   28.1                     16.2
#  8 GBR     United Kingdom                    5.92  22.1                     16.2
#  9 DNK     Denmark                          10.1   26.2                     16.0
# 10 NZL     New Zealand                       5.16  20.8                     15.7
# # ℹ 29 more rows
# # ℹ abbreviated name: ¹​`Total - Old age and Survivors`
Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         UNIT == "PCT_GDP",
         obsTime == "2019") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  spread(Branch, obsValue) |>
  mutate(`Total - Old age` = Total - `Old age`) |>
  arrange(-`Total - Old age`)
# # A tibble: 429 × 25
#    SOURCE BRANCH TYPEXP TYPROG UNIT    COUNTRY TIME_FORMAT UNIT.1  POWERCODE
#    <chr>  <chr>  <chr>  <chr>  <chr>   <chr>   <chr>       <chr>   <chr>    
#  1 10     1      0      0      PCT_GDP AUS     P1Y         PCT_GDP 0        
#  2 10     1      0      0      PCT_GDP AUT     P1Y         PCT_GDP 0        
#  3 10     1      0      0      PCT_GDP BEL     P1Y         PCT_GDP 0        
#  4 10     1      0      0      PCT_GDP CAN     P1Y         PCT_GDP 0        
#  5 10     1      0      0      PCT_GDP CHE     P1Y         PCT_GDP 0        
#  6 10     1      0      0      PCT_GDP CHL     P1Y         PCT_GDP 0        
#  7 10     1      0      0      PCT_GDP COL     P1Y         PCT_GDP 0        
#  8 10     1      0      0      PCT_GDP CRI     P1Y         PCT_GDP 0        
#  9 10     1      0      0      PCT_GDP CZE     P1Y         PCT_GDP 0        
# 10 10     1      0      0      PCT_GDP DEU     P1Y         PCT_GDP 0        
# # ℹ 419 more rows
# # ℹ 16 more variables: REFERENCEPERIOD <chr>, obsTime <chr>, OBS_STATUS <chr>,
# #   Country <chr>, `Active labour market programmes` <dbl>, Family <dbl>,
# #   Health <dbl>, Housing <dbl>, `Incapacity related` <dbl>, `Old age` <dbl>,
# #   `Old age and Survivors` <dbl>, `Other social policy areas` <dbl>,
# #   Survivors <dbl>, Total <dbl>, Unemployment <dbl>, `Total - Old age` <dbl>

All

Cash

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         COUNTRY %in% c("USA", "FRA", "DEU", "GBR"),
         UNIT == "PCT_GDP",
         obsTime == "2015") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  select(BRANCH, Branch, COUNTRY, obsValue) |>
  spread(COUNTRY, obsValue) %>%
  mutate_at(vars(-BRANCH, -Branch), funs(round(., digits = 1))) -> SOC_AGG_TYPEXP_1

do.call(save, list("SOC_AGG_TYPEXP_1", file = "SOC_AGG_TYPEXP_1.RData"))

SOC_AGG_TYPEXP_1 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

In-kind

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 2, 
         COUNTRY %in% c("USA", "FRA", "DEU", "GBR"),
         UNIT == "PCT_GDP",
         obsTime == "2015") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  select(BRANCH, Branch, COUNTRY, obsValue) |>
  spread(COUNTRY, obsValue) %>%
  mutate_at(vars(-BRANCH, -Branch), funs(round(., digits = 1))) -> SOC_AGG_TYPEXP_2

do.call(save, list("SOC_AGG_TYPEXP_2", file = "SOC_AGG_TYPEXP_2.RData"))

SOC_AGG_TYPEXP_2 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Total

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         COUNTRY %in% c("USA", "FRA", "DEU", "GBR"),
         UNIT == "PCT_GDP",
         obsTime == "2015") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  select(BRANCH, Branch, COUNTRY, obsValue) |>
  spread(COUNTRY, obsValue) %>%
  mutate_at(vars(-BRANCH, -Branch), funs(round(., digits = 1))) -> SOC_AGG_TYPEXP_0

do.call(save, list("SOC_AGG_TYPEXP_0", file = "SOC_AGG_TYPEXP_0.RData"))

SOC_AGG_TYPEXP_0 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Total - Cash benefits (Branch 90)

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_enddate() |>
  mutate(year = year(date)) |>
  filter(year %in% c(1990, 2000, 2015)) |>
  arrange(Country, year) |>
  group_by(Country) |>
  summarise(`1990 (% GDP)` = obsValue[1],
            `2000 (% GDP)` = obsValue[2],
            `2015 (% GDP)` = obsValue[3],
            `Delta 2000-15` = obsValue[3] - obsValue[2]) |>
  arrange(-`2015 (% GDP)`) %>%
  mutate_at(vars(-Country), funs(round(., digits = 1))) -> SOC_AGG_BRANCH_90

# do.call(save, list("SOC_AGG_BRANCH_90", file = "SOC_AGG_BRANCH_90.RData"))

SOC_AGG_BRANCH_90 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

United States, United Kingdom, Australia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("USA", "GBR", "AUS")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Total - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.8, 0.15),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 30, 1),
                     labels = scales::percent_format(accuracy = 1))

France, Germany, Netherlands

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Total - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.15),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 30, 1),
                     labels = scales::percent_format(accuracy = 1))

Chile, Denmark, Sweden

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("DNK", "SWE", "CHL")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Total - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.7, 0.85),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 30, 1),
                     labels = scales::percent_format(accuracy = 1))

Switzerland, Canada, Sloveinia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("CHE", "CAN", "SVN")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Total - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.8, 0.25),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 30, 1),
                     labels = scales::percent_format(accuracy = 1))

Austria, Belgium, Italy

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("BEL", "AUT", "ITA")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Total - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.8, 0.25),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 30, 1),
                     labels = scales::percent_format(accuracy = 1))

Old age - Cash benefits (Branch 1)

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_enddate() |>
  mutate(year = year(date)) |>
  filter(year %in% c(1990, 2000, 2015)) |>
  arrange(Country, year) |>
  group_by(Country, COUNTRY) |>
  summarise(`1990 (% GDP)` = obsValue[1],
            `2000 (% GDP)` = obsValue[2],
            `2015 (% GDP)` = obsValue[3],
            `Delta 2000-15` = obsValue[3] - obsValue[2]) |>
  arrange(-`2015 (% GDP)`) %>%
  mutate_at(vars(-Country, -COUNTRY), funs(round(., digits = 1))) |>
  rename(`Country Name` = Country, 
         `Country Code` = COUNTRY) -> SOC_AGG_BRANCH_1

do.call(save, list("SOC_AGG_BRANCH_1", file = "SOC_AGG_BRANCH_1.RData"))

SOC_AGG_BRANCH_1 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Retirement

2015

Code
SOCX_AGG |>
  filter(TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         obsTime == "2014") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$SOURCE, by = "SOURCE") |>
  select(Source, COUNTRY, Country, obsValue) |>
  spread(Source, obsValue) |>
  arrange(-`Public`) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

2017

Code
SOCX_AGG |>
  filter(TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         obsTime == "2017") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$SOURCE, by = "SOURCE") |>
  select(Source, COUNTRY, Country, obsValue) |>
  spread(Source, obsValue) |>
  arrange(-`Public`) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

United States, United Kingdom, Australia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("USA", "GBR", "AUS")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Old age - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.35, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

France, Germany, Netherlands

English

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Old age - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 1),
                     labels = scales::percent_format(accuracy = 0.1))

French

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  mutate(Country = case_when(COUNTRY == "FRA" ~ "France",
                             COUNTRY == "DEU" ~ "Allemagne",
                             COUNTRY == "NLD" ~ "Pays-Bas")) |>
  year_to_enddate() |>
  ggplot() + theme_minimal() + ylab("Retraites - Dépenses Monétaires (% of PIB)") + xlab("") +
  geom_line(aes(x = date, y = obsValue / 100, color = Country, linetype = Country)) +
  scale_color_manual(values = viridis(4)[1:3]) +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 1),
                     labels = scales::percent_format(accuracy = 1))

Chile, Denmark, Sweden

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("DNK", "SWE", "CHL")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Old age - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.2),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Switzerland, Canada, Sloveinia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("CHE", "CAN", "SVN")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Old age - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 1),
                     labels = scales::percent_format(accuracy = 0.1))

Austria, Belgium, Italy

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("BEL", "AUT", "ITA")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Old age - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 1),
                     labels = scales::percent_format(accuracy = 0.1))

Survivors - Cash benefits (Branch 2)

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 2, 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_enddate() |>
  mutate(year = year(date)) |>
  filter(year %in% c(1990, 2000, 2015)) |>
  arrange(Country, year) |>
  group_by(Country, COUNTRY) |>
  summarise(`1990 (% GDP)` = obsValue[1],
            `2000 (% GDP)` = obsValue[2],
            `2015 (% GDP)` = obsValue[3],
            `Delta 2000-15` = obsValue[3] - obsValue[2]) |>
  arrange(-`2015 (% GDP)`) %>%
  mutate_at(vars(-Country, -COUNTRY), funs(round(., digits = 1))) |>
  rename(`Country Name` = Country, 
         `Country Code` = COUNTRY) -> SOC_AGG_BRANCH_2

# do.call(save, list("SOC_AGG_BRANCH_2", file = "SOC_AGG_BRANCH_2.RData"))

SOC_AGG_BRANCH_2 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

United States, United Kingdom, Australia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 2, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("USA", "GBR", "AUS")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Survivors - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.65, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

France, Germany, Netherlands

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 2, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Survivors - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Chile, Denmark, Sweden

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 2, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("DNK", "SWE", "CHL")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Survivors - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.2),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Switzerland, Canada, Sloveinia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 2, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("CHE", "CAN", "SVN")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Survivors - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 1),
                     labels = scales::percent_format(accuracy = 0.1))

Austria, Belgium, Italy

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 2, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("BEL", "AUT", "ITA")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Survivors - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.35, 0.25),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Health - Total (Branch 7)

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_enddate() |>
  mutate(year = year(date)) |>
  filter(year %in% c(1990, 2000, 2015)) |>
  arrange(Country, year) |>
  group_by(Country, COUNTRY) |>
  summarise(`1990 (% GDP)` = obsValue[1],
            `2000 (% GDP)` = obsValue[2],
            `2015 (% GDP)` = obsValue[3],
            `Delta 2000-15` = obsValue[3] - obsValue[2]) |>
  arrange(-`2015 (% GDP)`) %>%
  mutate_at(vars(-Country, -COUNTRY), funs(round(., digits = 1))) |>
  rename(`Country Name` = Country, 
         `Country Code` = COUNTRY) -> SOC_AGG_BRANCH_4

# do.call(save, list("SOC_AGG_BRANCH_4", file = "SOC_AGG_BRANCH_4.RData"))

SOC_AGG_BRANCH_4 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

United States, United Kingdom, Australia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("USA", "GBR", "AUS")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Health (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

France, Germany, Netherlands

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Health (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Chile, Denmark, Sweden

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("DNK", "SWE", "CHL")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Health (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.2),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Switzerland, Canada, Slovenia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("CHE", "CAN", "SVN")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Health (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.1, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Austria, Belgium, Italy

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("BEL", "AUT", "ITA")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Health (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Unemployment - Cash Benefits (Branch 7)

World

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 7, 
         UNIT == "PCT_GDP") |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_enddate() |>
  mutate(year = year(date)) |>
  filter(year %in% c(1990, 2000, 2015)) |>
  arrange(Country, year) |>
  group_by(Country, COUNTRY) |>
  summarise(`1990 (% GDP)` = obsValue[1],
            `2000 (% GDP)` = obsValue[2],
            `2015 (% GDP)` = obsValue[3],
            `Delta 2000-15` = obsValue[3] - obsValue[2]) |>
  arrange(-`2015 (% GDP)`) %>%
  mutate_at(vars(-Country, -COUNTRY), funs(round(., digits = 1))) |>
  rename(`Country Name` = Country, 
         `Country Code` = COUNTRY) -> SOC_AGG_BRANCH_7

do.call(save, list("SOC_AGG_BRANCH_7", file = "SOC_AGG_BRANCH_7.RData"))

SOC_AGG_BRANCH_7 %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

France, Germany, Netherlands

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 7, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Unemployment - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Chile, Denmark, Sweden

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 7, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("DNK", "SWE", "CHL")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Unemployment - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.2),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Switzerland, Canada, Sloveinia

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 7, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("CHE", "CAN", "SVN")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Unemployment - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.75, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1))

Austria, Belgium, Italy

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 7, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("BEL", "AUT", "ITA")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  year_to_date() |>
  rename(Location = Country) |>
  left_join(colors, by = c("Location" = "country")) |>
  mutate(obsValue = obsValue / 100) |>
  ggplot() + theme_minimal() + ylab("Unemployment - Cash Benefits (% of GDP)") + xlab("") +
  geom_line(aes(x = date, y = obsValue, color = color)) +
  scale_color_identity() + add_3flags +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 1),
                     labels = scales::percent_format(accuracy = 0.1))

France and Germany

Total - Old Age

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Old age - Cash benefits

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.8),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Total - Cash Benefits

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 90, 
         UNIT == "PCT_GDP", 
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.7),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 26, 0.5),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Health - Total

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 4, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 26, 0.5),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Family - Total

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 5, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.15, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 26, 0.2),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Housing - Total

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 0, 
         BRANCH == 8, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.5),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 26, 0.1),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

10-112

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 112, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  arrange(Country) |>
  select(Country, date, value) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Country)) +
  scale_color_manual(values = viridis(3)[1:2]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.4),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 2, 0.1),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Old age - Cash benefits

France, Germany, Netherlands

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("FRA", "DEU", "NLD")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1990) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(4)[1:3]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")

Belgium, Austria, Italy

Code
SOCX_AGG |>
  filter(SOURCE == 10, 
         TYPROG == 0, 
         TYPEXP == 1, 
         BRANCH == 1, 
         UNIT == "PCT_GDP",
         COUNTRY %in% c("BEL", "AUT", "ITA")) |>
  left_join(SOCX_AGG_var$COUNTRY, by = "COUNTRY") |>
  left_join(SOCX_AGG_var$BRANCH, by = "BRANCH") |>
  left_join(SOCX_AGG_var$TYPEXP, by = "TYPEXP") |>
  mutate(date = paste0(obsTime, "-01-01") |> as.Date(),
         value = obsValue / 100) |>
  filter(year(date) >= 1980) |>
  arrange(Country) |>
  select(Branch, Country, Typexp, date, value) |>
  mutate(Variable = paste0(Branch, " - ", Typexp, " (", Country, ")")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  scale_color_manual(values = viridis(4)[1:3]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.25, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-7, 16, 0.5),
                     labels = scales::percent_format(accuracy = 0.1)) +
  ylab("% of GDP") + xlab("")