Rows: 537 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): ticker, company_name, sector, esg_uw_ow
dbl (7): esg_etf, standard_etf, esg_tilt, esg_tilt_z_score, esg_tilt_rank, e...
lgl (3): in_esg_only, in_standard_only, in_on_index_only
ℹ 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.
ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = standard_etf, colour = sector) +geom_point(shape ="circle", size =1L) +geom_smooth(span =0.47) +scale_color_viridis_d(option ="magma", direction =1) +scale_x_continuous(trans ="log10") +scale_y_continuous(trans ="log10") +labs(x ="ESG ETF (ESGU)",y ="Standard ETF (IVV)",title ="Large Cap US Equities ETFs ESG vs Non-ESG",subtitle ="Made with Esquisse",caption ="Josie Zhou" ) +theme_minimal() +facet_wrap(vars(sector))
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: reciprocal condition number 0
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: There are other near singularities as well. 0.052415
Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : span too small. fewer
data values than degrees of freedom.
Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
-0.83043
Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
0.21739
Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 0
Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 0.052415
Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
-Inf
library(tidyverse)# Transforming the datasetblackrock_esg_vs_non_esg_etf_long <- blackrock_esg_vs_non_esg_etf |>pivot_longer(cols =contains("etf"), names_to ="fund_type", values_to ="weight") |>mutate(fund_type =case_when( fund_type =="esg_etf"~"ESG ETF (ESGU)", fund_type =="standard_etf"~"Standard ETF (IVV)" ))# Filter and plotblackrock_esg_vs_non_esg_etf_long %>%filter(weight >=0& weight <=1) %>%ggplot(aes(x = weight, y = company_name, colour = fund_type, size = weight)) +geom_point(shape =16) +scale_color_hue(direction =-1) +labs(x ="Weight (percentage)",y ="Company name",title ="Weight of Large Cap US ETF: ESG vs. Non-ESG",caption ="Josie Zhou" ) +theme_minimal()
Reflection: There are a lot of green points lying on the y axis, indicating that these companies are excluded from ESG ETFs. This could be explained by the negative screening principle in ESG investment, which often refers to the act in ESG investing to exclude some companies that are famous for heavy pollution or employee rights violation. The distribution shows the effect of negative screening in ESG ETF portfolios.
ggplot(blackrock_esg_vs_non_esg_etf_long) +#Using the long data to make the visualizationaes(x = fund_type,y = weight,fill = sector,colour = sector ) +geom_col() +scale_fill_hue(direction =1) +scale_color_hue(direction =1) +labs(x ="Fund Type",y ="Weight",title ="Investment Sector Comparison of US Large Cap Companies: ESG and Non-ESG ETFs",subtitle ="A comparison of the holdings of BlackRock iShares IVV and ESGU",caption ="Josie Zhou" ) +coord_flip() +# make the diagrams horizontal so it's more readabletheme_minimal()
Reflection: This diagram can show the sector distribution of ESG funds and Non-ESG funds. As shown in this graph, the proportion of each sector generally matches between ESG and non-ESG funds.
ggplot(blackrock_esg_vs_non_esg_etf_long) +#Using the long data to make the visualizationaes(x = sector,y = weight,fill = fund_type,colour = fund_type ) +geom_col() +scale_fill_hue(direction =-1) +scale_color_hue(direction =-1) +# reverse the color code to use green for ESG fundslabs(x ="Sector",y ="Number of Companies in Holding",title ="Investment Sector Distribution of US Large Cap Companies",subtitle ="A comparison of the holdings of BlackRock iShares IVV and ESGU",caption ="Josie Zhou" ) +theme_minimal()
Reflection: This visualization shows the capital distribution among different sectors more directly, with information technology receiving the most investment across ESG and non-ESG funds.
ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = standard_etf, colour = sector) +geom_point(shape ="circle", size =1.5) +geom_smooth(se =TRUE, color ="blue", fill ="grey") +#add a smooth line and grey fill to fit the trendscale_color_hue(direction =1) +scale_x_continuous(trans ="log10") +# use log to show the trend betterscale_y_continuous(trans ="log10") +theme_minimal()
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
This graph uses the geom_smooth function to add one smooth line representing the overall trend. In the asethetics part, it also maps sector into color to have the colorful layout.
ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = standard_etf, colour = sector) +geom_point(shape ="circle", size =2.25) +geom_smooth(span =0.75) +# add multiple lines to show the trends of respective industries scale_color_hue(direction =1) +scale_x_continuous(trans ="log10") +#use log to show the trend betterscale_y_continuous(trans ="log10") +theme_minimal()
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Since the code has mapped sector in its aesthetics, the geom_smooth functions assumes that it should generate multiple trend lines without further specification. This is the main difference from the graph above.
ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = standard_etf) +geom_point(shape ="circle", size =1.5, colour ="#8000FF") +#set the color of all points to purplegeom_smooth(se =TRUE, color ="yellow", fill ="grey") +#set the color of the trend line to yellowscale_x_continuous(trans ="log10") +#use log to show the trend betterscale_y_continuous(trans ="log10") +theme_minimal()
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
This graph changes the color of the graph. I did this by adding a color tab in the bracket of geom_point and geom_smooth function.
#Use a bubble plot to represent the size of each data pointggplot(blackrock_esg_vs_non_esg_etf, aes(x=esg_etf, y=standard_etf, size = sector, color = sector)) +#use log10 to show the trend betterscale_x_continuous(trans ="log10") +scale_y_continuous(trans ="log10") +#add labs(x ="ESG ETFs",y ="Standard ETFs ",title ="Bubble Plot of US Large Cap Companies",caption ="Josie Zhou" ) +#adjust alpha to make the bubbles more transparentgeom_point(alpha=0.3)
Warning: Using size for a discrete variable is not advised.
Warning: Transformation introduced infinite values in continuous x-axis
Warning: Transformation introduced infinite values in continuous y-axis
This chart tells us the size of investment in different sectors in ESG funds and standard funds. The bubble chart shows both the distribution across industries and the the proportion of total investment.
#use a new extension called ggsci to use color palette that is commonly used in scientific journals.library(ggsci)ggplot(blackrock_esg_vs_non_esg_etf) +aes(x = esg_etf, y = sector, fill = sector) +geom_boxplot() +#scale the color and scale to a set color palette in ggsciscale_color_npg() +scale_fill_npg() +#scale the dataset to be more representativescale_x_continuous(trans ="log10") +labs(x ="Weight in ESG ETFs",y ="Sector",title ="Boxplot for ESG ETFs Portfolio across Sectors",caption ="Josie Zhou" ) +theme_minimal()
Warning: Transformation introduced infinite values in continuous x-axis
Warning: This manual palette can handle a maximum of 10 values. You have
supplied 11
This box plot show the statistical distribution of different percentiles and outliers of investment weight from ESG ETFs. This can directly show readers how ESG funds allocate their assets.