Predicting the Likelihood of a Potential Impending Recession - Here’s What the Data Says
Автор: Analytics in Practice
Загружено: 2026-02-16
Просмотров: 16
Описание: Debates about whether a recession is coming soon, already here, or avoidable can be informed by building a data-driven forecasting pipeline. The workflow starts by defining a clear recession target such as whether a recession begins within the next 6, 12, 18, or 24 months. Next, it assembles a feature set of classic leading indicators from FRED, including the term spread, credit spreads, initial claims, financial conditions, equity returns, volatility, and housing activity. The code shows two reliable ways to pull these time series: a retry-safe pandas_datareader session and a direct FRED API approach using an API key stored outside the script. All series are resampled to a common monthly frequency, engineered into interpretable predictors (spreads, 3-month returns, YoY housing growth), and aligned to a forward-shifted recession label to avoid look-ahead bias. A rolling-window logistic regression is then fit to track how each feature’s coefficient behaves over time. Stability is assessed using sign flips (when coefficients change direction) and magnitude jumps (when coefficients shift sharply), where stable indicators tend to keep the same sign and similar scale across windows. Because raw coefficients can be distorted by scaling, an L2-regularized logistic model with standardization is also used to make drift comparisons more meaningful. The analysis also addresses real-time reliability by checking revision risk using ALFRED-style vintages, favoring indicators with small revisions and high first-vs-latest agreement. Finally, performance stability is evaluated with rolling out-of-sample testing (10-year train, 2-year test) using AUC when enough recession months exist and Brier scores for probability accuracy, and the pipeline ends by producing horizon-based recession probabilities and Plotly charts that visualize recession shading, coefficient drift, sign-flip counts, and probability signals over time.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: