AlessiaPaccagnini/Macroeconometrics_book
Companion code repository for the textbook Macroeconometrics by Alessia Paccagnini, with Python, R, MATLAB and Dynare examples
Featured achievements
The project's latest awards
#1 Repository of the week
#1 Repository of the week
#1 Repository of the week
Macroeconometrics — Companion Code Repository
Alessia Paccagnini
Macroeconometrics
Citation
If you use these codes in your research or teaching, please cite:
Paccagnini, A. (forthcoming). Macroeconometrics. De Gruyter.
Companion code repository:
Paccagnini, A. (2026). Macroeconometrics — Companion Code Repository (Version v1.0.0) [Software]. Zenodo. https://doi.org/10.5281/zenodo.20739680
About this repository
This repository contains the companion code for the textbook Macroeconometrics (De Gruyter). It is still in progress and some codes will be changed, fixed or replaced in the next few weeks. Further material will be also added as companion for the book.
It is organised into two types of material:
- Figure replication codes — scripts that reproduce every figure appearing in each chapter, using the simulated or calibrated datasets described in the text.
- Empirical example codes — scripts that implement the applied examples at the end of each chapter, where the methods are taken to real macroeconomic data.
All codes are provided in three languages: Python, R, and MATLAB. The only exception is Chapter 6 (DSGE Models), whose empirical examples use Dynare (a dedicated MATLAB/Octave toolbox for DSGE estimation), as is standard practice in the field.
Data required to run the empirical examples are included in the repository alongside the code.
This repository is actively maintained. Further codes, datasets, and supplementary materials will be continuously added as the book goes to press.
About the Companion Slides These slides are designed as a flexible starting point for teaching and studying Macroeconometrics. They summarize the core concepts and selected examples from each chapter rather than reproducing the full content of the book. Users are encouraged to adapt and enrich the slides with their own explanations, empirical applications, datasets, exercises, and additional material. The editable LaTeX/Overleaf source is provided precisely for this purpose. Make them yours: add your examples, applications, exercises, and discussion questions.
Acknowledgment
Special thanks to Kelvin Marcano for carefully reviewing the companion code and for identifying potential bugs and reproducibility issues that helped improve the codebase.
Repository structure
Macroeconometrics_book/
│
├── Chapter_01_Univariate/
│ ├── figures/ # Figure replication
│ └── empirical/ # Empirical examples
│ ├── example1_arima.{py,R,m} # ARIMA: Box-Jenkins methodology
│ ├── example2_cointegration.{py,R,m} # Spurious regression & ECM
│ └── example3_garch.{py,R,m} # GARCH volatility dynamics
│
├── Chapter_02_VAR/
│ ├── figures/
│ └── empirical/ # VAR estimation, diagnostics, IRFs, VECM
│
├── Chapter_03_LocalProjections/
│ ├── figures/
│ └── empirical/ # Monetary policy shocks (LP vs smooth LP)
│ # State-dependent fiscal multipliers
│
├── Chapter_04_ShockIdentification/
│ ├── figures/
│ └── empirical/ # Cholesky VAR & Proxy SVAR (US monetary policy)
│
├── Chapter_05_BayesianEstimation/
│ ├── figures/
│ └── empirical/ # BVAR: US monetary policy application
│
├── Chapter_06_DSGE/
│ ├── figures/
│ └── empirical/ # ⚠️ Dynare only (see note below)
│
├── Chapter_07_Forecasting/
│ ├── figures/
│ └── empirical/ # RW, VAR, BVAR forecast comparison (US GDP/inflation)
│
├── Chapter_08_HighDimensionality/
│ ├── figures/
│ └── empirical/ # FAVAR: US monetary policy with large information set
│
├── Chapter_19_MachineLearning/
│ ├── figures/
│ └── empirical/ # ML vs traditional forecasting (US GDP/inflation)
│
├── Chapter_10_TimeVaryingNonlinear/
│ ├── figures/
│ └── empirical/
│
├── Chapter_11_MixedFrequency/
│ ├── figures/
│ └── empirical/
│
├── Chapter_12_QuantileGaR/
│ ├── figures/
│ └── empirical/
│
├── Chapter_13_MultiCountry/
│ ├── figures/
│ └── empirical/
│ ├── empirical_example_PanelVAR.{py,R,m} # Panel VAR: oil price shocks
│ └── empirical_example_GlobalVAR.{py,R,m} # GVAR: US monetary policy spillovers
│
└── data/ # All datasets used across chapters
Empirical examples by chapter
| Chapter | Topic | Empirical example | Languages |
|---|---|---|---|
| 1 | Univariate Time Series | ARIMA (Box-Jenkins), Cointegration & ECM, GARCH volatility | Python · R · MATLAB |
| 2 | VAR Models | VAR estimation & diagnostics, VECM, reduced-form IRFs | Python · R · MATLAB |
| 3 | Local Projections | Monetary policy shocks (LP vs smooth LP), fiscal multipliers | Python · R · MATLAB |
| 4 | Shock Identification | Cholesky VAR & Proxy SVAR for US monetary policy | Python · R · MATLAB |
| 5 | Bayesian Estimation | BVAR for US monetary policy | Python · R · MATLAB |
| 6 | DSGE Models | New Keynesian model estimation | Dynare only |
| 7 | Forecasting | RW vs VAR vs BVAR — US GDP, inflation, interest rates | Python · R · MATLAB |
| 8 | High Dimensionality | FAVAR — US monetary policy with 100+ variables | Python · R · MATLAB |
| 9 | Machine Learning | ML vs traditional methods — US GDP/inflation forecasting | Python · R · MATLAB |
| 10 | Time-Varying & Nonlinear | TVP-VAR, MS-VAR, STVAR | Python · R · MATLAB |
| 11 | Mixed-Frequency Data | MIDAS, MF-VAR | Python · R · MATLAB |
| 12 | Quantile Regression & GaR | Growth-at-Risk, quantile VAR | Python · R · MATLAB |
| 13 | Multi-Country Methods | Panel VAR (oil shocks), GVAR (US monetary policy spillovers) | Python · R · MATLAB |
Software requirements
Python
numpy, pandas, matplotlib, scipy, statsmodels, scikit-learn
Install all at once:
pip install numpy pandas matplotlib scipy statsmodels scikit-learn
R
vars, MTS, rugarch, quantreg, forecast, ggplot2, tsDyn
Install all at once:
install.packages(c("vars","MTS","rugarch","quantreg","forecast","ggplot2","tsDyn"))
MATLAB
Requires the Econometrics Toolbox and Statistics and Machine Learning Toolbox.
Chapter 13 multi-country codes run on base MATLAB with no additional toolboxes.
Dynare (Chapter 7 only)
Dynare 6.x, freely available at www.dynare.org.
Compatible with MATLAB R2019b+ and Octave 7+.
File naming conventions
Each script is self-contained and follows a consistent naming pattern:
| Pattern | Content |
|---|---|
figure_chXX_*.{py,R,m} | Replicates a specific figure from Chapter XX |
empirical_example_*.{py,R,m} | Implements a chapter empirical example |
ex*_data.csv | Dataset used by the corresponding example |
Every script includes a header block with the chapter reference, textbook equation number, and a brief description of the method implemented.
A note on Chapter 7 (DSGE)
DSGE model estimation requires Dynare, which provides a purpose-built preprocessor and solver that cannot be replicated straightforwardly in general-purpose Python or R scripts. The Chapter 7 empirical example files (.mod format) are Dynare-native and are documented separately in the chapter's software appendix. For installation and usage guidance see www.dynare.org/documentation.
Citation
If you use these codes in your research or teaching, please cite:
Paccagnini, A. (2026). Macroeconometrics. De Gruyter.
Contact and updates
Maintained by Alessia Paccagnini — https://sites.google.com/site/alessiapaccagnini/
Further materials — including additional datasets, solutions to exercises, and codes for the appendix chapters — will be continuously added to this repository.
Similar Projects
Discover other similar projects and AI models.
Lightning ⚡️ fast forecasting with statistical and econometric models.
System Identification toolbox, compatible with ControlSystems.jl
Course on Dynamic Stochastic General Equilibrium (DSGE): Models, Solution, Estimation (graduate level)
Chronos-2 Update Jun 5, 2026: ☁️ Deploy Chronos-2 on AWS with AutoGluon-Cloud. Real-time, serverless, or batch inference in 3 lines of code — pandas DataFrames in, forecasts out. Check out the new deployment guide(https://auto.gluon.ai/cloud/stable/...
Firecrawl is the knowledge infrastructure to make your agents smarter. It connects your agents to the web, and to Alexandria, our library of everything else.
all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...
Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.