{r setup, include=FALSE} options(bitmapType=‘cairo’) options(digits = 3, scipen = 99999) remove(list = ls()) graphics.off()
suppressWarnings({ suppressPackageStartupMessages({ library(markovchain) library(tidyverse) library(quantmod) library(tsbox) library(vars) library(xts) library(TSstudio) }) })
Understanding the state of the economy is crucial for policymakers, businesses, and individuals alike. In this analysis, we construct a diffusion index for the United States economy using three economic indicators: Unemployment Rate (UNRATE), Industrial Production Index (INDPRO), and Retail Sales (RSAFSNA). Diffusion indexes serve as a measure of economic activity, aggregating diverse signals into a single value that helps in identifying trends and turning points.
This analysis is a part of the coursework for *Pompea College of Business, University of New Haven. My name is **Sarangam Sathwik*, and I hope this analysis will provide valuable insights into the dynamics of the US economy.
The first step in constructing the diffusion index is to gather relevant data. We have selected three key indicators that provide a balanced representation of the economic condition:
The data for these indicators has been collected from FRED (Federal Reserve Economic Data).
{r data-collection} # Pick 3 pertinent economic variables for the US getSymbols(c(“UNRATE”, “INDPRO”, “RSAFSNA”), freq = “monthly”, src = “FRED”, return.class = ‘xts’, index.class = ‘Date’, from = “2010-01-01”, to = Sys.Date(), auto.assign = TRUE)
us_data <- merge(UNRATE, INDPRO, RSAFSNA) colnames(us_data) <- c(“Unemployment_Rate”, “Industrial_Production”, “Retail_Sales”)
In order to make these indicators comparable, we need to standardize them. Standardization ensures that differences in scale between the variables do not bias the diffusion index.
{r data-standardization} # Standardize each series to ensure comparability us_data_scaled <- us_data %>% na.omit() %>% scale() %>% as.xts()
The diffusion index is constructed by averaging the standardized versions of the three indicators. By aggregating these indicators, we can gain a broader picture of the general economic trends.
{r diffusion-index} # Constructing a diffusion index by averaging standardized variables us_data_diffusion <- rowMeans(us_data_scaled, na.rm = TRUE) us_data_diffusion <- xts(us_data_diffusion, order.by = index(us_data_scaled))
The diffusion index provides a broad view of the economy by aggregating multiple indicators into a single measure. Below, we analyze the constructed diffusion index over time.
The following plot visualizes the diffusion index over time, with a loess smoother added to highlight the overall trend.
{r plot-diffusion-index, echo=FALSE, message=FALSE, warning=FALSE, dev=‘png’} us_data_df <- data.frame(Date = index(us_data_diffusion), Diffusion_Index = coredata(us_data_diffusion))
ggplot(us_data_df, aes(x = Date, y = Diffusion_Index)) + geom_line(color = “blue”) + geom_smooth(method = “loess”, color = “red”) + labs(title = “Diffusion Index of Selected US Economic Variables”, x = “Date”, y = “Diffusion Index”) + theme_minimal()
The diffusion index highlights key turning points in the economy. For instance, we observe sharp declines during significant economic downturns, such as the COVID-19 pandemic period in 2020.
The Chicago Fed National Activity Index (CFNAI) serves as a benchmark for national economic activity. By comparing our diffusion index to the CFNAI, we can assess how well our selected indicators track broader economic trends.
{r get-cfnai} # Comparing with Chicago Fed National Activity Index: Diffusion Index (CFNAI) getSymbols(“CFNAI”, src = “FRED”, return.class = ‘xts’, from = “2010-01-01”, to = Sys.Date(), auto.assign = TRUE)
common_start_date <- max(start(us_data_diffusion), start(CFNAI)) common_end_date <- min(end(us_data_diffusion), end(CFNAI)) us_data_diffusion_aligned <- window(us_data_diffusion, start = common_start_date, end = common_end_date) CFNAI_aligned <- window(CFNAI, start = common_start_date, end = common_end_date)
combined_data <- merge(us_data_diffusion_aligned, CFNAI_aligned, join = “inner”) colnames(combined_data) <- c(“Diffusion_Index”, “Chicago_Fed_Index”)
The correlation between our diffusion index and the CFNAI gives us an indication of how closely the two indexes track each other.
{r correlation-analysis} # Calculating correlation correlation <- cor(combined_data\(Diffusion_Index, combined_data\)Chicago_Fed_Index, use = “complete.obs”) print(paste(“Correlation Coefficient:”, round(correlation, 3)))
The correlation coefficient is calculated above. A high correlation value would indicate that our selected indicators effectively mirror the general economic activity captured by the CFNAI.
The comparison between the diffusion index we created and the Chicago Fed National Activity Index (CFNAI) reveals important insights into how well our selected indicators reflect overall economic activity.
Below, we plot both indexes side by side to visualize their similarities or differences over time.
{r plot-comparison, echo=FALSE, message=FALSE, warning=FALSE, dev=‘png’} combined_data_df <- data.frame(Date = index(combined_data), Diffusion_Index = coredata(combined_data\(Diffusion_Index), Chicago_Fed_Index = coredata(combined_data\)Chicago_Fed_Index))
ggplot(combined_data_df) + geom_line(aes(x = Date, y = Diffusion_Index, color = “Diffusion Index”)) + geom_line(aes(x = Date, y = Chicago_Fed_Index, color = “Chicago Fed Index”)) + labs(title = “Comparison of Diffusion Indexes”, x = “Date”, y = “Index Value”) + theme_minimal() + scale_color_manual(values = c(“Diffusion Index” = “blue”, “Chicago Fed Index” = “green”))
In the comparison plot, periods where the two indexes move together indicate strong alignment in the economic trends they represent. Deviations between the indexes may suggest differences in how each index responds to specific economic shocks or events.
The analysis shows that our diffusion index closely tracks the CFNAI, as evidenced by the correlation coefficient and visual comparison. Given that the CFNAI data ends in September, we observe that our diffusion index continues to provide valuable insights into the ongoing economic conditions, which suggest a gradual recovery.
This analysis serves as a foundation for understanding how diffusion indexes are constructed and used to monitor economic activity. The selected indicators—Unemployment Rate, Industrial Production, and Retail Sales—collectively provide a comprehensive picture of the economy, aligning well with broader measures like the CFNAI. However, expanding the range of indicators may further improve the robustness and accuracy of the index.
The analysis shows that our diffusion index closely tracks the CFNAI, as evidenced by the correlation coefficient and visual comparison. Given that the CFNAI data ends in September, we observe that our diffusion index continues to provide valuable insights into the ongoing economic conditions, which suggest a gradual recovery.
During periods of divergence, further analysis would be needed to understand which of the underlying indicators are driving the differences. This highlights the importance of selecting a diverse range of economic indicators to create a diffusion index.
This analysis serves as a foundation for understanding how diffusion indexes are constructed and used to monitor economic activity. The selected indicators—Unemployment Rate, Industrial Production, and Retail Sales—collectively provide a comprehensive picture of the economy, aligning well with broader measures like the CFNAI.
This report is part of the coursework for the Pompea College of Business, University of New Haven. I would like to thank my professors and colleagues for their guidance throughout this project.