Story 2

Author

Heleine Fouda

Investigating the Trifecta of Economic Indicators

The Federal Reserve’s policies and broader economic trends are often reflected in the interplay between interest ratesmarket 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 years
getSymbols(symbols, src = "FRED", from = start_date)
[1] "DJIA"   "DGS10"  "UNRATE"
head(DJIA)
               DJIA
2015-03-09 17995.72
2015-03-10 17662.94
2015-03-11 17635.39
2015-03-12 17895.22
2015-03-13 17749.31
2015-03-16 17977.42
head(DGS10)
           DGS10
2000-03-15  6.29
2000-03-16  6.26
2000-03-17  6.20
2000-03-20  6.18
2000-03-21  6.13
2000-03-22  6.13
head(UNRATE)
           UNRATE
2000-04-01    3.8
2000-05-01    4.0
2000-06-01    4.0
2000-07-01    4.0
2000-08-01    4.1
2000-09-01    3.9

Data preparation

#| 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 dates
economic_data <- merge(DJIA_xts, DGS10_xts, UNRATE_xts, all = FALSE)
#| label: Remove missing values
economic_data <- na.omit(economic_data)
economic_data_df <- data.frame(Date = index(economic_data), coredata(economic_data))
economic_data_df
         Date     DJIA DGS10 UNRATE
1  2015-04-01 17698.18  1.87    5.4
2  2015-05-01 18024.06  2.12    5.6
3  2015-06-01 18040.37  2.19    5.3
4  2015-07-01 17757.91  2.43    5.2
5  2015-09-01 16058.35  2.17    5.0
6  2015-10-01 16272.01  2.05    5.0
7  2015-12-01 17888.35  2.15    5.0
8  2016-02-01 16449.18  1.97    4.9
9  2016-03-01 16865.08  1.83    5.0
10 2016-04-01 17792.75  1.79    5.1
11 2016-06-01 17789.67  1.85    4.9
12 2016-07-01 17949.37  1.46    4.8
13 2016-08-01 18404.51  1.51    4.9
14 2016-09-01 18419.30  1.57    5.0
15 2016-11-01 18037.10  1.83    4.7
16 2016-12-01 19191.93  2.45    4.7
17 2017-02-01 19890.94  2.48    4.6
18 2017-03-01 21115.55  2.46    4.4
19 2017-05-01 20913.46  2.33    4.4
20 2017-06-01 21144.18  2.21    4.3
21 2017-08-01 21963.92  2.26    4.4
22 2017-09-01 21987.56  2.16    4.3
23 2017-11-01 23435.01  2.37    4.2
24 2017-12-01 24231.59  2.37    4.1
25 2018-02-01 26186.71  2.78    4.1
26 2018-03-01 24608.98  2.81    4.0
27 2018-05-01 24099.05  2.97    3.8
28 2018-06-01 24635.21  2.89    4.0
29 2018-08-01 25333.82  3.00    3.8
30 2018-10-01 26651.21  3.09    3.8
31 2018-11-01 25380.74  3.14    3.8
32 2019-02-01 25063.89  2.70    3.8
33 2019-03-01 26026.32  2.76    3.8
34 2019-04-01 26258.42  2.49    3.7
35 2019-05-01 26430.14  2.52    3.6
36 2019-07-01 26717.43  2.03    3.7
37 2019-08-01 26583.42  1.90    3.6
38 2019-10-01 26573.04  1.65    3.6
39 2019-11-01 27347.36  1.73    3.6
40 2020-04-01 20943.51  0.62   14.8
41 2020-05-01 23723.69  0.64   13.2
42 2020-06-01 25475.02  0.66   11.0
43 2020-07-01 25734.97  0.69   10.2
44 2020-09-01 28645.66  0.68    7.8
45 2020-10-01 27816.90  0.68    6.9
46 2020-12-01 29823.92  0.92    6.7
47 2021-02-01 30211.91  1.09    6.2
48 2021-03-01 31535.51  1.45    6.1
49 2021-04-01 33153.21  1.69    6.1
50 2021-06-01 34575.31  1.62    5.9
51 2021-07-01 34633.53  1.48    5.4
52 2021-09-01 35312.53  1.31    4.7
53 2021-10-01 34326.46  1.48    4.5
54 2021-11-01 35913.84  1.58    4.2
55 2021-12-01 34022.04  1.43    3.9
56 2022-02-01 35405.24  1.81    3.8
57 2022-03-01 33294.95  1.72    3.7
58 2022-04-01 34818.27  2.39    3.7
59 2022-06-01 32813.23  2.94    3.6
60 2022-07-01 31097.26  2.88    3.5
61 2022-08-01 32798.40  2.60    3.6
62 2022-09-01 31656.42  3.26    3.5
63 2022-11-01 32653.20  4.07    3.6
64 2022-12-01 34395.01  3.53    3.5
65 2023-02-01 34092.96  3.39    3.6
66 2023-03-01 32661.84  4.01    3.5
67 2023-05-01 34051.70  3.59    3.6
68 2023-06-01 33061.57  3.61    3.6
69 2023-08-01 35630.68  4.05    3.7
70 2023-09-01 34837.71  4.18    3.8
71 2023-11-01 33274.58  4.77    3.7
72 2023-12-01 36245.50  4.22    3.8
73 2024-02-01 38519.84  3.87    3.9
74 2024-03-01 39087.38  4.19    3.9
75 2024-04-01 39566.85  4.33    3.9
76 2024-05-01 37903.29  4.63    4.0
77 2024-07-01 39169.52  4.48    4.2
78 2024-08-01 40347.97  3.99    4.2
79 2024-10-01 42156.97  3.74    4.1
80 2024-11-01 42052.19  4.37    4.2
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
 [1] "2015-04-01" "2015-05-01" "2015-06-01" "2015-07-01" "2015-09-01"
 [6] "2015-10-01" "2015-12-01" "2016-02-01" "2016-03-01" "2016-04-01"
