RepositoryPython
AlessiaPaccagnini

AlessiaPaccagnini/Macroeconometrics_book

Companion code repository for the textbook Macroeconometrics by Alessia Paccagnini, with Python, R, MATLAB and Dynare examples

106stars
46forks
0issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: estimation

#1 Repository of the week

1
TINIX TRENDING·Topic: identification

#1 Repository of the week

1
TINIX TRENDING·Topic: dsge

#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

ChapterTopicEmpirical exampleLanguages
1Univariate Time SeriesARIMA (Box-Jenkins), Cointegration & ECM, GARCH volatilityPython · R · MATLAB
2VAR ModelsVAR estimation & diagnostics, VECM, reduced-form IRFsPython · R · MATLAB
3Local ProjectionsMonetary policy shocks (LP vs smooth LP), fiscal multipliersPython · R · MATLAB
4Shock IdentificationCholesky VAR & Proxy SVAR for US monetary policyPython · R · MATLAB
5Bayesian EstimationBVAR for US monetary policyPython · R · MATLAB
6DSGE ModelsNew Keynesian model estimationDynare only
7ForecastingRW vs VAR vs BVAR — US GDP, inflation, interest ratesPython · R · MATLAB
8High DimensionalityFAVAR — US monetary policy with 100+ variablesPython · R · MATLAB
9Machine LearningML vs traditional methods — US GDP/inflation forecastingPython · R · MATLAB
10Time-Varying & NonlinearTVP-VAR, MS-VAR, STVARPython · R · MATLAB
11Mixed-Frequency DataMIDAS, MF-VARPython · R · MATLAB
12Quantile Regression & GaRGrowth-at-Risk, quantile VARPython · R · MATLAB
13Multi-Country MethodsPanel 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:

PatternContent
figure_chXX_*.{py,R,m}Replicates a specific figure from Chapter XX
empirical_example_*.{py,R,m}Implements a chapter empirical example
ex*_data.csvDataset 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.

RepositoryPython
Nixtla/statsforecast

Lightning ⚡️ fast forecasting with statistical and econometric models.

5.0k
Nov 23, 2026
RepositoryJulia
JuliaControl/ControlSystemIdentification.jl

System Identification toolbox, compatible with ControlSystems.jl

154
Nov 24, 2026
RepositoryMATLAB
wmutschl/dsge

Course on Dynamic Stochastic General Equilibrium (DSGE): Models, Solution, Estimation (graduate level)

101
Apr 8, 2022
Modeltime-series-forecasting
autogluon/chronos-2

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/...

♥0
80.6M
Jun 5, 2026
RepositoryTypeScript
firecrawl/firecrawl

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.

215.1k
Dec 2, 2026
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

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...

♥0
157.6M
Jun 1, 2026
Repository
getify/You-Dont-Know-JS

A book series (2 published editions) on the JS language.

184.8k
Oct 31, 2026
RepositoryPython
soxoj/maigret

🕵️‍♂️ Collect a dossier on a person by username from 6K websites

41.5k
Dec 1, 2026
RepositoryPython
meta/prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

20.5k
Nov 24, 2026