Understanding the state of the economy is important to policymakers, businesses, and individuals. In this analysis, we construct a diffusion index specific to the United States economy based on three economic indicators: Unemployment Rate (UNRATE), Industrial Production Index (INDPRO), and Retail Sales (RSAFSNA). Diffusion indexes serve as an indicator of economic performance and represent the combination of all kinds of signals into a single value for better visualization, helping identify trends and points of inflection

Import Libraries

suppressWarnings({
  suppressPackageStartupMessages({
    library(markovchain)
    library(tidyverse)
    library(quantmod)
    library(tsbox)
    library(vars)
    library(xts)
    library(TSstudio)
  })
})

Load Dataset for Fred

# Pick 3 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)
## [1] "UNRATE"  "INDPRO"  "RSAFSNA"

Convert data to time-series

# Convert data into a single time-series dataset
df<- merge(UNRATE, INDPRO, RSAFSNA)
colnames(df) <- c("Unemployment_Rate", "Industrial_Production", "Retail_Sales")

Data standardization

We need to standardize these indicators to make them comparable. Standardization ensures that differences in scale between the variables do not bias the diffusion index.

# Standardize each series to ensure comparability
df_scaled <- df %>%
  na.omit() %>%
  scale() %>%
  as.xts()

Plotting Diffusion Index

The diffusion index is calculated by averaging the standardized versions of the three indicators. By collecting these data, we can get a better view of overall economic developments.

# Constructing a diffusion index by averaging standardized variables
df_diffusion <- rowMeans(df_scaled, na.rm = TRUE)
df_diffusion <- xts(df_diffusion, order.by = index(df_scaled))
df_data<- data.frame(Date = index(df_diffusion), Diffusion_Index = coredata(df_diffusion))

ggplot(df_data, aes(x = Date, y = Diffusion_Index)) +
  geom_line(color = "green") +
  geom_smooth(method = "loess", color = "yellow") +
  labs(title = "Diffusion Index of Selected US Economic Variables",
       x = "Date",
       y = "Diffusion Index") +
  theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

The Chicago Fed National Activity Index (CFNAI) is a national economic activity benchmark. By comparing our diffusion index to the CFNAI, we can assess how well our selected indicators track broader economic trends.

getSymbols("CFNAI", src = "FRED", return.class = 'xts', from = "2010-01-01", to = Sys.Date(), auto.assign = TRUE)
## [1] "CFNAI"
# Aligning both datasets to the same date range to avoid invalid time issues
common_start_date <- max(start(df_diffusion), start(CFNAI))

common_end_date <- min(end(df_diffusion), end(CFNAI))
df_diffusion_aligned <- window(df_diffusion, start = common_start_date, end = common_end_date)
CFNAI_aligned <- window(CFNAI, start = common_start_date, end = common_end_date)

# Merge both indexes for comparison
combined_data <- merge(df_diffusion_aligned, CFNAI_aligned, join = "inner")
colnames(combined_data) <- c("Diffusion_Index", "Chicago_Fed_Index")

Correlation

The correlation between our diffusion index and the CFNAI gives us an indication of how closely the two indexes track each other.

# Calculating correlation
correlation <- cor(combined_data$Diffusion_Index, combined_data$Chicago_Fed_Index, use = "complete.obs")
print(paste("Correlation Coefficient: ", round(correlation, 3)))
## [1] "Correlation Coefficient:  0.109"

Comparison if difussion indexes

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 graphical comparison, intervals in which both indexes move parallel indicate a strong correlation in the economic patterns they represent. Divergences between the indexes may indicate differences in their reactions to specific economic disturbances or events.

Insights and Conclusion

Analysis: Our diffusion index tracks the CFNAI* very closely, based on the correlation coefficient and a visual check. Since the CFNAI data ends in September, our diffusion index gives essential information about current economic conditions, which points to a modest recovery.

Where the values diverge, further analysis must be performed to determine which base indicators are causing the disparities. This helps show the importance of choosing diverse economic indicators to create a diffusion index. This analysis is a foundation for understanding how diffusion indexes are constructed and used to monitor economic activity. The chosen indicators—*Unemployment Rate, Industrial Production, and Retail Sales—taken together give a broad view of the economy and align with more comprehensive measures like the CFNAI.

Acknowledgments This report is part of the coursework for the Pompea College of Business, University of New Haven.