Dsge All
Dsge All
Dsge All
Modelling
Alina Barnett
Martin Ellison
1
Practical DSGE modelling
Bank of England
December 2005
Overview
Course objectives
Understand the economic foundations of dynamic models and how they relate
to current policy issues
Be able to write dynamic models in a general form suitable for solution and
simulation by computer
Implement basic solution and simulation techniques to analyse dynamic
models, showing how the model economies behave and how they respond to
different shocks
Be aware of how to extend simple models to answer more complex questions
associated with monetary policy
Feel confident in discussing model-based analysis, evaluating the strength of
models used and engaging in conversation with people building economic
models
Organisation
The course runs over a series of five mornings. Each session will be a mixture of
small-group teaching and practical exercises using MATLAB software to solve and
simulate dynamic models. Afternoons are therefore free, allowing participants time to
reflect and consolidate the morning work before the next session. The instructors will
be available throughout each afternoon to answer any questions or queries that arise.
Pre-readings
Some pre-course readings will be assigned for those participants who wish to prepare
in advance. The issues involved in the pre-reading will be dealt with in the course so
there is no need to understand everything. The pre-reading is as much about getting
participants to gauge what they do and dont understand as it is to get ideas and issues
across.
2
Ouline
In this session we describe the key ingredients in a dynamic model, using the
simplest available dynamic model with monetary policy.
We show how to rewrite the model in a form suitable for solving and
simulating on a computer. There are two parts to this: (i) approximating the
nonlinear model by a linear model and (ii) collecting the equations together
into the so-called state-space form.
The computer exercises take participants from the state-space form to the
solution to the model and show the relevance of determinacy conditions.
Session 4 Simulation techniques
Having obtained the solution in the previous session, this session is devoted
to developing a range of simulation techniques through which to analyse the
model. Amongst others, we discuss stylised facts of volatilities and
correlations at different leads and lags, impulse response analysis, forecast
error variance decomposition.
In the final session we survey some of the more advanced dynamic models
that are useful for policy analysis. In particular, we focus on how to handle
models with simple monetary policy rules such as those famously associated
with Taylor.
The exercises in the final session consolidate the work of the previous
sessions. The participants will work through a series of exercises which
simulate the behaviour of a dynamic economy under Taylor rules. Time
permitting, participants will be able to analyse the response of the economy
for different coefficients in the monetary policy rules.
3
Instructors
Martin has an MPhil from Oxford University and a PhD from the European
University Institute, Florence. He is an affiliate of the Centre for Economic Policy
Research and a consultant at the Bank of England. His research focuses on monetary
theory and monetary policy and he has just received a three-year ESRC Research
Fellowship for his project Improving Monetary Policy for Macroeconomic Stability
in the 21st Century. His research is regularly published in the top academic journals,
as well as presented at leading conferences and central banks.
4
Practical DSGE
modelling
Alina Barnett
Martin Ellison
Objective
5
Aims
Organisation
Five mornings
6
Outline
Day Topics
3 Solution techniques
4 Simulation techniques
Introduction to
DSGE modelling
Martin Ellison
University of Warwick and CEPR
7
Dynamic
Stochastic
General Equilibrium
Dynamic
t-1 t t+1
expectations
8
Stochastic
Frisch-Slutsky paradigm
Impulses
Propagation
Fluctuations
General equilibrium
Monetary
authority
Firms Households
9
Households
Households characterised by
utility maximisation
consumption smoothing
Households
We show household consumption behaviour in a
simple two-period deterministic example with no
uncertainty
initial wealth W0
consumption C0 and C1
prices p0 and p1
nominal interest at rate i0 on savings from t0 to t1
10
Household utility
C
1 max U (C ) + U (C )
C0 0 1
dC1 U ' (C )
= 0
U dC0 U ' (C )
1
C
0
p1dC1 = p0 dC0 (1 + i0 )
dC1 1 + i0
=
dC0 1 + 1
C
0
11
Household utility maximisation
C
1
U ' (C )
0 = 1 + i0
U ' (C ) 1 + 1
1
C
0
Households
1 + it
U ' (C ) = Et U ' (C
t + 1 1 + t +1
)
t
12
Households - intuition
1 + it
U ' (C ) = Et U ' (C
t + 1 1 + t +1
)
t
Firms
Firms characterised by
profit maximisation
subject to nominal price rigidity
13
Firms
14
Aggregate price level
p t = (1 ) p it + p t 1
price price
setters non-setters
Derivation
p t = (1 ) p it + p t 1
15
Optimal price setting
p it = (1 ) p t* + Et p it +1
Derivation
p t = (1 ) p it + p t 1
p it = (1 ) p t* + Et p it +1
16
Myopic price
Approximate myopic price with price that would
prevail in flexible price equilibrium
pt* = k pt mct
p t* = p t + m ct
Full derivation
p t = (1 ) p it + p t 1
p it = (1 ) p t* + Et p it +1
p t* = p t + m ct
17
Marginal cost
m ct = w t
Derivation
p t = (1 ) p it + p t 1
p it = (1 ) p t* + Et p it +1
p t* = p t + m ct
m ct = w t
18
Wages
Assume a labour supply function
1
w t = xt
Full derivation
p t = (1 ) p it + p t 1
p it = (1 ) p t* + Et p it +1
p t* = p t + m ct
m ct = w t
1
w t = xt
19
Firms
Full solution
xt = ( t Et t +1 )
(1 )(1 )
Firms - intuition
xt = ( t Et t +1 )
(1 )(1 )
20
Monetary authority
it = t + vt
Monetary it = t + vt
authority
Firms Households
1 + it
xt = ( t Et t +1 ) U ' (C ) = Et U ' (C )
(1 )(1 ) t t + 1 1 + t +1
21
Next steps
Introduction to MATLAB
22
Introduction to
MATLAB
Martin Ellison
University of Warwick and CEPR
What is MATLAB?
23
Matrix
Entering a matrix
Matrices can be
Entered manually
Generated by built-in functions
24
An example
A = [1, 2, 3; 7, 8, 9]
Matrix operations
+ addition
- subtraction
* multiplication
^ power
transpose
25
Example
A= [1, 2; 3, 4]
B = [0.5, 0.6; 1, 1.5]
C = A*B
C = A.*B
Subscripts
Example: A = zeros(2,2);
A(1,1) + A(1,2) + A(2,2)
26
The colon operator
The colon : is one of MATLAB s most
important operators. It has many uses.
27
Working with matrices
Functions
MATLAB provides a large range of standard
elementary mathematical functions, including abs,
sqrt, exp, and sin.
28
Suppressing output
Example: C = randn(5,1)
C = randn(5,1);
29
Flow Control
if statement
for loops
while loops
30
for end
for i = 1:m
for j = 1:n
H(i,j) = 1/(i+j)
end
end
while end
i = 0;
while (i<10000)
s = s + i;
i = i + 1;
end
31
Graphics
x = 0 : 0.01 : 100;
y = x^2;
plot(x,y)
32
Taking a model
to the computer
Martin Ellison
University of Warwick and CEPR
Monetary it = t + vt
authority
Firms Households
1 + it
xt = ( t Et t +1 ) U ' (C ) = Et U ' (C )
(1 )(1 ) t t + 1 1 + t +1
33
Households
Ct1
CRRA utility function U (Ct ) = U ' (Ct ) = Ct
1
No capital Ct = Yt
Dynamic IS curve
1 + it
Yt = Et Yt +1
1 + t +1
Non-linear relationship
34
Log-linear approximation
1 + it
ln Yt = ln + ln Et Yt +1
1 + t +1
Properties of logarithms
Taylor series expansion of logarithmic function
z 2 z3 z 4
ln(1 + z ) = z + + ... 1 < z < 1
2 3 4
35
Log-linearisation
Log-linear expansion of dynamic IS curve
ln Yt = ln Et ln Yt +1 + ln(1 + it ) Et ln(1 + t +1 ) (1)
Zt Zt Z Z
ln Z t ln Z = ln 1 = t = Z t
Z Z Z
percentage deviation of
Zt from steady state Z
36
Log-linearised IS curve
it Et t +1
xt = Et xt +1 1 (it Et t +1 )
Et xt +1
Slope = -
xt
Advanced log-linearisation
The dynamic IS curve was relatively easy to
log-linearise
f x ( x, y ) x , y f y ( x, y )
ln f ( x, y ) ln f ( x , y ) + (x x) + ( y y)
x,y
f ( x, y) f (x, y)
37
Firms
38
Optimal price setting
Pit i =0 Pt p it = (1 ) p t* + Et p it +1
= 1
Pt 1
i i 1 Pt + i
Et Ct +i
i =0 Pt
Myopic price
pt* = pt mct p t* = p t + m ct
1
39
Marginal cost
Wt
= mct m ct = w t
Pt
Wages
Wt N t
= 1
Pt Ct w t = xt
Ct = N t
40
Monetary authority
We assumed it = t + vt
Equivalent to ln it ln i = (ln t 1 ln ) + vt
Monetary it = t + vt
authority
Firms Households
xt = ( t Et t +1 ) xt = Et xt +1 1 (it Et t +1 )
(1 )(1 )
41
Steady state
From firm P = Pi = P *
W 1
mc = =
P
1
1 +
Y =
42
Full DSGE model
xt = Et xt +1 1 (it Et t +1 )
t = Et t +1 + xt
it = t + vt
(1 )(1 )
=
Alternative representation
Et xt +1 + 1 Et t +1 = xt + 1 t + 1vt
Et t +1 = xt + t
1 1 Et xt +1 1 1 xt 1
+
0 E = 0 vt
t t +1 1 t
43
State-space form
A0 Et X t +1 = A1 X t + B0 vt +1
Models of this form (generalised linear rational
expectations models) can be solved relatively
easily by computer
Next steps
Blanchard-Kahn technique
44
Solution techniques
Martin Ellison
University of Warwick and CEPR
State-space form
Generalised state-space form
A0 Et X t +1 = A1 X t + B0 vt +1
45
Alternative state-space form
Et X t +1 = A01 A1 X t + A01 B0 vt +1
A B
Et X t +1 = AX t + Bvt +1
Partitioning of model
backward-looking variables
predetermined variables
w
Xt = t
yt forward-looking variables
control variables
wt +1 w
E y = A t + Bvt +1
t t +1 yt
46
Jordan decomposition of A
wt +1 w
E y = A t + Bvt +1
t t +1 yt
A = PP 1
Blanchard-Kahn condition
47
Too many stable roots
yt multiple solutions
equilibrium path
not unique
need alternative
w0 wt techniques
yt no solution
transversality
w0 wt conditions violated
48
Blanchard-Kahn satisfied
yt one solution
equilibrium path
is unique
wt +1 1 t
w
E y = P P y + Bvt +1
t t +1 t
wt +1
1 1 t
w
P = P + P 1 Bvt +1
Et yt +1 yt
49
Partition of model
w w
P 1 t +1 = P 1 t + Rvt +1
Et yt +1 yt
stable
0 P* P12* R
= 1 P 1 = 11* R = 1
0 2 P21 P22* R2
unstable
Transformed problem
~ ~
w
w t
Et ~t +1 ~
yt +1 t
y
~
P11* wt + P12* yt = w ~
w 0 w ~ R
t +1
= 1 ~t + 1 vt +1
t
E ~ 2 yt R2
P w +P y = ~
*
21 t
*
22 y t t t yt +1 0
50
Decoupled equations
~
w 0 w ~ R
t +1
E ~ = 1 ~t + 1 vt +1
t yt +1 0 2 yt R2
~ = w ~
wt +1 1 t + R1vt +1 stable
Et ~
yt +1 = 2 ~
yt + R2 vt +1 unstable
Solution strategy
Solve unstable ~
yt
transformed equation
Solve stable ~
transformed equation wt
51
Solution of unstable equation
Solve unstable equation forward to time t+j
yt + j = ( 2 ) ~
Et ~
j
yt
~
yt = P21* wt + P22* yt = 0 yt = P22*1 P21* wt
~ = P* w + P* y
wt 11 t 12 t ~ = ( P * P* P *1 P * ) w
w
yt = P22*1 P21* wt
t 11 12 22 21 t
52
Solution of stable equation
~ = w ~
wt +1 1 t + R1vt +1
~
( P11* P12* P22*1 P21* ) wt +1 = w ~ = ( P * P * P *1 P * ) w
w
t +1 t 11 12 22 21 t
Full solution
yt = P22*1 P21* wt
53
Baseline DSGE model
State space form
1 1 Et xt +1 1 1 xt 1
+
0 E = 0 vt
t t +1 1 t
vt +1 = vt + t +1
1 0 0 vt +1 0 0 vt 1
1
0 1 Et xt +1 = 1 1 xt + 0 t +1
1
0 0 E 0 1 t 0
t t +1
54
Blanchard-Khan conditions
wt = vt
Partition model according to x
yt = t
t
Next steps
Simulation techniques
55
Simulation techniques
Martin Ellison
University of Warwick and CEPR
yt = P22*1 P21* wt
56
Numerical simulations
Stylised facts
Stylised facts
Variances
Covariances/correlations
Autocovariances/autocorrelations
57
Recursive simulation
1. Start from steady-state value w0 = 0
Recursive simulation
58
Variances
Standard
deviation
Interest rate 0.46
Inflation 0.46
Correlations
59
Autocorrelations
Cross-correlations
60
Impulse response functions
What is effect of 1 standard deviation shock in
any element of vt on variables wt and yt?
0 0 0 0 L
M M M M
2. Define shock of interest
{vt } = 1 0 0 0 L
M M M M
0 0 0 0 L
61
Response to vt shock
0.6
0.4
0.2
0
-0.2 0 1 2 3 4 5 6 7 8 9 1011 12
-0.4 t
-0.6
-0.8
-1
i nt er e st r a t e
-1.2 o ut p ut g ap
i nf l a t i o n
-1.4
62
FEVD calculation
Define impulse response function of output gap
to each shocks v1 and v2
1.5
1
0.5
0 t
-0.5 0 1 2 3 4 5 6 7 8
-1
-1.5
response to v1
11 21 31 41 51 61 71 81
12 22 32 42 52 62 72 82
response to v2
response at horizons 1 to 8
FEVD at horizon h = 1
At horizon h = 1, two sources of forecast errors
Shock
vt1 vt2
Impulse
response at 11 12
horizon 1
Contribution to
variance at (11 )2 21 ( )
1
2 2 2
v2
horizon 1
63
FEVD at horizon h = 1
Contribution of v1
(11 ) 2 v21
(11 ) 2 v21 + (12 ) 2 v22
FEVD at horizon h = 2
At horizon h = 2, four sources of forecast errors
Shock
vt1 vt2 vt1+1 vt2+1
Impulse
response at 21 22 11 12
horizon 2
Contribution to
variance at ( )
(21 )2 21 22 2 v22 ( ) ( )
1 2
1
2
1 1
2 2 2
v2
horizon 2
64
FEVD at horizon h = 2
Contribution of v1
FEVD at horizon h
At horizon h, 2h sources of forecast errors
Contribution of v1
( )
i =1
1 2
i
2
v1
h h
( )
i =1
1 2
i
2
v1
+ (i2 ) 2 v22
i =1
65
FEVD for output gap
1
0.9
0.8
0.7
0.6 i nt e r est r at e
sho c k
0.5 co st - p us h
sho c k
0.4
0.3
0.2
0.1
0 h
0 1 2 3 4 5 6 7 8 9 10
0.3
0.2
0.1
0 h
0 1 2 3 4 5 6 7 8 9 10
66
FEVD for interest rates
1
0.9
0.8
0.7
0.6 i nt e r est r at e
sho c k
0.5
co st - p us h
0.4 sho c k
0.3
0.2
0.1
0 h
0 1 2 3 4 5 6 7 8 9 10
Next steps
Taylor rules
67
Advanced dynamic
models
Martin Ellison
University of Warwick and CEPR
Impulses
Propagation
Fluctuations
68
Impulses
Can add extra shocks to the model
xt = Et xt +1 1 (it Et t +1 ) + g t
t = Et t +1 + xt + ut
it = t + vt
Propagation
Add lags to match dynamics of data
(Del Negro-Schorfeide, Smets-Wouters)
h 1 h
xt = xt 1 + Et xt +1 1 (it Et t +1 ) 0.35
1+ h 1+ h 1+ h
p p
t = t 1 + Et t +1 + xt 0.29
1 + p 1 + p 1 + p
Taylor rule it = t + x xt + vt
69
Solution of complex models
Blanchard-Kahn technique relies on invertibility
of A0 in state-space form.
A0 E t X t +1 = A1 X t + B 0 v t +1
E t X t +1 = A01 A1 X t + A01 B 0 v t +1
A B
E t X t +1 = AX t + Bv t +1
QZ decomposition
For models where A0 is not invertible
A0 Et X t +1 = A1 X t + B0 vt +1
70
Recursive equations
11 12 w ~ 12 w~
t +1
~ = 11
~t + (Q' ) 1 B0 vt +1
0 22 Et yt +1 0 22 yt
~ + E ~
11w ~ ~
t +1 12 t yt +1 = 11 wt + 12 yt + R1vt +1 stable
22Et ~
yt +1 = 22 ~
yt + R2vt +1 unstable
Solution strategy
Solve unstable ~
yt
transformed equation
71
Simulation possibilities
Stylised facts
min i ( t2 + x xt2 + i it 2 )
i =0
72
Brute force approach
Try all possible combinations of Taylor rule
parameters
73
Grid search
2 For each point
check B-K
conditions
x 1
Next steps
74