Credit-to-GDP gaps - CREDIT_GAP

Data - BIS

iso3c, iso2c, Borrowers’ country

Code
CREDIT_GAP %>%
  arrange(iso3c, date) %>%
  group_by(iso3c, iso2c, `Borrowers' country`) %>%
  summarise(Nobs = n(),
            start = first(date),
            end = last(date)) %>%
  arrange(-Nobs) %>%
  mutate(Flag = gsub(" ", "-", str_to_lower(`Borrowers' country`)),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) %>%
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

FREQ, Frequency

Code
CREDIT_GAP %>%
  group_by(FREQ, Frequency) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
FREQ Frequency Nobs
Q Quarterly 24488

CG_DTYPE, Credit gap data type

Code
CREDIT_GAP %>%
  group_by(CG_DTYPE, `Credit gap data type`) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
CG_DTYPE Credit gap data type Nobs
A Credit-to-GDP ratios (actual data) 9336
B Credit-to-GDP trend (HP filter) 7576
C Credit-to-GDP gaps (actual-trend) 7576

TC_LENDERS, Lending sector

Code
CREDIT_GAP %>%
  group_by(TC_LENDERS, `Lending sector`) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
TC_LENDERS Lending sector Nobs
A All sectors 24488

TC_BORROWERS, Borrowing sector

Code
CREDIT_GAP %>%
  group_by(TC_BORROWERS, `Borrowing sector`) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
TC_BORROWERS Borrowing sector Nobs
P Private non-financial sector 24488

TC_LENDERS, Lending sector

Code
CREDIT_GAP %>%
  group_by(TC_LENDERS, `Lending sector`) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  print_table_conditional()
TC_LENDERS Lending sector Nobs
A All sectors 24488

date

Code
CREDIT_GAP %>%
  group_by(date) %>%
  summarise(Nobs = n()) %>%
  arrange(desc(date)) %>%
  print_table_conditional()

Spain, Italy, United States

Credit to GDP Ratio

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "A",
         iso3c %in% c("ESP", "USA", "ITA")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  scale_x_date(breaks = seq(1920, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-60, 300, 20),
                     labels = scales::percent_format(accuracy = 1))

Credit to GDP Gaps

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "C",
         iso3c %in% c("ESP", "USA", "ITA")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  scale_x_date(breaks = seq(1920, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-60, 300, 20),
                     labels = scales::percent_format(accuracy = 1))

Denmark, Netherlands, Germany

Credit to GDP Ratio

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "A",
         iso3c %in% c("DNK", "NLD", "DEU")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  scale_x_date(breaks = seq(1920, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-60, 300, 20),
                     labels = scales::percent_format(accuracy = 1))

Credit to GDP Gaps

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "C",
         iso3c %in% c("DNK", "NLD", "DEU")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  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(-60, 300, 10),
                     labels = scales::percent_format(accuracy = 1))

Spain, Ireland, Portugal

Credit to GDP Ratio

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "A",
         iso3c %in% c("IRL", "ESP", "PRT")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  scale_x_date(breaks = seq(1920, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-60, 600, 20),
                     labels = scales::percent_format(accuracy = 1))

Credit to GDP Gaps

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "C",
         iso3c %in% c("IRL", "ESP", "PRT")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  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(-300, 300, 10),
                     labels = scales::percent_format(accuracy = 1))

France, Spain, Italy

Credit to GDP Ratio

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "A",
         iso3c %in% c("FRA", "ESP", "ITA")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  scale_x_date(breaks = seq(1920, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  theme(legend.position = c(0.2, 0.85),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = 0.01*seq(-60, 300, 20),
                     labels = scales::percent_format(accuracy = 1))

Credit to GDP Gaps

Code
CREDIT_GAP %>%
  filter(CG_DTYPE == "C",
         iso3c %in% c("FRA", "ESP", "ITA")) %>%
  left_join(colors, by = c("Borrowers' country" = "country")) %>%
  ggplot() + theme_minimal() + ylab("Credit-to-GDP ratio") + xlab("") +
  geom_line(aes(x = date, y = value/100, color = color)) +
  scale_color_identity() + add_flags +
  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(-300, 300, 10),
                     labels = scales::percent_format(accuracy = 1))