Repository: https://github.com/chirindaopensource/regime_changes_real_financial_cycles
Owner: 2025 Craig Chirinda (Open Source Projects)
This repository contains an independent, professional-grade Python implementation of the research methodology from the 2025 paper entitled "Regime Changes and Real-Financial Cycles: Searching Minsky's Hypothesis in a Nonlinear Setting" by:
- Domenico Delli Gatti
- Filippo Gusella
- Giorgio Ricchiuti
The project provides a complete, end-to-end computational framework for replicating the paper's findings. It delivers a modular, auditable, and extensible pipeline that executes the entire research workflow: from rigorous data validation and spectral decomposition to the core nonlinear Markov-Switching Vector Autoregression (MS-VAR) estimation, Minsky regime classification, and Monte Carlo robustness analysis.
- Introduction
- Theoretical Background
- Features
- Methodology Implemented
- Core Components (Notebook Structure)
- Key Callable:
execute_minsky_research_project - Prerequisites
- Installation
- Input Data Structure
- Usage
- Output Structure
- Project Structure
- Customization
- Contributing
- Recommended Extensions
- License
- Citation
- Acknowledgments
This project provides a Python implementation of the analytical framework presented in Delli Gatti, Gusella, and Ricchiuti (2025). The core of this repository is the iPython Notebook regime_changes_real_financial_cycles_draft.ipynb, which contains a comprehensive suite of functions to replicate the paper's findings. The pipeline is designed to be a generalizable toolkit for detecting endogenous financial fragility and nonlinear regime shifts in macroeconomic data.
The paper investigates Minsky's Financial Instability Hypothesis (FIH) by extending linear models to a nonlinear setting. It captures local real-financial endogenous cycles where stability breeds instability. This codebase operationalizes the paper's framework, allowing users to:
- Rigorously validate and manage the entire experimental configuration via a single
config.yamlfile. - Process raw macroeconomic time series, applying Hodrick-Prescott (HP) filtering to extract cyclical components.
- Estimate a bivariate Markov-Switching Vector Autoregression (MS-VAR) model to distinguish between "Minsky" (interaction) and "No Minsky" (independence) regimes.
- Empirically verify the mathematical conditions for endogenous oscillations (complex eigenvalues) and Minskyan feedback loops.
- Trace the evolution of financial fragility over time using filtered and smoothed regime probabilities.
- Validate the robustness of findings via parametric bootstrap Monte Carlo simulations.
- Automatically generate all key tables and figures from the paper.
The implemented methods are grounded in nonlinear dynamic macroeconomic modeling and time series econometrics.
1. The Minsky Cycle Mechanism:
The core hypothesis is that financial fragility builds endogenously during expansions. This is captured by a dynamic interaction between a real variable (
-
$\beta_1 > 0$ : Economic expansion leads to rising debt/interest rates (pro-cyclical leverage). -
$\alpha_2 < 0$ : Rising financial fragility drags down real activity. -
Oscillation Condition: The discriminant
$\Delta = (\alpha_1 - \beta_2)^2 + 4\alpha_2\beta_1 < 0$ , implying complex eigenvalues and endogenous cycles.
2. Regime Switching:
The economy transitions between the interaction regime and an independence regime (
3. Estimation Strategy: The model is estimated using the Expectation-Maximization (EM) Algorithm, which iteratively maximizes the likelihood function. The Hamilton Filter is used for the Expectation step to infer the latent state probabilities, and the Kim Smoother provides the optimal inference using the full sample.
Below is a diagram which sums up the Inputs-Processes-Outputs of the proposed approach:
The provided iPython Notebook (regime_changes_real_financial_cycles_draft.ipynb) implements the full research pipeline, including:
- Modular, Multi-Task Architecture: The entire pipeline is broken down into 24 distinct, modular tasks, each with its own orchestrator function.
- Configuration-Driven Design: All study parameters are managed in an external
config.yamlfile. - Rigorous Data Validation: A multi-stage validation process checks the schema, temporal consistency, and domain constraints of all input data.
- Advanced Signal Extraction: Implements a sparse-matrix version of the Hodrick-Prescott filter for efficient cycle extraction.
- Robust Econometric Engine: A custom EM algorithm implementation with numerical safeguards (regularization, log-sum-exp) for stable MS-VAR estimation.
- Comprehensive Diagnostics: Includes Ljung-Box residual tests and rigorous eigenvalue analysis for Minsky condition verification.
- Monte Carlo Robustness: A fully integrated parametric bootstrap module to assess the stability of parameter estimates and regime classifications.
- Automated Reporting: Generates publication-ready LaTeX tables and technical documentation.
The core analytical steps directly implement the methodology from the paper:
- Validation & Preprocessing (Tasks 1-4): Ingests raw data, validates schemas, cleanses missing values via interpolation/truncation, and applies logarithmic transformations.
-
Signal Extraction (Task 5): Applies the HP filter (
$\lambda=100$ ) to extract stationary cyclical components from annual data. - Model Setup (Tasks 6-10): Constructs bivariate systems, verifies stationarity via ADF tests, and initializes EM parameters using baseline VAR estimates.
- Estimation (Tasks 11-15): Executes the EM algorithm, utilizing the Hamilton Filter and Kim Smoother to estimate regime-dependent parameters and state probabilities.
- Diagnostics & Analysis (Tasks 16-18): Validates residuals, checks mathematical conditions for Minsky cycles (eigenvalues, signs), and analyzes regime dominance over time.
- Robustness & Synthesis (Tasks 19-24): Runs Monte Carlo simulations, cross-validates against paper benchmarks, and compiles the final report.
The regime_changes_real_financial_cycles_draft.ipynb notebook is structured as a logical pipeline with modular orchestrator functions for each of the 24 major tasks. All functions are self-contained, fully documented with type hints and docstrings, and designed for professional-grade execution.
The project is designed around a single, top-level user-facing interface function:
execute_minsky_research_project: This master orchestrator function, located in the final section of the notebook, runs the entire automated research pipeline from end-to-end. A single call to this function reproduces the entire computational portion of the project.
- Python 3.9+
- Core dependencies:
pandas,numpy,pyyaml,scipy,statsmodels,matplotlib.
-
Clone the repository:
git clone https://github.com/chirindaopensource/regime_changes_real_financial_cycles.git cd regime_changes_real_financial_cycles -
Create and activate a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install Python dependencies:
pip install pandas numpy pyyaml scipy statsmodels matplotlib
The pipeline requires a dictionary of DataFrames (raw_datasets) where keys are country names and values are DataFrames with a DatetimeIndex (annual frequency) and the following columns:
real_gdp: Real Gross Domestic Product.nfcd: Non-financial Corporate Debt.household_debt: Household Debt.stir: Short-Term Interest Rate.
All other parameters are controlled by the config.yaml file.
The regime_changes_real_financial_cycles_draft.ipynb notebook provides a complete, step-by-step guide. The primary workflow is to execute the final cell of the notebook, which demonstrates how to use the top-level execute_minsky_research_project orchestrator:
# Final cell of the notebook
# This block serves as the main entry point for the entire project.
if __name__ == '__main__':
# 1. Load the master configuration from the YAML file.
with open('config.yaml', 'r') as f:
study_config = yaml.safe_load(f)
# 2. Load or generate raw datasets (Example using synthetic generator)
# In production, load from CSV/Parquet: pd.read_csv(...)
raw_datasets = load_country_data()
# 3. Execute the entire replication study.
final_results = execute_minsky_research_project(
study_config=study_config,
raw_datasets=raw_datasets
)
# 4. Access results
print(final_results["master_results"]["analysis"]["minsky_conditions"])The pipeline returns a comprehensive dictionary containing all analytical artifacts, structured as follows:
-
master_results: The aggregated dictionary of all outputs.-
estimation: Contains estimated parameters ($A, \Sigma, P$ ) for all models. -
diagnostics: Ljung-Box test results. -
analysis: Minsky condition verification and regime probabilities. -
robustness: Monte Carlo simulation statistics. -
validation: Cross-validation report against paper benchmarks.
-
-
latex_tables: Ready-to-compile LaTeX code for parameter estimates and classification tables. -
technical_appendix: A markdown summary of implementation choices.
regime_changes_real_financial_cycles/
│
├── regime_changes_real_financial_cycles_draft.ipynb # Main implementation notebook
├── config.yaml # Master configuration file
├── requirements.txt # Python package dependencies
│
├── data/ # Directory for raw data (optional)
│ ├── usa_macro_data.csv
│ └── ...
│
├── LICENSE # MIT Project License File
└── README.md # This file
The pipeline is highly customizable via the config.yaml file. Users can modify study parameters such as the HP filter lambda, convergence tolerances, Monte Carlo iterations, and statistical thresholds without altering the core Python code.
Contributions are welcome. Please fork the repository, create a feature branch, and submit a pull request with a clear description of your changes. Adherence to PEP 8, type hinting, and comprehensive docstrings is required.
Future extensions could include:
- Alternative Filtering: Implementing the Hamilton regression filter or Baxter-King filter as alternatives to HP.
- Model Selection: Adding information criteria (AIC/BIC) to select the optimal number of regimes or lags.
- Time-Varying Transition Probabilities: Extending the MS-VAR to allow transition probabilities to depend on exogenous variables (TVTP-MS-VAR).
This project is licensed under the MIT License. See the LICENSE file for details.
If you use this code or the methodology in your research, please cite the original paper:
@article{delligatti2025regime,
title={Regime Changes and Real-Financial Cycles: Searching Minsky's Hypothesis in a Nonlinear Setting},
author={Delli Gatti, Domenico and Gusella, Filippo and Ricchiuti, Giorgio},
journal={arXiv preprint arXiv:2511.04348},
year={2025}
}For the implementation itself, you may cite this repository:
Chirinda, C. (2025). Regime Changes and Real-Financial Cycles: An Open Source Implementation.
GitHub repository: https://github.com/chirindaopensource/regime_changes_real_financial_cycles
- Credit to Domenico Delli Gatti, Filippo Gusella, and Giorgio Ricchiuti for the foundational research that forms the entire basis for this computational replication.
- This project is built upon the exceptional tools provided by the open-source community. Sincere thanks to the developers of the scientific Python ecosystem, including Pandas, NumPy, SciPy, Statsmodels, and Matplotlib.
--
This README was generated based on the structure and content of the regime_changes_real_financial_cycles_draft.ipynb notebook and follows best practices for research software documentation.
