Homework 3

Pre-Homework

#load the tidyverse 
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
# this will stop R from presenting data in scientific notation, which can be annoying. 
options(scipen = 999)
#loding the data
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>, …
# 2.4.2 Exploring our Dataset
blackrock_etf_screener |> 
  glimpse()
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…
#2.4.2.2 Exploring categorical variables, 3 ways using dplyr
blackrock_etf_screener |> 
  distinct(sustainable_classification)
# A tibble: 5 × 1
  sustainable_classification
  <chr>                     
1 <NA>                      
2 Uplift                    
3 Thematic                  
4 Impact                    
5 Screened                  
blackrock_etf_screener |> 
  group_by(sustainable_classification) |> 
  count(sort = TRUE)
# A tibble: 5 × 2
# Groups:   sustainable_classification [5]
  sustainable_classification     n
  <chr>                      <int>
1 <NA>                         384
2 Uplift                        30
3 Thematic                       6
4 Screened                       3
5 Impact                         1
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 order
  arrange(assets_usd |> desc())
# A tibble: 5 × 3
  sustainable_classification n_funds assets_usd
  <chr>                        <int>      <dbl>
1 <NA>                           384    2.55e12
2 Uplift                          30    5.14e10
3 Thematic                         6    3.43e 9
4 Screened                         3    3.83e 8
5 Impact                           1    3.35e 8
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 order
  arrange(desc(assets_usd))
# A tibble: 5 × 3
  sustainable_classification n_funds assets_usd
  <chr>                        <int>      <dbl>
1 <NA>                           384    2.55e12
2 Uplift                          30    5.14e10
3 Thematic                         6    3.43e 9
4 Screened                         3    3.83e 8
5 Impact                           1    3.35e 8
#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 date
    inception_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 Funds
blackrock_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 |> 
  mutate(assets_pct = assets_bn/sum(assets_bn) * 100,
         .after = standard_or_esg)
# A tibble: 2 × 4
  standard_or_esg assets_pct assets_bn n_funds
  <chr>                <dbl>     <dbl>   <int>
1 ESG                   2.14      55.6      40
2 Standard             97.9     2547.      384
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 break
       caption = "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)

etf_formation_esg_vs_standard <- blackrock_etf_screener_w_new_features |> 
  group_by(standard_or_esg, inception_year) |> 
  count() |> 
  ungroup()

etf_formation_esg_vs_standard_cumulative <- etf_formation_esg_vs_standard |> 
  arrange(standard_or_esg, inception_year) |> 
  group_by(standard_or_esg) |> 
  mutate(cumulative_n = cumsum(n)) |> 
  ungroup()

etf_formation_esg_vs_standard_cumulative 
# A tibble: 37 × 4
   standard_or_esg inception_year     n cumulative_n
   <chr>                    <dbl> <int>        <int>
 1 ESG                       2005     1            1
 2 ESG                       2006     1            2
 3 ESG                       2008     1            3
 4 ESG                       2014     1            4
 5 ESG                       2016     5            9
 6 ESG                       2017     2           11
 7 ESG                       2018     3           14
 8 ESG                       2019     1           15
 9 ESG                       2020    12           27
10 ESG                       2021     5           32
# ℹ 27 more rows
etf_formation_esg_vs_standard_cumulative |> 
  ggplot(aes(x = inception_year, y = cumulative_n, color = standard_or_esg)) +
  geom_line()

etf_formation_esg_vs_standard
# A tibble: 37 × 3
   standard_or_esg inception_year     n
   <chr>                    <dbl> <int>
 1 ESG                       2005     1
 2 ESG                       2006     1
 3 ESG                       2008     1
 4 ESG                       2014     1
 5 ESG                       2016     5
 6 ESG                       2017     2
 7 ESG                       2018     3
 8 ESG                       2019     1
 9 ESG                       2020    12
10 ESG                       2021     5
# ℹ 27 more rows
etf_formation_esg_vs_standard |> 
  ggplot(aes(x = inception_year, y = n, fill = standard_or_esg)) +
  geom_bar(stat = "identity", position = "stack")

etf_formation_esg_vs_standard |> 
  ggplot(aes(x = inception_year, y = n, color = standard_or_esg)) +
  geom_bar(stat = "identity", position = "stack")

blackrock_etf_screener_w_new_features |> 
  summarize(
    max_size = max(net_assets_bn_usd, na.rm = TRUE),
    min_size = min(net_assets_bn_usd, na.rm = TRUE),
    avg_size = mean(net_assets_bn_usd, na.rm = TRUE),
    sd_size = sd(net_assets_bn_usd, na.rm = TRUE),
    median_size = median(net_assets_bn_usd, na.rm = TRUE),
    # same as median, calculated a different way for illustration
    percentile_50 = quantile(net_assets_bn_usd, .5, na.rm = TRUE),
    percentile_75 = quantile(net_assets_bn_usd, .75, na.rm = TRUE),
  )
# A tibble: 1 × 7
  max_size min_size avg_size sd_size median_size percentile_50 percentile_75
     <dbl>    <dbl>    <dbl>   <dbl>       <dbl>         <dbl>         <dbl>
1     399. 0.000457     6.14    23.2       0.606         0.606          3.57
blackrock_etf_screener_w_new_features |> 
  group_by(standard_or_esg, asset_class) |> 
  summarize(
    max_size = max(net_assets_bn_usd, na.rm = TRUE),
    min_size = min(net_assets_bn_usd, na.rm = TRUE),
    avg_size = mean(net_assets_bn_usd, na.rm = TRUE),
    sd_size = sd(net_assets_bn_usd, na.rm = TRUE),
    median_size = median(net_assets_bn_usd, na.rm = TRUE),
    # same as median, calculated a different way for illustration
    percentile_50 = quantile(net_assets_bn_usd, .5, na.rm = TRUE),
    percentile_75 = quantile(net_assets_bn_usd, .75, na.rm = TRUE),
  )
`summarise()` has grouped output by 'standard_or_esg'. You can override using
the `.groups` argument.
# A tibble: 9 × 9
# Groups:   standard_or_esg [2]
  standard_or_esg asset_class   max_size min_size avg_size  sd_size median_size
  <chr>           <chr>            <dbl>    <dbl>    <dbl>    <dbl>       <dbl>
1 ESG             Equity        13.4     0.00371   1.74     2.97        0.501  
2 ESG             Fixed Income   3.56    0.0125    0.954    1.22        0.586  
3 ESG             Multi Asset    0.0257  0.00527   0.0144   0.00966     0.0132 
4 ESG             Real Estate    0.00939 0.00939   0.00939 NA           0.00939
5 Standard        Commodity     26.5     0.0130    4.48     8.92        0.659  
6 Standard        Equity       399.      0.000457  8.02    29.9         0.817  
7 Standard        Fixed Income 101.      0.00247   5.22    12.6         0.423  
8 Standard        Multi Asset    2.25    0.00271   0.435    0.782       0.00383
9 Standard        Real Estate    4.60    0.0403    1.76     1.67        1.41   
# ℹ 2 more variables: percentile_50 <dbl>, percentile_75 <dbl>
blackrock_etf_screener_w_new_features |> 
  filter(standard_or_esg == "ESG") |> 
  select(ticker, name, net_assets_bn_usd) |> 
  mutate(
    fund_rank = rank(net_assets_bn_usd),
    fund_percentile = percent_rank(net_assets_bn_usd),
    fund_decile = ntile(net_assets_bn_usd, n = 10),
    
    pct_of_total = net_assets_bn_usd/sum(net_assets_bn_usd, na.rm = TRUE) * 100,
    pct_of_total_cumulative = cumsum(pct_of_total))
# A tibble: 40 × 8
   ticker name           net_assets_bn_usd fund_rank fund_percentile fund_decile
   <chr>  <chr>                      <dbl>     <dbl>           <dbl>       <int>
 1 ESGU   iShares ESG A…             13.4         40           1              10
 2 ESGD   iShares ESG A…              7.64        39           0.974          10
 3 SUSA   iShares MSCI …              5.37        38           0.949          10
 4 DSI    iShares MSCI …              4.08        37           0.923          10
 5 ESGE   iShares ESG A…              4.02        36           0.897           9
 6 EAGG   iShares ESG A…              3.56        35           0.872           9
 7 ICLN   iShares Globa…              3.06        34           0.846           9
 8 USCL   iShares Clima…              2.09        33           0.821           9
 9 PABU   iShares Paris…              1.54        32           0.795           8
