── 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
# this will stop R from presenting data in scientific notation, which can be annoying. options(scipen =999)#loding the datablackrock_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 |>group_by(sustainable_classification) |>summarize(# how many funds?n_funds =n(),# how much money?assets_usd =sum(net_assets_usd, na.rm =TRUE) ) |># arrange in descending orderarrange(assets_usd |>desc())
blackrock_etf_screener |>group_by(sustainable_classification) |>summarize(# how many funds?n_funds =n(),# how much money?assets_usd =sum(net_assets_usd, na.rm =TRUE) ) |># arrange in descending orderarrange(desc(assets_usd))
#2.4.3 Feature Engineering with mutate()blackrock_etf_screener_w_new_features <- blackrock_etf_screener |>mutate(# if the sustainable_classification column is NA, then the fund is not an ESG fund.standard_or_esg =if_else(condition =is.na(sustainable_classification),true ="Standard",false ="ESG" ),# lubridate::year() extracts the year from a dateinception_year = lubridate::year(incept_date),# Change to a meaningful magnitude for the data. In asset management, billions is a good default. net_assets_bn_usd = net_assets_usd/10^9,# let's put our new variables at the front so we can see them easily..before =everything() )blackrock_etf_screener_w_new_features
# A tibble: 424 × 21
standard_or_esg inception_year net_assets_bn_usd ticker name
<chr> <dbl> <dbl> <chr> <chr>
1 Standard 2000 399. IVV iShares Core S&P 500…
2 Standard 2012 107. IEFA iShares Core MSCI EA…
3 Standard 2003 101. AGG iShares Core U.S. Ag…
4 Standard 2000 82.1 IWF iShares Russell 1000…
5 Standard 2000 78.2 IJR iShares Core S&P Sma…
6 Standard 2000 77.1 IJH iShares Core S&P Mid…
7 Standard 2012 73.9 IEMG iShares Core MSCI Em…
8 Standard 2000 67.7 IWM iShares Russell 2000…
9 Standard 2000 55.4 IWD iShares Russell 1000…
10 Standard 2002 52.2 TLT iShares 20+ Year Tre…
# ℹ 414 more rows
# ℹ 16 more variables: incept_date <dttm>, gross_expense_ratio_percent <dbl>,
# 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>, …
#2.4.4 Analyzing ESG vs. Standard Fundsblackrock_etf_screener_w_new_features |>summarize(total_assets_bn =sum(net_assets_bn_usd, na.rm =TRUE))
# A tibble: 1 × 1
total_assets_bn
<dbl>
1 2603.
#2.4.4.1 Static Analysis: How big a share is the ESG business?assets_esg_vs_standard <- blackrock_etf_screener_w_new_features |>group_by(standard_or_esg) |>summarize(assets_bn =sum(net_assets_bn_usd, na.rm =TRUE),n_funds =n() )assets_esg_vs_standard
# A tibble: 2 × 3
standard_or_esg assets_bn n_funds
<chr> <dbl> <int>
1 ESG 55.6 40
2 Standard 2547. 384
assets_esg_vs_standard |>ggplot(aes(x = assets_bn, y = standard_or_esg)) +geom_bar(stat ="identity")
assets_esg_vs_standard |>ggplot(aes(x = assets_bn, y = standard_or_esg)) +geom_bar(stat ="identity", fill ="grey40", alpha = .7) +# make it prettier# scales::label_* funcitons provide useful options. Check them out!scale_x_continuous(labels = scales::label_dollar(scale =1/10^3, suffix =" tn")) +labs(title ="Total Assets: iShares ESG vs. Standard Funds",subtitle ="ESG comprise a small percentage of total assets.",x ="Total Assets (USD)",y ="Fund Type",# you can use \n to create a line breakcaption ="I made this.\nData as of xyz") +theme_minimal()
assets_esg_vs_standard |>mutate(assets_pct = assets_bn/sum(assets_bn) *100) |>ggplot(aes(x = assets_pct, y = standard_or_esg)) +geom_bar(stat ="identity", fill ="grey40", alpha = .7)
library(tidyverse)library(dplyr)options(scipen =999)library(ggplot2)library(forcats)library(lubridate)ESG_fund_tibble <- blackrock_etf_screener_w_new_features %>%#Naming my tibblefilter(standard_or_esg =="ESG") %>%# Filter only ESG fundsgroup_by(sustainable_classification) %>%# Group by sustainable classificationmutate(total_assets_in_class =sum(net_assets_bn_usd, na.rm =TRUE)) %>%# Sum assets in each classslice_max(net_assets_bn_usd, n =1) %>%# Select the largest fund in each classungroup() %>%# Remove groupingmutate(pct_of_total = net_assets_bn_usd / total_assets_in_class *100, # Calculate percent of total assetspct_of_total_cumulative =cumsum(pct_of_total) # Calculate cumulative percent ) %>%arrange(desc(pct_of_total)) # Arrange in descending order of percent of total assets ESG_fund_tibble
# A tibble: 9 × 3
asset_class sub_asset_class num_funds
<chr> <chr> <int>
1 Equity All Cap 23
2 Equity Large Cap 1
3 Equity Large/Mid Cap 10
4 Equity Small Cap 17
5 Fixed Income Corporates 1
6 Fixed Income Credit 1
7 Fixed Income Government 3
8 Fixed Income High Yield 16
9 Real Estate Real Estate Securities 4
2.5.0.4 Homework problem 4:
Insight 1
# Insight 1: Distribution of Net Assets by Asset Class net_assets_by_asset_class <- blackrock_etf_screener_w_new_features %>%group_by(asset_class) %>%summarise(total_assets =sum(net_assets_bn_usd, na.rm =TRUE)) %>%arrange(desc(total_assets))ggplot(net_assets_by_asset_class, aes(x =reorder(asset_class, total_assets), y = total_assets)) +geom_bar(stat ="identity", fill="blue") +coord_flip() +labs(title ="Distribution of Net Assets by Asset Class", x ="Asset Class", y ="Total Assets (Billion USD)")+theme_classic()
#The bar chart indicates that equity asset class dominates the portfolio with the highest total net assets, suggesting a strong investor preference or performance in this category. Other asset classes, such as fixed income, commodities, real estate, and multi-asset, have significantly lower total net assets, highlighting a potential lack of diversification or a strategic focus on equities.
Insight 2
# Insight 2: ESG Rating Distribution esg_rating_distribution <- blackrock_etf_screener_w_new_features %>%filter(!is.na(msci_esg_fund_rating_aaa_ccc)) %>%#chart was creating an NA bar in chart so I want to remove itcount(msci_esg_fund_rating_aaa_ccc, na.rm =TRUE) %>%arrange(desc(n))ggplot(esg_rating_distribution, aes(x = msci_esg_fund_rating_aaa_ccc, y = n),) +geom_bar(stat ="identity", fill="blue") +labs(title ="Distribution of MSCI ESG Ratings", x ="ESG Rating", y ="Number of Funds")+theme_classic()
#The bar chart displays a distribution of MSCI ESG ratings where the 'A' category has the highest number of funds, indicating it's the most common ESG rating among the surveyed funds. In contrast, the 'AAA' and 'BB' categories have notably fewer funds, suggesting that very high and lower ESG ratings are less frequently assigned and that there are few firms that are resilient to long-term ESG risks
Insight 3
# Insight 3# Analysis sector_distribution <- blackrock_etf_screener_w_new_features %>%filter(standard_or_esg =="ESG") %>%count(sub_asset_class) %>%arrange(desc(n))ggplot(sector_distribution, aes(x =reorder(sub_asset_class, n), y = n)) +geom_bar(stat ="identity", fill="blue") +coord_flip() +labs(title ="Sector-wise Distribution of ESG Funds", x ="Sector", y ="Number of Funds")+theme_classic()
#The bar chart shows the sector-wise distribution of ESG funds, with 'All Cap' funds being the most prevalent, indicating a broad market investment strategy is favored in ESG portfolios. Conversely, 'High Yield' funds have the least representation, suggesting less emphasis on income-focused strategies within ESG investing.
Insight 4
# Insight 5: Regional Exposure of Funds regional_exposure <- blackrock_etf_screener_w_new_features %>%count(region) %>%arrange(desc(n))ggplot(regional_exposure, aes(x =reorder(region, n), y = n)) +geom_bar(stat ="identity",fill="blue") +coord_flip() +labs(title ="Regional Exposure of Funds", x ="Region", y ="Number of Funds")+theme_classic()
#The bar chart illustrates that funds with global exposure vastly outnumber those focused on specific regions, suggesting a preference for diversified international investment strategies. Meanwhile, funds specifically targeting Kuwait represent the smallest category, indicating either a niche focus or limited interest in this regional market among the fund offerings.
Insight 5
# Insight 5: Analysisasset_class_proportion <- blackrock_etf_screener_w_new_features %>%group_by(asset_class) %>%summarise(total_assets =sum(net_assets_bn_usd, na.rm =TRUE)) %>%mutate(proportion = total_assets /sum(total_assets))# Insight 5: Visualization (Pie Chart)ggplot(asset_class_proportion, aes(x ="", y = proportion, fill = asset_class)) +geom_bar(stat ="identity", width =1) +coord_polar("y") +labs(title ="Asset Class Proportion of Total Net Assets", x ="", y ="") +theme_void()
#The pie chart reveals a heavy concentration of investments in a single asset class, with minimal diversification into other classes. This suggests a focused investment strategy, potentially reflecting market confidence or a lack of risk spread.