The Federal Reserve’s policies and broader economic trends are often reflected in the interplay between interest rates, market prices, and bond yields. These indicators are critical for understanding economic health and investor sentiment. Your task is to analyze their relationships to determine whether patterns or trends are evident.
Research Question: Are there visible relationships among interest rates, market prices (DJIA), and bond yields (10-year Treasury)?
Your analysis should explore the potential interactions and correlations between these key economic indicators over the past 25 years.
Our analysis:
Quick Introduction
To access market data from FRED, we will use the quantmod package. In R, this package is designed for retrieving, analyzing, and visualizing financial and economic data. The package allows users to easily access market data from sources like FRED and Yahoo Finance using getSymbols(), handling time series data efficiently with built-in functions for merging, transforming, and plotting. Additionally, quantmod provides tools for technical analysis, such as calculating moving averages, rate of change, and momentum indicators, making it a powerful package for financial modeling and data-driven decision-making.
library(quantmod)
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: TTR
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Data collection
start_date <-Sys.Date() - (25*365)start_date
[1] "2000-03-15"
symbols <-c("DJIA", "DGS10", "UNRATE")#| label: Get data from FRED for the past 25 yearsgetSymbols(symbols, src ="FRED", from = start_date)
#| label: Convert to xts format (ensuring proper handling)DJIA_xts <-as.xts(DJIA)DGS10_xts <-as.xts(DGS10)UNRATE_xts <-as.xts(UNRATE)#| label: Merge datasets while keeping only common dateseconomic_data <-merge(DJIA_xts, DGS10_xts, UNRATE_xts, all =FALSE)#| label: Remove missing valueseconomic_data <-na.omit(economic_data)
colnames(economic_data_df) <-c("Date", "DJIA", "Treasury_10Y", "Unemployment_Rate")#| label: Convert Date column to Date format economic_data_df$Date <-as.Date(economic_data_df$Date)economic_data_df$Date
The following is a three stacked time series plots illustrating macroeconomic trends and their relationships:
# Ensure proper data conversion to avoid misinterpretation of valueseconomic_data_df$DJIA <-as.numeric(economic_data_df$DJIA)economic_data_df$Treasury_10Y <-as.numeric(economic_data_df$Treasury_10Y)economic_data_df$Unemployment_Rate <-as.numeric(economic_data_df$Unemployment_Rate)economic_data_df$Date <-as.Date(economic_data_df$Date)# Set up the plotting layout for a single combined graphpar(mar =c(4, 4, 2, 2)) # Adjust margins for better spacing# Plot DJIAplot(economic_data_df$Date, economic_data_df$DJIA, type ="l", col ="blue", lwd =2,main ="Comparing Economic Indicators",ylab ="Values ", xlab ="Year", ylim =c(10000, 40000))# Add Treasury Yield, scaled for visibilityscaled_treasury <- economic_data_df$Treasury_10Y * (max(economic_data_df$DJIA) /max(economic_data_df$Treasury_10Y))lines(economic_data_df$Date, scaled_treasury, col ="red", lwd =2, lty =1) # Solid red line# Add Unemployment Rate, scaled for visibilityscaled_unemployment <- economic_data_df$Unemployment_Rate * (max(economic_data_df$DJIA) /max(economic_data_df$Unemployment_Rate))lines(economic_data_df$Date, scaled_unemployment, col ="green", lwd =2, lty =1) # Solid green line# Add a title, axis labels, and legendlegend("topleft", inset =c(0.05, 0.05), legend =c("DJIA", "Treasury Yield ", "Unemployment Rate "),col =c("blue", "red", "green"), lty =1, lwd =2, bty ="n", cex =0.7)
# Reset the plot layoutpar(mfrow =c(1, 1))
Graph Interpretation & Key Findings:
The three stacked time series plots shows a correlation in the performance of DJIA (blue), 10-Year Treasury Yield (red), and Unemployment Rate (green)over time. Based on the plots, we see that the DJIA typically trends upward during economic growth and declines during recessions, while the Treasury yield fluctuates based on Federal Reserve policies and investor sentiment, often falling during economic downturns. The Unemployment Rate inversely correlates with DJIA, rising in recessions and declining during economic booms.
In terms of investment strategies, the plots suggest shifting to defensive assets during downturns and targeting growth sectors in expansions. Additionally, businesses should prepare for interest rate fluctuations and use job market trends to anticipate consumer behavior for strategic decision-making.