HW 4

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── 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
library(janitor)

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
library(countrycode)

imf_climate_dashboards_green_debt_url <- "https://opendata.arcgis.com/datasets/8e2772e0b65f4e33a80183ce9583d062_0.csv"

green_debt <- imf_climate_dashboards_green_debt_url |> 
  read_csv() 
Rows: 355 Columns: 42
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (12): Country, ISO2, ISO3, Indicator, Unit, Source, CTS_Code, CTS_Name, ...
dbl (30): ObjectId, F1985, F1986, F1987, F1990, F1991, F1992, F1993, F1994, ...

ℹ 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.
green_debt
# A tibble: 355 × 42
   ObjectId Country         ISO2  ISO3  Indicator Unit  Source CTS_Code CTS_Name
      <dbl> <chr>           <chr> <chr> <chr>     <chr> <chr>  <chr>    <chr>   
 1        1 Argentina       AR    ARG   Green Bo… Bill… Refin… ECFFI    Green B…
 2        2 Australia       AU    AUS   Green Bo… Bill… Refin… ECFFI    Green B…
 3        3 Austria         AT    AUT   Green Bo… Bill… Refin… ECFFI    Green B…
 4        4 Austria         AT    AUT   Sovereig… Bill… Refin… ECFF     Green B…
 5        5 Bangladesh      BD    BGD   Green Bo… Bill… Refin… ECFFI    Green B…
 6        6 Belarus, Rep. … BY    BLR   Green Bo… Bill… Refin… ECFFI    Green B…
 7        7 Belarus, Rep. … BY    BLR   Sovereig… Bill… Refin… ECFF     Green B…
 8        8 Belgium         BE    BEL   Green Bo… Bill… Refin… ECFFI    Green B…
 9        9 Belgium         BE    BEL   Sovereig… Bill… Refin… ECFF     Green B…
10       10 Bermuda         BM    BMU   Green Bo… Bill… Refin… ECFFI    Green B…
# ℹ 345 more rows
# ℹ 33 more variables: CTS_Full_Descriptor <chr>, Type_of_Issuer <chr>,
#   Use_of_Proceed <chr>, Principal_Currency <chr>, F1985 <dbl>, F1986 <dbl>,
#   F1987 <dbl>, F1990 <dbl>, F1991 <dbl>, F1992 <dbl>, F1993 <dbl>,
#   F1994 <dbl>, F1999 <dbl>, F2000 <dbl>, F2002 <dbl>, F2003 <dbl>,
#   F2004 <dbl>, F2007 <dbl>, F2008 <dbl>, F2009 <dbl>, F2010 <dbl>,
#   F2011 <dbl>, F2012 <dbl>, F2013 <dbl>, F2014 <dbl>, F2015 <dbl>, …
indicators_we_want <- c("Green Bond Issuances by Country", "Sovereign Green Bond Issuances")

green_debt_subset <- green_debt |> 
  clean_names() |> 
  filter(indicator %in% indicators_we_want) |> 
  select(country, iso3, indicator, matches("f\\d{4}")) 

green_debt_subset 
# A tibble: 107 × 32
   country iso3  indicator f1985 f1986 f1987 f1990 f1991 f1992 f1993 f1994 f1999
   <chr>   <chr> <chr>     <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1 Argent… ARG   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 2 Austra… AUS   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 3 Austria AUT   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 4 Austria AUT   Sovereig…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 5 Bangla… BGD   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 6 Belaru… BLR   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 7 Belaru… BLR   Sovereig…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 8 Belgium BEL   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
 9 Belgium BEL   Sovereig…    NA    NA    NA    NA    NA    NA    NA    NA    NA
10 Bermuda BMU   Green Bo…    NA    NA    NA    NA    NA    NA    NA    NA    NA
# ℹ 97 more rows
# ℹ 20 more variables: f2000 <dbl>, f2002 <dbl>, f2003 <dbl>, f2004 <dbl>,
#   f2007 <dbl>, f2008 <dbl>, f2009 <dbl>, f2010 <dbl>, f2011 <dbl>,
#   f2012 <dbl>, f2013 <dbl>, f2014 <dbl>, f2015 <dbl>, f2016 <dbl>,
#   f2017 <dbl>, f2018 <dbl>, f2019 <dbl>, f2020 <dbl>, f2021 <dbl>,
#   f2022 <dbl>

Question 1

