HW3

Homework 3 - Xiaorui Zhang

library(ggplot2)
library(ggthemes)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ lubridate 1.9.2     ✔ tibble    3.2.1
✔ purrr     1.0.2     ✔ tidyr     1.3.0
── 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(dplyr)
library(pkgdown)
library(esquisse)

Question 1

blackrock_etf_screener <- read_csv("https://raw.githubusercontent.com/t-emery/sais-susfin_data/main/datasets/ishares_etf_screener_as_of_2023-12-27.csv") 
Rows: 424 Columns: 18
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (10): ticker, name, asset_class, sub_asset_class, region, market, locat...
dbl   (6): gross_expense_ratio_percent, net_expense_ratio_percent, net_asset...
dttm  (2): incept_date, net_assets_as_of

ℹ 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.
blackrock_etf_screener
# A tibble: 424 × 18
   ticker name                        incept_date         gross_expense_ratio_…¹
   <chr>  <chr>                       <dttm>                               <dbl>
 1 IVV    iShares Core S&P 500 ETF    2000-05-15 00:00:00                   0.03
 2 IEFA   iShares Core MSCI EAFE ETF  2012-10-18 00:00:00                   0.07
 3 AGG    iShares Core U.S. Aggregat… 2003-09-22 00:00:00                   0.03
 4 IWF    iShares Russell 1000 Growt… 2000-05-22 00:00:00                   0.19
 5 IJR    iShares Core S&P Small-Cap… 2000-05-22 00:00:00                   0.06
 6 IJH    iShares Core S&P Mid-Cap E… 2000-05-22 00:00:00                   0.05
 7 IEMG   iShares Core MSCI Emerging… 2012-10-18 00:00:00                   0.09
 8 IWM    iShares Russell 2000 ETF    2000-05-22 00:00:00                   0.19
 9 IWD    iShares Russell 1000 Value… 2000-05-22 00:00:00                   0.19
10 TLT    iShares 20+ Year Treasury … 2002-07-22 00:00:00                   0.15
# ℹ 414 more rows
# ℹ abbreviated name: ¹​gross_expense_ratio_percent
# ℹ 14 more variables: net_expense_ratio_percent <dbl>, net_assets_usd <dbl>,
#   net_assets_as_of <dttm>, asset_class <chr>, sub_asset_class <chr>,
#   region <chr>, market <chr>, location <chr>, investment_style <chr>,
#   msci_esg_fund_rating_aaa_ccc <chr>, msci_esg_quality_score_0_10 <dbl>,
#   msci_weighted_average_carbon_intensity_tons_co2e_m_sales <dbl>, …
glimpse(blackrock_etf_screener)
Rows: 424
Columns: 18
$ ticker                                                   <chr> "IVV", "IEFA"…
$ name                                                     <chr> "iShares Core…
$ incept_date                                              <dttm> 2000-05-15, …
$ gross_expense_ratio_percent                              <dbl> 0.03, 0.07, 0…
$ net_expense_ratio_percent                                <dbl> 0.03, 0.07, 0…
$ net_assets_usd                                           <dbl> 399312542067,…
$ net_assets_as_of                                         <dttm> 2023-12-27, …
$ asset_class                                              <chr> "Equity", "Eq…
$ sub_asset_class                                          <chr> "Large Cap", …
$ region                                                   <chr> "North Americ…
$ market                                                   <chr> "Developed", …
$ location                                                 <chr> "United State…
$ investment_style                                         <chr> "Index", "Ind…
$ msci_esg_fund_rating_aaa_ccc                             <chr> "A", "AA", "A…
$ msci_esg_quality_score_0_10                              <dbl> 6.6845, 7.519…
$ msci_weighted_average_carbon_intensity_tons_co2e_m_sales <dbl> 106.80, 102.8…
$ msci_esg_percent_coverage                                <dbl> 99.05, 99.80,…
$ sustainable_classification                               <chr> NA, NA, NA, N…
#only contains ESG funds (no standard funds
blackrock_etf_screener_w_ESG <- blackrock_etf_screener |> mutate(
    standard_or_esg = if_else(
      condition = is.na(sustainable_classification),
      true = "Standard",
      false = "ESG"))
ESG_funds <- blackrock_etf_screener_w_ESG %>%
  filter(standard_or_esg == "ESG") %>%
  as_tibble()

#contains the largest fund from each sustainable classification.
largest_funds_by_classification <- blackrock_etf_screener %>%
  group_by(sustainable_classification) %>%
  arrange(desc(net_assets_usd), .by_group = TRUE) %>%
  slice(1) %>%
  ungroup() %>%
  as_tibble()

