This report looks at a custom diffusion index created using three important economic indicators: the unemployment rate, retail sales, and new orders. The goal is to understand economic trends and changes over time. To see how well this custom index reflects broader economic conditions, it is compared to the Chicago Fed National Activity Index - Diffusion Index (CFNAIDIFF). This comparison helps evaluate their relationship and what they reveal about the current state of the economy.
# Load economic variables
getSymbols(c("RSXFS", "UNRATE", "NEWORDER"),
src = "FRED", return.class = 'xts',
from = "2010-01-01", to = Sys.Date())
## [1] "RSXFS" "UNRATE" "NEWORDER"
# Variables
retail_sales <- RSXFS
unemployment <- UNRATE
new_orders <- NEWORDER
# Restrict to common date range and preprocess
retail_sales_ss <- ts_ts(retail_sales["2010-01-31/2024-09-01"])
unemployment_ss <- ts_ts(unemployment["2010-01-31/2024-09-01"])
new_orders_ss <- ts_ts(new_orders["2010-01-31/2024-09-01"])
# Combine data
mydata <- cbind.data.frame(retail_sales_ss, unemployment_ss, new_orders_ss)
# Calculate first differences
mydf <- mydata %>%
mutate(
sales_diff = tsibble::difference(retail_sales_ss, differences = 1),
unemp_diff = tsibble::difference(unemployment_ss, differences = 1),
orders_diff = tsibble::difference(new_orders_ss, differences = 1)
) %>%
dplyr::select(sales_diff, unemp_diff, orders_diff) %>%
na.omit()
## Registered S3 method overwritten by 'tsibble':
## method from
## as_tibble.grouped_df dplyr
# Construct diffusion index
mydf_mat <- apply(mydf, 2, sign)
pos <- apply(mydf_mat, 1, function(row) sum(row > 0))
neg <- apply(mydf_mat, 1, function(row) sum(row < 0))
tot <- pos + neg
index <- (pos / tot - neg / tot) * 100
ma_index <- rollmean(index, 7, align = "right", na.pad = TRUE)
Date <- seq.Date(from = as.Date("2010-05-01"), length.out = length(index), by = "month")
diffusion_df <- cbind.data.frame(Date, index, ma_index)
# Plot the diffusion index
ggplot(diffusion_df, aes(x = Date, y = index)) +
geom_line(color = "navyblue", size = 0.8) +
geom_smooth(color = "red", fill = "lightblue", alpha = 0.3, size = 1.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "black") +
labs(
title = "Diffusion Index for Selected Economic Variables",
x = "Year",
y = "Diffusion Index (%)"
) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
# Load CFNAIDIFF
getSymbols("CFNAIDIFF", src = "FRED", return.class = 'xts', from = "2010-01-01")
## [1] "CFNAIDIFF"
cfnaidiff_ss <- ts_ts(CFNAIDIFF["2010-05-01/2024-09-01"])
# Align lengths for comparison
min_length <- min(length(ma_index), length(cfnaidiff_ss))
ma_index <- ma_index[1:min_length]
cfnaidiff_ss <- cfnaidiff_ss[1:min_length]
Date <- Date[1:min_length]
# Prepare comparison data
compare_df <- cbind.data.frame(Date, diffusion_index = ma_index, CFNAIDIFF = cfnaidiff_ss)
correlation <- cor(compare_df$diffusion_index, compare_df$CFNAIDIFF, use = "complete.obs")
# Plot the comparison
ggplot(compare_df, aes(x = Date)) +
geom_line(aes(y = diffusion_index, color = "Diffusion Index"), size = 1.2) +
geom_line(aes(y = CFNAIDIFF * 100, color = "CFNAIDIFF"), size = 1.2, linetype = "dashed") +
scale_color_manual(values = c("Diffusion Index" = "blue", "CFNAIDIFF" = "red")) +
labs(
title = "Comparison of Diffusion Index and CFNAIDIFF",
subtitle = paste("Correlation:", round(correlation, 2)),
x = "Year",
y = "Index Value",
color = "Legend"
) +
theme_minimal()
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_line()`).
Strengths of the Custom Diffusion Index The custom diffusion index effectively captures key economic dynamics and short-term fluctuations in retail sales, unemployment, and new orders. It shows some alignment with the CFNAIDIFF, as evidenced by a weak positive correlation (0.24), highlighting its ability to track broad economic trends in certain periods.
The custom index relies on a narrower set of economic variables, leading to less alignment with the comprehensive CFNAIDIFF. The high sensitivity to short-term changes introduces volatility, making it harder to interpret in the context of broader, long-term economic conditions.
If the custom index shows a downward trend after September 2024:
This could signal a weakening in economic activity, potentially linked to challenges in consumer demand, industrial production, or employment. Such a trend may reflect headwinds like rising interest rates or global economic uncertainty. If the custom index is stable or rising:
This suggests resilience in certain sectors of the economy, with positive contributions from retail sales, employment, and new orders.
The custom diffusion index highlights economic fluctuations over time, with recent trends indicating potential stabilization or recovery. However, its limited variable set leads to less alignment with the CFNAIDIFF, which captures broader national activity with smoother trends.
The weak correlation (0.24) between the indices emphasizes the need for a more comprehensive variable selection to enhance reliability and comparability. Nonetheless, the custom index offers valuable insights into specific economic areas and short-term changes. Future enhancements could include additional variables and refined weighting methods to improve its alignment with established benchmarks like the CFNAIDIFF.