Sustainable Finance HW#3 Josie Zhou

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(dplyr)
library(ggplot2)
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>, …

Question 1

blackrock_etf_screener %>%
  mutate(total_assets = sum(net_assets_usd)) %>%
  #only contains ESG funds (no standard funds)
  filter(sustainable_classification %in% c("Thematic", "Uplift", "Impact", "Screened")) %>% 
  
  #contains the largest fund from each sustainable classification.
  group_by(sustainable_classification) %>%
  arrange(desc(net_assets_usd), .by_group = TRUE) %>%
  slice(1) %>% 

  #shows the percent of assets that the top fund comprises for its category
  mutate(percent_of_total_assets = (net_assets_usd / total_assets) * 100) %>% 

  #Ranks each sustainable classification by the % of assets in its largest fund, and arranges them in descending order.
  arrange(desc(percent_of_total_assets))
# A tibble: 4 × 20
# Groups:   sustainable_classification [4]
  ticker name  incept_date         gross_expense_ratio_…¹ net_expense_ratio_pe…²
  <chr>  <chr> <dttm>                               <dbl>                  <dbl>
1 ESGU   iSha… 2016-12-01 00:00:00                   0.15                   0.15
2 ICLN   iSha… 2008-06-24 00:00:00                   0.41                   0.41
3 BGRN   iSha… 2018-11-13 00:00:00                   0.2                    0.2 
4 XVV    iSha… 2020-09-22 00:00:00                   0.08                   0.08
# ℹ abbreviated names: ¹​gross_expense_ratio_percent, ²​net_expense_ratio_percent
# ℹ 15 more variables: 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>,
#   msci_esg_percent_coverage <dbl>, sustainable_classification <chr>, …

Question 2

Min10ETF <- blackrock_etf_screener %>% 
  arrange(net_assets_usd) %>% 
  head(10)

ggplot(Min10ETF, aes(x = fct_reorder(ticker, net_assets_usd), y = net_assets_usd)) +
  geom_bar(width = 0.5, stat = "identity") + 
  labs(title = "Top 10 Smallest ETFs by Net Assets",
       x = "ETF Ticker",
       y = "Net Assets (in USD)") 

Question 3

bottom_quintile_threshold <- quantile(blackrock_etf_screener$msci_esg_quality_score_0_10, 
                                      probs = 0.20, 
                                      na.rm = TRUE)
bottom_quintile <- blackrock_etf_screener |>
  filter(msci_esg_quality_score_0_10 <= bottom_quintile_threshold) 
bottom_quintile |>
  group_by(asset_class)|>
  summarize(countInAssetClass = n())
# A tibble: 3 × 2
  asset_class  countInAssetClass
  <chr>                    <int>
1 Equity                      51
2 Fixed Income                21
3 Real Estate                  4
bottom_quintile |>
  group_by(sub_asset_class)|>
  summarize(countInAssetClass = n())
# A tibble: 9 × 2
  sub_asset_class        countInAssetClass
  <chr>                              <int>
1 All Cap                               23
2 Corporates                             1
3 Credit                                 1
4 Government                             3
5 High Yield                            16
6 Large Cap                              1
7 Large/Mid Cap                         10
8 Real Estate Securities                 4
9 Small Cap                             17

Question 4

Visualization 1

ggplot(blackrock_etf_screener) +
  aes(
    x = asset_class,
    fill = sustainable_classification,
    colour = msci_weighted_average_carbon_intensity_tons_co2e_m_sales
  ) +
  geom_bar() +
  scale_fill_hue(direction = 1) +
  scale_color_gradient() +
  labs(
    x = "Asset Class",
    y = "Weighted Carbon Intensity (Tons))",
    title = "Weighted Carbon Intensity by Asset Classes and Sustainable Classification",
    fill = "Sustainable Classification"
  ) +
  theme_minimal()
Warning: The following aesthetics were dropped during statistical transformation: colour
ℹ This can happen when ggplot fails to infer the correct grouping structure in
  the data.
ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
  variable into a factor?

Among all asset classes, equity is the category that has the highest weighted carbon intensity, covering both ESG funds and Non-ESG funds.

Visualization 2

