This report examines a unique diffusion index developed from three key economic indicators: the unemployment rate, retail sales, and new orders. The purpose is to analyze economic trends and shifts over time. To assess how effectively this custom index represents overall economic conditions, it is compared with the Chicago Fed National Activity Index - Diffusion Index (CFNAI-DIFF). This comparison provides insights into their relationship and what they indicate about the economy’s current state
# 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()`).
If the custom index shows a downward trend: This may signal a slowdown in economic activity, potentially driven by challenges such as reduced consumer demand, declining industrial production, or weaker employment figures. The trend could also reflect broader issues like increasing interest rates or global economic uncertainty.
The custom index is based on a limited set of economic indicators, resulting in weaker alignment with the more comprehensive CFNAIDIFF. Its heightened sensitivity to short-term variations introduces volatility, complicating its interpretation in the context of longer-term economic trends.
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.
If the custom index is stable or rising: This would suggest resilience in specific sectors, with positive contributions from retail sales, employment, and new orders.
The custom diffusion index provides valuable insights into economic fluctuations over time, with recent trends pointing to possible stabilization or recovery. However, its reliance on a limited set of variables reduces its alignment with the CFNAIDIFF, which offers a smoother and more comprehensive view of national economic activity.
The weak correlation (0.24) between the indices highlights the need for broader variable selection to improve reliability and comparability. Despite its limitations, the custom index is a useful tool for tracking specific economic dynamics and short-term changes. Future improvements could involve incorporating additional indicators and refining weighting methods to better align with established benchmarks like the CFNAIDIFF.