#shows the percent of assets that the top fund comprises for its category
assets_funds_by_classification <- blackrock_etf_screener |>
  group_by(sustainable_classification) |> 
  summarize(
    assets_total = sum(net_assets_usd, na.rm = TRUE)
    )

assets_top_fund <- assets_funds_by_classification %>%
  inner_join(largest_funds_by_classification, by = "sustainable_classification") 

percent_assets_top_fund <- assets_top_fund %>%
  mutate(percent_of_assets = (net_assets_usd / assets_total) * 100) %>%
  select(sustainable_classification, percent_of_assets)

#Ranks each sustainable classification by the % of assets
ranked_classifications <- percent_assets_top_fund %>%
  arrange(desc(percent_of_assets)) 

Question 2

top_10_smallest_etfs <- blackrock_etf_screener %>%
  arrange(net_assets_usd) %>%
  top_n(-10) %>%
  mutate(name = fct_reorder(name, net_assets_usd))
Selecting by sustainable_classification

Question 3

bottom_quintile <- quantile(blackrock_etf_screener$msci_esg_quality_score_0_10, 0.2, na.rm = TRUE)

bottom_quintile_funds <- blackrock_etf_screener %>%
  filter(msci_esg_quality_score_0_10 <= bottom_quintile)

summary_by_asset_class <- bottom_quintile_funds %>%
  group_by(asset_class) %>%
  summarize(
    number_of_funds = n(),
    total_assets = sum(net_assets_usd)
  )

summary_by_sub_asset_class <- bottom_quintile_funds %>%
  group_by(market) %>%
  summarize(
    number_of_funds = n(),
    total_assets = sum(net_assets_usd)
  )

Question 4

#The Ranking of Regions by Total Net Assets for ETF
blackrock_etf_screener |>
  group_by(region) |>
  summarise(total_net_assets_usd = sum(net_assets_usd, na.rm = TRUE)) |>
  arrange(desc(total_net_assets_usd))
# A tibble: 7 × 2
  region                 total_net_assets_usd
  <chr>                                 <dbl>
1 North America                       1.98e12
2 Global                              5.32e11
3 Asia Pacific                        5.36e10
4 Europe                              2.34e10
5 Latin America                       1.10e10
6 Middle East and Africa              1.22e 9
7 Kuwait                              5.68e 7
#Because I'm interested in the current state of ETFs and ESG ETFs, I'll start by examining the size of ETFs by region.
#The results show that North America has the largest amount of ETF assets, which is consistent with the impression that North America has highly developed financial markets

#Visualize each region's ESG ETF and Standard ETF
funds_by_region <- blackrock_etf_screener_w_ESG %>%
  group_by(region)

funds_by_region |> 
  ggplot(aes(x = region, y = net_assets_usd, fill = standard_or_esg)) +
  geom_bar(stat = "identity", position = "stack")

#In order to further visualize the results above and examine the prospects for sustainable finance, we have categorized the regions by ESG and standard ETFs in a bar chart. North America has the largest total amount of ESG ETFs, but nonetheless, we can see that the development of ESG ETFs globally is still in its beginning stages, and their numbers in each region are very small compared to standard ETFs.

#Which sub asset class is leading ESG ETFs in North America?
NA_funds <- blackrock_etf_screener_w_ESG %>%
  filter(region == "North America" & standard_or_esg == "ESG" ) %>%
  as_tibble()

NA_funds_by_sub_class <- NA_funds |>
  group_by(sub_asset_class) |> 
  summarize(
    assets_total = sum(net_assets_usd, na.rm = TRUE)
    )

ranked_sub_class <- NA_funds_by_sub_class %>%
  arrange(desc(assets_total)) 
#Large/Mid Cap

#What about North Ameirca ESG ETF's quality (its rating)?
summary_by_rating <- NA_funds %>%
  group_by(msci_esg_fund_rating_aaa_ccc) %>%
  summarize(
    number_of_funds = n()
  )
#50% of them are A class.

#Comparison of ESG ETF Development quality in NA and Global
NA_G_funds <- blackrock_etf_screener_w_ESG %>%
  filter(region %in% c("North America", "Global") & standard_or_esg == "ESG" ) %>%
  as_tibble()

NA_G_funds |> 
  ggplot(aes(x = region, y = net_assets_usd, fill = msci_esg_fund_rating_aaa_ccc)) +
  geom_bar(stat = "identity", position = "stack")

ESG_funds <- blackrock_etf_screener_w_ESG %>%
  filter(standard_or_esg == "ESG" ) %>%
  as_tibble()

ESG_funds |> 
  ggplot(aes(x = region, y = net_assets_usd, fill = msci_esg_fund_rating_aaa_ccc)) +
  geom_bar(stat = "identity", position = "stack")

#Most of ESG ETF are AA and A.