ggplot(blackrock_etf_screener) +
  aes(
    x = market,
    fill = sustainable_classification,
    colour = msci_esg_quality_score_0_10
  ) +
  geom_bar() +
  scale_fill_hue(direction = 1) +
  scale_color_gradient() +
  labs(
    x = "Market",
    y = "Number of Funds",
    title = "Market Distribution of Blackrock Funds",
    fill = "Sustainable Classification"
  ) +
  theme_minimal()
Warning: The following aesthetics were dropped during statistical transformation: colour
ℹ This can happen when ggplot fails to infer the correct grouping structure in
  the data.
ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
  variable into a factor?

Most of the funds at Blackrock focus on developed market. Most of the ESG funds are also in developed market, with a small proportion distributed in emerging market.

Visualization 3

ggplot(blackrock_etf_screener) +
  aes(
    x = msci_esg_quality_score_0_10,
    y = sustainable_classification
  ) +
  geom_boxplot(fill = "#228B22") +
  labs(
    x = "MSCI ESG Quality Score (1-10)",
    y = "Sustainable Classification",
    title = "Boxplot for ESG Quality Score Distribution"
  ) +
  theme_minimal()
Warning: Removed 44 rows containing non-finite values (`stat_boxplot()`).

The boxplot for sustainable classification and ESG quality scores shows that there is not a directly observable pattern in their correlation. Non-ESG funds have a wider spand probably due to its larger sample.

Visualization 4

ggplot(blackrock_etf_screener) +
  aes(
    x = msci_esg_fund_rating_aaa_ccc,
    y = msci_esg_quality_score_0_10,
    colour = msci_esg_quality_score_0_10
  ) +
  geom_jitter(size = 1.5) +
  scale_color_gradient() +
  labs(
    x = "MSCI ESG Fund Rating (AAA-CCC))",
    y = "MSCI ESG Quality Score (0-10)",
    title = "Relationship between Fund rating and ESG Score"
  ) +
  theme_minimal()
Warning: Removed 44 rows containing missing values (`geom_point()`).

The above graph shows the relationship between MSCI fund rating and MSCI ESG quality score. It can be observed that funds with higher ESG quality scores tend to also have a higher credit rating. These two metrics are somewhat correlated and can be further studied.

Visualization 5

blackrock_etf_screener_new <- blackrock_etf_screener |>
  mutate(
    standard_or_esg = if_else(
      condition = is.na(sustainable_classification),
      true = "Standard",
      false = "ESG" ),
    net_assets_bn_usd = net_assets_usd/10^9)

  ggplot(blackrock_etf_screener_new) +
  aes(
    x = incept_date,
    y = net_assets_bn_usd,
    colour = standard_or_esg,
    size = net_assets_bn_usd
  ) +
  geom_point(shape = "bullet") +
  geom_smooth(span = 0.45) +
  scale_color_brewer(palette = "Spectral", direction = -1) +
  scale_y_continuous(trans = "log10") +
  labs(
    x = "Year",
    y = "Net Assets",
    title = "Net Assets Trend in Different Markets"
  ) +
  ggthemes::theme_tufte() +
  facet_wrap(vars(market), scales = "free")
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Warning: The following aesthetics were dropped during statistical transformation: size
ℹ This can happen when ggplot fails to infer the correct grouping structure in
  the data.
ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
  variable into a factor?
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: span too small.  fewer data values than degrees of freedom.
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: at 1.466e+09
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: radius 1.133e+12
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: all data on boundary of neighborhood. make span bigger
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: pseudoinverse used at 1.466e+09
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: neighborhood radius 1.0644e+06
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: reciprocal condition number 1
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: at 1.681e+09
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: radius 1.133e+12
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: all data on boundary of neighborhood. make span bigger
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: There are other near singularities as well. 1.133e+12
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: zero-width neighborhood. make span bigger

Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: zero-width neighborhood. make span bigger

Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: zero-width neighborhood. make span bigger

Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: zero-width neighborhood. make span bigger
Warning: Computation failed in `stat_smooth()`
Caused by error in `predLoess()`:
! NA/NaN/Inf in foreign function call (arg 5)

This graph illustrates the trend of net assets included in ESG portfolio and Standard portfolio at Blackrock from 2000 to 2020. The distribution among different market indicates that Blackrock’s investment is skewed toward developed market. Also, the net asset pattern over the years shows that investment peaked at around 2005. After that, net assets in both ESG funds and standard funds gradually decreased, with a small rebound in around 2019.