10 LCTU   BlackRock U.S…              1.51        31           0.769           8
# ℹ 30 more rows
# ℹ 2 more variables: pct_of_total <dbl>, pct_of_total_cumulative <dbl>
    tibble(value = 1:10) |> 
      mutate(rank = rank(value),
             percentile = percent_rank(value),
             decile = ntile(value, n = 10))    
# A tibble: 10 × 4
   value  rank percentile decile
   <int> <dbl>      <dbl>  <int>
 1     1     1      0          1
 2     2     2      0.111      2
 3     3     3      0.222      3
 4     4     4      0.333      4
 5     5     5      0.444      5
 6     6     6      0.556      6
 7     7     7      0.667      7
 8     8     8      0.778      8
 9     9     9      0.889      9
10    10    10      1         10
    blackrock_etf_screener_w_new_features |> 
      filter(standard_or_esg == "ESG") |> 
      select(ticker, name, net_assets_bn_usd) |> 
      mutate(
        fund_rank = rank(net_assets_bn_usd * -1),
        fund_percentile = percent_rank(net_assets_bn_usd * -1),
        fund_decile = ntile(net_assets_bn_usd * -1, n = 10),
        
        pct_of_total = net_assets_bn_usd/sum(net_assets_bn_usd, na.rm = TRUE) * 100,
        pct_of_total_cumulative = cumsum(pct_of_total)
      )   
# A tibble: 40 × 8
   ticker name           net_assets_bn_usd fund_rank fund_percentile fund_decile
   <chr>  <chr>                      <dbl>     <dbl>           <dbl>       <int>
 1 ESGU   iShares ESG A…             13.4          1          0                1
 2 ESGD   iShares ESG A…              7.64         2          0.0256           1
 3 SUSA   iShares MSCI …              5.37         3          0.0513           1
 4 DSI    iShares MSCI …              4.08         4          0.0769           1
 5 ESGE   iShares ESG A…              4.02         5          0.103            2
 6 EAGG   iShares ESG A…              3.56         6          0.128            2
 7 ICLN   iShares Globa…              3.06         7          0.154            2
 8 USCL   iShares Clima…              2.09         8          0.179            2
 9 PABU   iShares Paris…              1.54         9          0.205            3
10 LCTU   BlackRock U.S…              1.51        10          0.231            3
# ℹ 30 more rows
# ℹ 2 more variables: pct_of_total <dbl>, pct_of_total_cumulative <dbl>

Homework 3

2.5.0.1 Homework problem 1

library(tidyverse)
library(dplyr)
options(scipen = 999)
library(ggplot2)
library(forcats)
library(lubridate)
ESG_fund_tibble <- blackrock_etf_screener_w_new_features %>% #Naming my tibble
      filter(standard_or_esg == "ESG") %>%  # Filter only ESG funds
      group_by(sustainable_classification) %>%  # Group by sustainable classification
      mutate(total_assets_in_class = sum(net_assets_bn_usd, na.rm = TRUE)) %>%  # Sum assets in each class
      slice_max(net_assets_bn_usd, n = 1) %>%  # Select the largest fund in each class
      ungroup() %>%  # Remove grouping
      mutate(
        pct_of_total = net_assets_bn_usd / total_assets_in_class * 100,  # Calculate percent of total assets
        pct_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: 4 × 24
  standard_or_esg inception_year net_assets_bn_usd ticker name                  
  <chr>                    <dbl>             <dbl> <chr>  <chr>                 
1 ESG                       2018             0.335 BGRN   iShares USD Green Bon…
2 ESG                       2008             3.06  ICLN   iShares Global Clean …
3 ESG                       2020             0.182 XVV    iShares ESG Screened …
4 ESG                       2016            13.4   ESGU   iShares ESG Aware MSC…
# ℹ 19 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>,
#   msci_esg_percent_coverage <dbl>, sustainable_classification <chr>, …

2.5.0.2 Homework problem 2:

2.5.0.3 Homework problem 3

  blackrock_etf_screener_w_new_features %>%
      filter(msci_esg_quality_score_0_10 <=quantile(msci_esg_quality_score_0_10, 0.2, na.rm = TRUE)) %>%
      group_by(asset_class, sub_asset_class) %>%
      summarize(num_funds = n(), .groups = "drop")
# 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 it
       count(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: Analysis
asset_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.