Here you can find some code and lecture notes on DSGE models. I wrote this material mainly to organize my code and consolidate my knowledge of DSGE models. I hope that sharing it can help young researchers set up a model or write the corresponding code. However, this material is by no means a substitute for a graduate course in macroeconomics or a textbook treatment of DSGE models.
These models are based on classic contributions to the macroeconomic literature, but they are not necessarily exact replicas. The impulse response functions generated by the models are intended for illustrative purposes only and do not necessarily provide a rigorous quantitative assessment of a given shock. Whenever possible, I use the same notation throughout the lecture notes: most variables are defined in the RBC or NK lecture notes.
For each model, click on the title to download a folder containing the Dynare code that simulates the model, an .m file that computes the steady state (console), and lecture notes in which I derive the equations of the model and explain how to compute the steady state. You should first run the .m file to save the parameters and compute the steady state of the model; then you can run the Dynare file. You can download Dynare here.
Here you can find the Dynare Reference Manual and the excellent forum managed by Prof. Johannes Pfeifer, where you can ask questions and find Dynare code for well-known DSGE models.
Comments and suggestions are welcome, especially if you find any inaccuracies or typos. Please email me at valerio.nispilandi@bancaditalia.it.
This model is a version of the RBC framework first developed by Kydland and Prescott (1982).
Price rigidities are introduced in the RBC framework described above, as in the textbook analysis by Woodford (2003) and Gali (2015).
This is a NK model with two agents, where only one of them has access to financial markets, along the lines of Gali, Lopez-Salido, and Valles (2007).
The NK model is augmented with a link between the economy and the environment, as in Heutel (2012) and Annicchiarico and Di Dio (2015), which in turn build on the DICE model by Nordhaus.
The NK model is augmented with an extensive margin for employment, as in the Search and Matching model of Diamond (1982) and Mortensen and Pissarides (1994) (DMP). The lecture notes and the code are a replica of Section 7 in Monacelli, Trigari, and Perotti (2010).
The NK framework is augmented with the banking sector of Gertler and Karadi (2011), in order to study QE policies.
I augment the NK model with trend growth and permanent TFP shocks. I show how to detrend non-stationary variables in order to make the solution of the model stationary.
The number of firms is made endogenous in the NK model, along the lines of Bilbiie, Ghironi, and Melitz (2012, 2019) and Bilbiie, Fujiwara, and Ghironi (2014) .
This is a model for a small open economy trading with the rest of the world, as in the textbook analysis by Uribe and Schmitt-Grohe (2017). Two versions are presented: in the first one international financial markets are complete, in the second one financial markets are incomplete.
A non-tradable good is introduced in the open-economy RBC model.
The open-economy RBC model is augmented with nominal rigidities, as in Gali and Monacelli (2005).
This is a model for the global economy featuring two countries, incomplete financial markets, and nominal rigidities, as in Benigno (2009).
I show how to simulate the transition to a green (zero-emission) economy assuming perfect foresight.
I show how to linearize and log-linearize equations of a DSGE model around the deterministic steady state.
I provide the intuition behind the Blanchard-Kahn conditions for solving DSGE models, providing some examples. I show how to solve a small DSGE model with the method of undetermined coefficients.
I explain the differences between the concepts of deterministic steady state, stochastic steady state, and ergodic mean in DSGE models. A .mod file shows how to compute these objects in Dynare.
I show how to write recursively the non-linear equations of the Calvo pricing model. In the Dynare code, I compare the Calvo and the Rotemberg frameworks.
I show how to optimize the parameters of a simple policy rule using Dynare.
The goal of these lecture notes is threefold. First, I show how to derive a second-order approximation of the baseline NK model, including a second-order approximation of the Phillips Curve. Second, I derive the quadratic welfare loss function, assuming that the steady-state distortion is small (as in Gali's textbook, Chapter 5). Third, I derive the quadratic welfare loss function, assuming that the steady-state distortion is not small (as in Benigno and Woodford, 2005).
In the Dynare code, I show how to compute the optimal policy conditional on a given policy instrument. In the lecture notes, I show how to compute the steady state of the model, conditional on the policy instrument, as required by the Dynare routines.