TidyverseFirst we have to upload the “tidyverse” library
Short Bio Written in MarkdownHi! My name is Alejandro, I’m 23 years old and originally from Palamos, a beautiful coastal town in Spain.
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
I have built my career primarily at Deutsche Bank, gaining experience across several business areas:
Outside of work and school, I enjoy:
ggplot2 PracticeIn 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.
## 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.
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")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"
## [1] "Mean of BOND_TY10_US (2011-2020): 2.17"
## [1] "Std of BOND_TY10_US (2001-2010): 0.7"
## [1] "Std of BOND_TY10_US (2011-2020): 0.64"
Details