

This repository contains the Python code used to generate all statistical results and figures presented in the manuscript "Climate Shocks and Regime Dependence: A Structural Analysis of Macroeconomic Stability in the MENA Region". The code provides a complete replication package for the empirical analysis, enabling researchers to verify and build upon the findings.
The code implements a comprehensive empirical strategy including:
MENA Climate Risk Index (MCRI): Construction of a composite climate shock index using Principal Component Analysis (PCA) integrating temperature anomalies, rainfall deviations, and SPEI-12 drought intensity.
Unit Root and Cointegration Tests: Augmented Dickey-Fuller (ADF), Kwiatkowski-Phillips-Schmidt-Shin (KPSS), and Engle-Granger tests to establish integration and cointegration properties.
Linearity Tests: Comparison of linear VAR and Markov-switching VAR using AIC and BIC criteria.
Tunisia VAR: Linear structural VAR with Cholesky decomposition to compute impulse response functions for GDP growth, inflation, and FDI.
Egypt MS-AR: Univariate Markov-switching autoregressive models for GDP growth, inflation, and FDI, capturing regime-dependent dynamics.
Robustness Checks: Alternative lag lengths, subsample analysis, and alternative climate index specifications.
Figure Generation: All main text and appendix figures in publication-ready format.
Supplementary_Code.zip ├── README.txt # Instructions and file descriptions ├── requirements.txt # Python package dependencies ├── 01_data_preprocessing.py # Data loading, MCRI construction, normalization ├── 02_unit_root_tests.py # ADF, KPSS, PP tests ├── 03_cointegration_tests.py # Engle-Granger and Johansen tests ├── 04_linearity_tests.py # Linearity tests (AIC comparison) ├── 05_tunisia_var.py # Linear VAR for Tunisia (Figure 4) ├── 06_egypt_ms_ar.py # MS-AR models for Egypt (Figures 5-6) ├── 07_appendix_figures.py # Appendix A and F figures ├── 08_robustness_checks.py # Alternative specifications └── 09_main_figures.py # Main text figures (Figures 1-3)
Python 3.8 or higher
Dependencies listed in requirements.txt
Install with:
pip install -r requirements.txt
Run the scripts in numerical order:
python 01_data_preprocessing.py python 02_unit_root_tests.py python 03_cointegration_tests.py python 04_linearity_tests.py python 05_tunisia_var.py python 06_egypt_ms_ar.py python 07_appendix_figures.py python 08_robustness_checks.py python 09_main_figures.py
The code uses publicly available data from:
Climate data: Climatic Research Unit (CRU TS v4.0), SPEI Global Database
Macroeconomic data: World Bank World Development Indicators (WDI)
Institutional data: Varieties of Democracy (V-Dem), Worldwide Governance Indicators (WGI)
Processed panel data are generated by the 01_data_preprocessing.py script.
Figures: Saved as PNG and PDF in the current directory
Tables: Printed to console and saved as Excel files
Results: Excel files containing unit root, cointegration, and linearity test results
This code is released under the MIT License.