green_debt_subset_tidy <- green_debt_subset %>%
mutate(region = countrycode(iso3, "iso3c", "un.region.name")) %>% 
relocate(region, .before = 1) %>% 
pivot_longer(
  cols = starts_with("f"),
  names_to = "year",
  values_to = "green_bonds_issued",
  values_drop_na = TRUE
) %>% 
  mutate(year = parse_number(year)) 
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `region = countrycode(iso3, "iso3c", "un.region.name")`.
Caused by warning:
! Some values were not matched unambiguously: TWN
total_green_debt <- green_debt_subset_tidy %>% 
group_by(region) %>% 
summarise(total_issued = sum(green_bonds_issued)) %>% 
mutate(region = fct_inorder(region))

library(ggplot2)
ggplot(total_green_debt) +
  aes(x = region, y = total_issued) +
  geom_col(fill = "#228B22") +
  labs(
    x = "Region",
    y = "Number of Green Bonds Issued",
    title = "Green Bond Issuance by Region"
  ) +
  theme_gray()

Question 2

issuer_green_debt <- green_debt %>% 
clean_names() %>% 
filter(type_of_issuer != "Not Applicable") %>% 
pivot_longer(
  cols = starts_with("f"),
  names_to = "year",
  values_to = "green_bonds_issuance",
  values_drop_na = TRUE
) %>% 
mutate(year = parse_number(year)) %>% 
group_by(type_of_issuer) %>% 
summarise(total_issuance = sum(green_bonds_issuance)) %>% 
arrange(desc(total_issuance)) %>% 
mutate(type_of_issuer = fct_inorder(type_of_issuer))

ggplot(issuer_green_debt) +
  aes(x = total_issuance, y = type_of_issuer) +
  geom_col(fill = "#228B22") +
  labs(
    x = "Total Green Bond Issuance",
    y = "Issuer Type",
    title = "Green Bond Issuer by Volume"
  ) +
  theme_gray()

Factoid: Most of the current green bonds are issued by nonfinancial corporations, followed by banks and other financial corporations. In comparison, local and state governments issued the least green bonds.

Question 3

proceed_green_debt <- green_debt %>% 
clean_names() %>% 
filter(use_of_proceed != "Not Applicable") %>% 
pivot_longer(
  cols = starts_with("f"),
  names_to = "year",
  values_to = "green_bonds_issuance",
  values_drop_na = TRUE
) %>% 
mutate(year = parse_number(year)) %>% 
group_by(use_of_proceed) %>% 
summarise(total_issuance = sum(green_bonds_issuance)) %>% 
arrange(total_issuance) %>% 
slice(1:14) %>% 
mutate(use_of_proceed = fct_inorder(use_of_proceed))

ggplot(proceed_green_debt) +
  aes(x = use_of_proceed, y = total_issuance) +
  geom_col(fill = "#228B22") +
  labs(
    x = "Total Issuance",
    y = "Use of Proceeds",
    title = "Use of Proceeds in Green Bonds"
  ) +
  coord_flip() +
  theme_gray()

Factoid: Most green bonds are used fund higher education, economic development, and sustainable economic growth, followed by uses directed to specific industries like transport and biodiversity conservation.

currency_green_debt <- green_debt %>% 
clean_names() %>% 
filter(principal_currency != "Not Applicable") %>% 
pivot_longer(
  cols = starts_with("f"),
  names_to = "year",
  values_to = "green_bonds_issuance",
  values_drop_na = TRUE
) %>% 
mutate(year = parse_number(year)) %>% 
group_by(principal_currency) %>% 
summarise(total_issuance = sum(green_bonds_issuance)) %>% 
arrange(total_issuance) %>% 
slice(1:13) %>% 
mutate(principal_currency = fct_inorder(principal_currency))

ggplot(currency_green_debt) +
  aes(
    x = principal_currency,
    fill = principal_currency,
    weight = total_issuance
  ) +
  geom_bar() +
   labs(
    x = "Principal Currency",
    y = "Total Issuance",
    title = "Currency Usage in Green Bond Issuances"
  ) +
  scale_fill_hue(direction = -1) +
  coord_flip() +
  theme_minimal()

Factoid: Nigerian Naira is the currency that issued the most green bonds, followed by Deutsche Mark and Czech Koruna. Among the top 10 currencies in the above graph, Deutsche Mark is the only currency from a developed country, indicating its effort in developing sustainable finance. It also showcases that green bonds is commonly used among developing countries with abundant natural resources to raise funds and contribute to their sustainable movements.