[11] "2016-06-01" "2016-07-01" "2016-08-01" "2016-09-01" "2016-11-01"
[16] "2016-12-01" "2017-02-01" "2017-03-01" "2017-05-01" "2017-06-01"
[21] "2017-08-01" "2017-09-01" "2017-11-01" "2017-12-01" "2018-02-01"
[26] "2018-03-01" "2018-05-01" "2018-06-01" "2018-08-01" "2018-10-01"
[31] "2018-11-01" "2019-02-01" "2019-03-01" "2019-04-01" "2019-05-01"
[36] "2019-07-01" "2019-08-01" "2019-10-01" "2019-11-01" "2020-04-01"
[41] "2020-05-01" "2020-06-01" "2020-07-01" "2020-09-01" "2020-10-01"
[46] "2020-12-01" "2021-02-01" "2021-03-01" "2021-04-01" "2021-06-01"
[51] "2021-07-01" "2021-09-01" "2021-10-01" "2021-11-01" "2021-12-01"
[56] "2022-02-01" "2022-03-01" "2022-04-01" "2022-06-01" "2022-07-01"
[61] "2022-08-01" "2022-09-01" "2022-11-01" "2022-12-01" "2023-02-01"
[66] "2023-03-01" "2023-05-01" "2023-06-01" "2023-08-01" "2023-09-01"
[71] "2023-11-01" "2023-12-01" "2024-02-01" "2024-03-01" "2024-04-01"
[76] "2024-05-01" "2024-07-01" "2024-08-01" "2024-10-01" "2024-11-01"
str(economic_data_df)
'data.frame':   80 obs. of  4 variables:
 $ Date             : Date, format: "2015-04-01" "2015-05-01" ...
 $ DJIA             : num  17698 18024 18040 17758 16058 ...
 $ Treasury_10Y     : num  1.87 2.12 2.19 2.43 2.17 2.05 2.15 1.97 1.83 1.79 ...
 $ Unemployment_Rate: num  5.4 5.6 5.3 5.2 5 5 5 4.9 5 5.1 ...
head(economic_data_df)
        Date     DJIA Treasury_10Y Unemployment_Rate
1 2015-04-01 17698.18         1.87               5.4
2 2015-05-01 18024.06         2.12               5.6
3 2015-06-01 18040.37         2.19               5.3
4 2015-07-01 17757.91         2.43               5.2
5 2015-09-01 16058.35         2.17               5.0
6 2015-10-01 16272.01         2.05               5.0

Data visualization

The following is a three stacked time series plots illustrating macroeconomic trends and their relationships:

# Ensure proper data conversion to avoid misinterpretation of values
economic_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 graph
par(mar = c(4, 4, 2, 2))  # Adjust margins for better spacing

# Plot DJIA
plot(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 visibility
scaled_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 visibility
scaled_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 legend
legend("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 layout
par(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.