Solving DSGE models
Macro II - Fluctuations - ENSAE, 2024-2025
Introduction
What is the main specificity of economic modeling?
In (macro)economics, we model the behaviour of economic agents by specifying:
- their objective
- their constraints (budget constraint, econ. environment…)
. . .
This has important implications:
- macro models are forward looking
- rely on expectations
- macro models need to be solved
In many cases, there is no closed form for the solution -> we need numerical techniques
Dynare
- 1996: Michel Juillard created an opensource software to solve DSGE models
- DSGE: Dynamic Stochastic General Equilibrium
- usually solved around a steady-state
- Now about 10 contributors.
power users who have contributed to the code
- It has been widely adopted:
- early version in Gauss
- then Matlab/Octave/Scilab
- latest version in Julia
- … and Python (checkout dyno 🦖)
DSGE Models in institutions
Nowadays most DSGE models built in institutions have a Dynare version (IMF/GIMF, EC/Quest, ECB/, NYFed/FRBNY)
- they are usually based on the midsize model from Smets & Wouters (10 equations)
- but have grown up a lot (>>100 equations)
. . .
Institutions, led by researchers are diversifying their model
- Semi-Structural Models
- Computational General Equilibrium Models
- Network Models
- Agent-based Models
- Heterogenous Agents Models
The Plan
Provide a short introduction to DSGE modeling:
- How models are solved (today)
- Small Open Economy (aka IRBC model)
- Heterogeneity
- Financial Intermediation
In passing, we’ll discuss some of the trends
Solving a model
Model
A very concise representation of a model
The problem:
: the vector of endogenous variables : the vector of exogenous variables- we assume that
is a zero-mean gaussian process
- we assume that
: the model equations
The solution:
such that
The situation is different when one is making a perfect foresight simulation.
The timing of the equations
In a dynare modefile the model equations are coded in the model; ... ; end;
block.
Variable v
or v(0)
(resp v(-1)
, v(+1)
).
General Timing Convention
New information arrives with the innovations
At date
By convention an endogenous variable has a subscript
. . .
Several variable types depending on how they appear in the model:
- jump variable: appear
or - predetermined variable: appear in
and (possibly ) - static variables: appear in
only- can be expressed as a function of other variables
The timing of equations
Example
Using Dynare’s timing conventions:
Write the production function in the RBC
Write the law of motion for capital
, with a depreciation rate and investment- when is capital known?
- when is investment known?
Add a multiplicative investment efficiency shock
. Assume it is an driven by innovation and autocorrelation- how do you write the law of motion for capital?
Steady-state
The deterministic steady-state satisfies:
Often, there is a closed-form solution.
Otherwise, one must resort to a numerical solver to solve
In dynare the steady-state values are provided in the steadystate_model; ... ; end;
block. One can check they are correct using the check;
statement.
To find numerically the steady-state: steady;
.
The implicit system
Replacing the solution
we obtain:
It is an equation defining implicitly the function
The state-space
In this expression,
- it contains all information available at
to predict the future evolution of
. . .
Dropping the time subscripts, the equation must be satisfied for any realization of
It is a functional equation
Expected shocks
First order approximation:
- Assume
,
Perform a Taylor expansion with respect to future shock:
. . .
This uses the fact that
At first order, expected shocks play no role.
To capture precautionary behaviour (like risk premia), we would need to increase the approximation order.
First order perturbation
We are left with the system:
A variant of the implicit function theorem then yields the existence of a first approximation of
. . .
Unknown quantities
Computing
Recall the system:
We have
. . .
First Order Deterministic Model
Let’s pause a minute to observe the first order deterministic model:
From our intuition in dimension 1, we know there must be multiple solutions
- how do we find them?
- how do we select the right ones?
I the absence of shocks the dynamics of the model are given by
What is the condition for the model to be stationary?
. . .
-> the biggest eigenvalue of
Develop intuition in dimension 1.
Multiplicity of solution
It is possible to show that the system is associated with
For each choice
. . .
This yields at least
. . .
A model is well defined when there is exactly one solution that is non divergent.
This is equivalent to:
Example 1
Forward looking inflation:
Is it well defined?
. . .
We can rewrite the system as:
or
. . .
The generalized eigenvalues are
. . .
The unique stable solution is
Example 2
Debt accumulation equation by a rational agent:
Is it well-defined?
. . .
Two generalized eigenvalues
. . .
The unique non-diverging solution is
- it is a unit-root: any initial deviation in
has persistent effects
Example 3
Productivity process:
. . .
In that case there is a hidden infinite eigenvalue
. . .
To see why consider the system associated with eigenvalues
Which corresponds to the initial model when
. . .
The generalized eigenvalues are
More generally, any variable that does not appear in
A criterium for well-definedness
Looking again at the list of eigenvalues we set aside the infinite ones.
The model is well specified iff we can sort the eigenvalues as:
The model satisfies the Blanchard-Kahn criterium if the number of eigenvalues greater than one, is exactly equal to the number of variables appearing in
In that case the model is well-defined.
Computing the solution
There are several classical methods to compute the solution to the algebraic Riccatti equation:
- qz decomposition
- traditionnally used in the DSGE literature since Chris Sims
- a little bit unintuitive
- cyclic reduction
- new default in dynare, more adequate for big models
- linear time iteration cf @sec:linear_time_iteration
- conceptually very simple
Computing
Now we have
Recall:
We have
Now this is easy:
The model solution
The result of the model solution:
It is an AR1, driven by exogenous shock
. . .
Because it is a well known structure, one can investigate the model with
- impulse response functions
- stochastic simulations
. . .
Then to compare the model to the data we compute
- implied moments:
- covariances, autocorrelation
- likelihood
Optimizing the fit to the data is called model estimation
Conclusion
What can you do with the solution
The solution of a model found by Dynare has an especially simple form: an AR1
- where the covariances
of can be chosen by the modeler
. . .
With this solution we can (cf next TD)
- compute (conditional and unconditional) moments
- perform stochastic simulations, impulse response function
. . .
Going Further
Taking the model to the data with Dynare
- “estimate” the model: compute the likelihood of a solution and maximize it by choosing the right parameters
- “identify” shocks in the data
Other functions
- higher order approximation
- (noninear) perfect foresight simulations
- ramsey plan
- discretionary policy
- …
Coming Next
Many models
Appendix: Linear Time Iteration
Linear Time Iteration
Recall the system to solve:
but now assume the decision rules today and tomorrow are different:
- today:
- tomorrow:
Then the Ricatti equation is written:
Linear Time Iteration (2)
The linear time iteration algorithm consists in solving the decision rule
This corresponds to the simple formula:
And the full algorithm can be described as:
- choose
- for any
, compute- repeat until convergence
Linear Time Iteration (3)
It can be shown that, starting from a random initial guess, the linear time-iteration algorithm converges to the solution
In other words, it finds the right solution when the model is well specified.
How do you check it is well specified?
is the biggest eigenvalue of solution- what about
? is the biggest eigenvalue of
Linear Time Iteration (4)
Define
For any solution
and
By construction
Linear Time Iteration (5)
For
In words,
In particular,
Footnotes
Special case of Bezout theorem. Easy to check in that case↩︎