Tidyverse

First we have to upload the “tidyverse” library

Short Bio Written in Markdown

About Me

Hi! My name is Alejandro, I’m 23 years old and originally from Palamos, a beautiful coastal town in Spain.

Palamos
Palamos

I hold a BSc in Economics from Universitat Pompeu Fabra in (Barcelona), where I developed a strong interest in Finance. I am currently pursuing the Masters in Financial Analysis (MFA) at London Business School

Professional Experience

I have built my career primarily at Deutsche Bank, gaining experience across several business areas:

  • Corporate Banking Off-Cycle - (6 months)
  • Wealth Management Analyst - (Fixed-term contract)
  • Private Banking Off-Cycle - (3 months)

Interests

Outside of work and school, I enjoy:

  • Running (currently training for a full marathon!)
  • Sailing and outdoor sports
  • Traveling and exploring new cultures
LBS Campus
LBS Campus

ggplot2 Practice

In this section, I analyze the market yield on U.S. Treasury Securities at 10-Year Constant Maturity from 1962 to 2025. I begin by loading the dataset “DGS10.cvs” and taking a first look at its structure and the first 20 rows of data.

bond_10yr <- read_csv("Data/DGS10.csv")
glimpse(bond_10yr, 20)
## Rows: 16,563
## Columns: 2
## $ Date  <chr> "196…
## $ DGS10 <dbl> 4.06…

The dataset contains a Date column and the variable DGS10, which represents the yield (in percentage). Before analyzing the data, I converted the Date column to a proper date format and removed rows with missing values.

bond_10yr$Date <- as.Date(bond_10yr$Date)
bond_10yr <- bond_10yr %>% 
            filter(!is.na(DGS10))

For a focused analysis, I filtred the data into two subset: - The first covers the period from 2001 to 2010. - The second covers the period from 2011 to 2020.

This allows me to compare the yield behavior before and after the Global Financial Crisis.

data_2001_2010 <- bond_10yr %>% 
            filter(Date >= "2001-01-01" & Date < "2011-01-01") 
data_2011_2020 <- bond_10yr %>% 
            filter(Date >= "2011-01-01"& Date < "2021-01-01")

Plots & Stats

To better understand the behavior of the 10-year US Treasury yield, I created two plots: one covering the period 2001-2010 (in blue) and another covering 2011-2020 (in red). This helps visualize how yields changed before and after the Global Financial crisis.

# 2001_2010
ggplot(data=data_2001_2010, aes(x = Date, y = DGS10)) +
    geom_line(color = "blue") +
    theme_minimal()

# 2011_2020
ggplot(data=data_2011_2020, aes(x = Date, y = DGS10)) +
    geom_line(color = "red") +
    theme_minimal()

To make the visualization more informative, I added a descriptive title and axis labels to both plots:

# 2001_2010
ggplot(data=data_2001_2010, aes(x = Date, y = DGS10)) +
    geom_line(color = "blue") +
    labs(title = "10-year US Treasury Yield (2001-2010)", 
         x = "Date", 
         y = "Yield %") +
    theme_minimal()

# 2011_2020
ggplot(data=data_2011_2020, aes(x = Date, y = DGS10)) +
    geom_line(color = "red") +
    labs(title = "10-year US Treasury Yield (2011-2020)", 
    x = "Date", 
    y = "Yield %") +
  theme_minimal()

To complement the plots, I calculated the mean and standard deviation of yields for both periods. This allows me to compare the level and volatility of interest rates over time.

# Calculate the mean of BOND_TY10_US for data_2001_2010
mean_2001_2010 <- mean(data_2001_2010$DGS10, na.rm = TRUE)
std_2001_2010 <- sd(data_2001_2010$DGS10, na.rm = TRUE)

# Calculate the mean of BOND_TY10_US for data_2011_2020
mean_2011_2020 <- mean(data_2011_2020$DGS10, na.rm = TRUE)
std_2011_2020 <- sd(data_2011_2020$DGS10, na.rm = TRUE)

# Print the results
print(paste("Mean of BOND_TY10_US (2001-2010):", round(mean_2001_2010, 2)))
## [1] "Mean of BOND_TY10_US (2001-2010): 4.18"
print(paste("Mean of BOND_TY10_US (2011-2020):", round(mean_2011_2020, 2)))
## [1] "Mean of BOND_TY10_US (2011-2020): 2.17"
print(paste("Std of BOND_TY10_US (2001-2010):", round(std_2001_2010, 2)))
## [1] "Std of BOND_TY10_US (2001-2010): 0.7"
print(paste("Std of BOND_TY10_US (2011-2020):", round(std_2011_2020, 2)))
## [1] "Std of BOND_TY10_US (2011-2020): 0.64"

Details

  • Who did you collaborate with: JUST ME
  • How much time did you spend on each of the 3 Datacamp chapters and on this preliminary assignment completion: AROUND 6-7H
  • What, if anything, gave you the most trouble: NOTHING IN PARTICULAR