64
Using Dynare Giovanni Di Bartolomeo [email protected] Advanced Monetary Theory and Policy EPOS 2012/13

Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo [email protected] Advanced Monetary Theory and Policy

  • Upload
    buidieu

  • View
    231

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Using Dynare

Giovanni Di Bartolomeo

[email protected]

Advanced Monetary Theory and Policy EPOS 2012/13

Page 2: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

• The Neo-classical growth model

The RBC model

22

1

1

1 1 1 1 1

( , )( , )

( , )

( , ) (1 )

( , ) E ( , ) ( , ) (1 )

t tt t t

t t

t t t t t t

t t t t t t t t

u c lz f k n

u c l

c k z f k n k

u c l u c l z f k n

Page 3: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

• The Neo-classical growth model

The RBC model

22

1

1

1 1 1 1 1

( , )( , )

( , )

( , ) (1 )

( , ) E ( , ) ( , ) (1 )

t tt t t

t t

t t t t t t

t t t t t t t t

u c lz f k n

u c l

c k z f k n k

u c l u c l z f k n

How to solve it?

Page 4: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Dynare

• Dynare is preprocessor and a collection of Matlab

routines, which solves DSGE models

• A suite of programs for the simulation and estimation of

rational expectation models, developed by a group of

leading applied DSGE researchers headed by Michel

Juillard since 1994

• Widely used by central banks, IMF, academics research

and in teaching graduate students

• The Dynare home page is http://www.dynare.org/, here

you can download it

• Instructions how to install Dynare can be found in the

manual (Chapter 2, Installation and configuration)

• Dynare is open source!!!!

Page 5: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

What you do, what dynare do!!!

• You tell Dynare what the variables, shocks and

parameters of your model

• You write down the model equations

• You tell Dynare to find the steady state

• Dynare (log)linearizes the model around the steady state

... and solves the recursive equilibrium laws of motion of

the linearized model

• Finally, the model is analyzed via impulse responses,

stochastic simulations and moments

Page 6: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Features

• Computes the steady state of the D(S)GE model

• Computes the solution of deterministic models

• Computes the first and second order approximation of

• linear/non-linear stochastic models

• Estimates the parameters of DSGE models using MLE

or Bayesian methods

• Computes optimal policy for LQ economies

• Simple regression tool

• Useful checking tool

• No or little programming skills required

Page 7: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

The general model

• The model

• Et{f( yt+1, yt, yt−1, vt; θ)} = 0

– y: vector of endogenous (state and jump) variables

– v: vector of exogenous shocks

– θ: vector of model parameters

– f(.): linear or non-linear function

• Steady state: y = {y : [f(yt+1, yt, yt-1, vt; θ)] = 0, t →∞}

• Solution: yt = g(yt-1,vt; ψ)

• Compute statistics of interest: zt = h(vt; ψ, y0, ybar)

Page 8: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Labeling and parameter value blocks

• Labeling block: indicate (list) which symbols indicate

what

– (endogenous) variables in "var"

– exogenous shocks in "varexo"

– parameters in "parameters"

• Parameter values block: Assign values to parameters

• You may also find it useful to give some parameter

transformations. e.g. beta is a parameter, and you

define steady state real interest rate: rr = 1/beta −1

Page 9: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Model block

• The model block starts with

model;

... and ends with

end;

• Between ’model’ and ’end’ you write down the necessary

equations

– defining the dynamic equilibrium of the model first-

order conditions

– constraints

• Remember: you need as many equations as there are

variables

Page 10: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Notation: Time conventions

• Time indices are given in parenthesis

Xt+1 is written X(+1),

Xt−1 is written X(−1)

Xt is written X (no time index needed)

• Note In Dynare, the time index refers to the period when

the value of the variable is determined

Page 11: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Example

• The value of the capital stock, which is used in

production in period t, is determined in period t − 1

• In period t − 1, the agents decide how much to consume

and invest, and they simultaneously determine the size

of the capital stock that will be available in period t.

• In a theory model we often write the period t production

function

Yt= ZtKtαLt

1−α

• In Dynare we need to write

Y = Z*K(−1)^(alpha)*L^(1−alpha)

• Note that we now use L for labor (do not make confusion

with leisure)

Page 12: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

• The model is non-linear. Difficult to solve!!!!

The RBC model (dynare notation)

1

1

1 1

1

1 1

1

1

1

(1 )

E E (1 )

t t t t

t t t t t t

t t tt t

t t

C Z K L

C K Z K L K

C Z K

C L

Page 13: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

State-space form

10110 tttt vBXAXEA

• Generalised state-space form (matrix notation)

• Many techniques available to solve this class of models

• Dynare uses standard: Blanchard-Kahn

• We will discuss this issue later on (other classes)

Page 14: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Linearization

• In the long-run the model in on the steady state.We want

to evaluate what occurs after a shock

– If the economy goes back to the steady state

(stability)

– and how (path followed by the variables after the

shock in backing to the steady state

• Linearize the model, consider a linear approximation

(Taylor expansion) of the non-linear model around the

steady state and compute the effects of small

perturbations around steady state

• Our results are good is we are in the neighborhood of

the steady state (small perturbations)

• After we will go back on this issue

Page 15: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Linearization and log-linearization

• Dynare linearizes the model around the steady state

• It does not log-linearize the model

• Advantages of log-linearization: We are dealing with

percentage deviations from the steady state (or the

balanced growth path)

• Note:

log(Y)log(Yss) = % deviation from the steady state

• Log-deviations (or percentage deviations) are easy to

interpret (is a deviation ’small’ or ’large’?)

• Similar measures are used in empirical examination of

the data (e.g. applying HP filter to log(GDP))

Page 16: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Log-linearization: A useful trick

• A useful trick: Write down the model in terms of

logarithmic transformations of the original variables

• Adopt the notation

ly = log(Y), lc = log(C), lk = log(K) etc.

• Then use

Y = exp(ly), C = exp(lc), K=exp(lk) etc.

• When Dynare linearizes the model in terms of the

logarithmic transformations, it log-linearizes the model in

terms of the original variables

Page 17: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Log-linearization in practice

• Adopt the notation

ly = log(Y), lc = log(C), lk = log(K) etc.

• Note: For employment we use the notation

lh = log(L)

• where h refers to hours worked

• Then the resource constraint

Yt = Ct + Kt+1 − (1− δ)Kt

• can be written as

exp(ly) = exp(lc) + exp(lk) − (1− delta) ∗ exp(lk(−1))

• Remember the Dynare conventions pertaining to time

indexation

Page 18: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Conditional expectations

• The expectation operator Et is not used in Dynare code.

– Dynare ’knows’ when one has to take expectations,

we do not have to tell this explicitly.

• E.g., the consumption Euler equation

• is written as

(1/beta)∗ exp(lc(+1) − lc) = alfa ∗ (exp(y(+1) − lk) + 1− δ

1 11E E (1 )t t

t t

t t

C Y

C K

Page 19: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Dynare program blocks

• Initialization block: Dynare has to solve for the steady

state. This can be the most diffcult part (since it is a true

non-linear problem). So good initial conditions are

important

• Random shock block: Indicate the standard deviation for

the exogenous innovation

Page 20: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Initialization block

• It is often useful to give Dynare an initial guess of the

steady state values, after the command

initval;

• Dynare finds the steady state with the command

steady;

Page 21: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Random shock block

shock;

var e; we shock only one ’variable’ (the TFP shock e)

stderr 0.007; the standard error of the TFP shock is 0.007

– If there are several shocks, say e_z and e_c, you

have to be more careful: stderr e_z 0.007; stderr e_c

0.002;

– More generally, if there are several shocks, you may

want to give the variance-covariance matrix of the

shocks;

end;

Page 22: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Stochastic simulation (IRF)

stoch_simul(order=1,irf=100) ly lh lc li lk z;

– order=1 means that Dynare takes a first order Taylor

approximation around the steady state (order=2 =>

second order approximation, order=3 …)

– irf=100 means that you want Dynare to compute the

impulse responses for 100 periods

• Dynare computes the moments of the endogenous

variables mean, standard deviation, variance, skewness,

kurtosis (contemporaneous) cov-matrix autocorrelations

• The list of variables, we want to Dynare to analyze is ly

lh lc li lk z

• Notice that z ≡ log(Zt)−log(Z) = log (Zt), since Z=1 and

log(Z)=0 (a useful normalization).

Page 23: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Stochastic simulation (IRF)

• Alternatively we can write:

stoch_simul(order=1,periods=1000,irf=100);

• Now Dynare simulates the model for 1000 periods, and

computes the moments based on the simulated data

Page 24: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

The structure of the code in a nutshell

• var (list of endogenous variables );

• varexo (list of shocks) ;

• parameters (parameters + parameter values + transformations);

• model;

• model equations;

• end;

• initval; (initial guesses for computing the steady state)

• steady; (compute the steady state)

• shocks; (the shock structure of the model )

• var (what variables are shocked);

• stderr (the standard error of the shocks);

• end;

• stoch_simul(order=1,irf=100) ly lh lc li lk z; (analyzing the model)

Page 25: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

The RBC DSGE model (dynare notation)

• Our RBC model (social planner)

1

1

1 1

1

1 1

1

1

(1 )

E E (1 )

t t t t

t t t t t t

t t tt t

t t

C Z K L

C K Z K L K

C Z K

C L

Page 26: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Now recall that

1

1

1 1 1

1 1 /

/ /

t t t t t

t t t t t

MPL Z K L Y L

MPK Z K L Y K

• Competitive markets imply

• From the production function definition

1 (1 )

t

t

W MPL

r MPK

Page 27: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Full micro-founded RBC model

D

1 1

1

1

1/ E / [Euler equation, S ]

[Labor supply]

(1 ) [Capital accumulation]

[Producti

t t t t

t t

t t t

t t t t

C r C

C W

K I K

Y Z K L

S

1 1

1

on function]

[Market equilibrium]

1 / [Market equilibrium]

E / (1 ) [Real net interest rate, S ]

log 1 log( ) log ,

t t t

t t t

t t t t

t t t

Y I C

W Y L

r Y K

Z Z Z

[TFP]t iid

Page 28: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Full micro-founded RBC model

D

1 1

1

1

1/ E / [Euler equation, S ]

[Labor supply]

(1 ) [Capital accumulation]

[Producti

t t t t

t t

t t t

t t t t

C r C

C W

K I K

Y Z K L

S

1 1

1

on function]

[Market equilibrium]

1 / [Market equilibrium]

E / (1 ) [Real net interest rate, S ]

log 1 log( ) log ,

t t t

t t t

t t t t

t t t

Y I C

W Y L

r Y K

Z Z Z

[TFP]t iid

Check that the social planner model and

the micro-foundend one are the same

First welfare theorem!!!

Page 29: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

RBC DSGE model (after some algebra)

1 1

1

1

1

1 1

1

E E (1 )

1

(1 )

log 1 log( ) log ,

1 /

t tt t

t t

t t

t t t t

t

t t

t t t t t t

t t

t t

t t

t t

t

C Y

C K

C Z K L

C K Z K L K

Z Z Z iid

Y Z K L

I Y C

W Y L

Page 30: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

1. Definitions

// following are the ’endogenous’ variables:

var ly, lh, lc, li, lw, lk, z ;

// following are the shocks

varexo e;

parameters beta, fi, alpha, delta, psi;

alpha = 0.33;

fi = 0.74;

beta = 0.99;

delta = 0.024;

psi =0.262;

Page 31: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Steady state (solved)

1

1

1/ / (1 )

1

log 0, 1 0

1 /

ss ss

ss ss ss

ss s

ss ss ss

ss ss ss

ss ss s

s ss ss

ss ss

s

Y K L

I Y

K L

C K L

C K L K

Z

C

W Y L

Z

Page 32: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Steady state (solved)

// Steady state expressed in terms of parameters

rr = 1/beta-1;

zss = 1;

css = (1-

alpha)*(zss/psi)*(alpha*zss/(rr+delta))^(alpha/(1-

alpha));

kss = css/((rr+delta)/alpha-delta);

hss = (1/psi)*(1-alpha*rr/(rr+(1-alpha)*delta));

yss = zss*kss^(alpha)*hss^(1-alpha);

iss = delta*kss;

wss = (1-alpha)*yss/hss;

Page 33: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

2. The model

1

1

1

1

1 1

1

E E (1 )

1 /

(1 )

log 1 log( ) log ,

1 /

t

t tt t

t t

t t t

t

t

t t

t t

t t t

t t t

t t t

t t t t

C Y

C K

C Y L

C K Z K L K

Y Z K L

I Y C

W

Z i

L

Z Z id

Y

Page 34: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(a) Euler equation

(1/beta)*exp(lc(+1)-lc)= alpha*exp(ly(+1)-lk) + 1 - delta;

Inter-temporal marginal rate of substitution between

consumption today and tomorrow is equal to the real

interest rate (marginal product of capital) [dynamic]

1

1 1E E (1 )

t

t tt t

t t

r

C Y

C K

Page 35: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(b) Labor market equilibrium

psi*exp(lc)= (1-alpha)*exp(ly-lh);

The marginal rate of substitution between consumption and

leisure should be equated to the wage rate (marginal

product of labor) [static]

1 tt

t

YC

L

Page 36: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(c) Capital accumulation

exp(ly) = exp(lc) + exp(lk) - (1-delta)*exp(lk(-1));

Note that

1

1 1(1 )

t

t t t t t t

Y

Z K L C K K

1

1

1

1

(1 )

(1 )

(1 )

(1 )

t t t t

t t t t

t t t

t t t

Y C K K

Y C K K

I K K

K I K

Page 37: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(d) Production function

exp(ly) = exp(z+alpha*lk(-1)+(1-alpha)*lh);

Cobb-Douglas production function

1t t t tY Z K L

Page 38: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(e) Investment

exp(li)=exp(ly)-exp(lc);

Maybe, more familiar identity: Y = C + I

t t tI Y C

Page 39: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(f) Real wage

exp(lw)=(1-alpha)*exp(ly-lh);

Real wage is equal to the marginal product of labor

Recall that

1 /t t tW Y L

11 1t tt

t t

K YMPL Z

L L

Page 40: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

(g) Law of motion of TFP

z = fi*z(-1) + e;

• Note for later use: we assume that the steady state value

of the total factor productivity is one, its log is zero

1log 1 log( ) log , t t t tZ Z Z iid

Page 41: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Model: Summary

model;

(1/beta)*exp(lc(+1)-lc)= alpha*exp(ly(+1)-lk) + 1 -

delta; //Euler equation

psi*exp(lc)= (1-alpha)*exp(ly-lh); //Labour market

equilibrium

exp(ly) = exp(lc) + exp(lk) - (1-delta)*exp(lk(-1));

//Resource constraint

exp(ly) = exp(z+alpha*lk(-1)+(1-alpha)*lh);

//Production function

exp(li)=exp(ly)-exp(lc); // Investment

exp(lw)=(1-alpha)*exp(ly-lh); //Real wage

z = fi*z(-1) + e; //Law of motion of TFP

end;

Page 42: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

4. Initial values

//Initial guesses for the computation of steady

state

initval;

lc=log(css);

lh=log(hss);

lk=log(kss);

ly=log(yss);

li=log(iss);

lw=log(wss);

z=zss;

end;

steady;

Page 43: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

5. Stochastic block and simulation

shocks;

var e;

stderr 0.007;

end;

stoch_simul(order=1,irf=100) ly lh lc li lk z;

Page 44: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

To get the results

• Save the file as [Name of the file].mod

• For example rbc.mod

• You run the model by writing to the Matlab command

window

dynare rbc.mod

Page 45: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Dynare output

• The output is shown on the screen, and in separate

figures (impulse responses).

• Output includes

– Policy and transition functions

– Moments of the endogenous variables

– mean, variance, standard deviation, skewness, kurtosis

– matrix of contemporaneous correlations

– coefficients of autocorrelation

– Impulse responses

• If you have included the periods option in stoch_simul

the output also includes the results (time paths of

endogenous variables) from the stochastic simulation.

Page 46: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Output storing

• The output is shown on the screen, and in separate

figures (impulse responses).

• Output is also stored in a separate structure, called oo_.

The structure oo_ contains (for example)

– The steady state (oo_.steady_state )

– The variance-covariance matrix (oo_.var)

– The autocorrelations (oo_.autocorr)

– The impulse responses (oo_.irfs)

– The coefficients of the policy and transition functions

(oo_.dr)

– Results (time paths of endogenous variables) from

stochastic simulations (oo_.endo_simul)

Page 47: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Dynare output

Type dynare rbc.mod

Starting Dynare (version 4.3.0).

Starting preprocessing of the model file ...

Found 7 equation(s).

Evaluating expressions...done

Computing static model derivatives:

- order 1

Computing dynamic model derivatives:

- order 1

Processing outputs ...done

Preprocessing completed.

Starting MATLAB/Octave computing.

Page 48: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Steady state

STEADY-STATE RESULTS:

ly 0.02

lh -1.10

lc -0.24

li -1.44

lw 0.72

lk 2.23

z 0.00

• The term constant is the steady state (of log

transformation)

• E.g. lh = -1.1 and thus L = exp(-1.1) = 0.33

Page 49: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Summary

MODEL SUMMARY

Number of variables: 7

Number of stochastic shocks: 1

Number of state variables: 2

Number of jumpers: 2

Number of static variables: 3

Page 50: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Shock co-variance

MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS

Variables e

e 0.000049

Page 51: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Policy and transition functions

POLICY AND TRANSITION FUNCTIONS

ly lh lc li lk z

Const 0.018 -1.099 -0.245 -1.441 2.288 0.000

lk(-1) -0.007 -0.503 0.496 -1.672 0.935 0.000

z(-1) 1.868 1.683 0.184 7.433 0.178 0.740

e 2.524 2.275 0.249 10.045 0.241 1.000

• Transition functions: how the period t values of the state variables (lk

and z) depend on t-1 values of the state variables, and the shock

• Policy functions: how the period t values of the other variables

depend on t-1 values of the state variables, and the shock

– Rows: period t values of the variables

– Columns: period t-1 values of the state variables + the shock (e)

• The term constant is the steady state (of log transformation)

Page 52: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Moments

THEORETICAL MOMENTS

VARIABLE MEAN STD. DEV. VARIANCE

ly 0.0186 0.0262 0.0007

lh -1.0994 0.0221 0.0005

lc -0.2457 0.0095 0.0001

li -1.4414 0.0980 0.0096

lk 2.2884 0.0167 0.0003

z 0.0000 0.0104 0.0001

Page 53: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Correlations

MATRIX OF CORRELATIONS

Variables ly lh lc li lk z

ly 1.0000 0.9363 0.5824 0.9652 0.4846 1.0000

lh 0.9363 1.0000 0.2597 0.9956 0.1465 0.9347

lc 0.5824 0.2597 1.0000 0.3494 0.9933 0.5860

li 0.9652 0.9956 0.3494 1.0000 0.2388 0.9640

lk 0.4846 0.1465 0.9933 0.2388 1.0000 0.4885

z 1.0000 0.9347 0.5860 0.9640 0.4885 1.0000

Page 54: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Autocorrelation

COEFFICIENTS OF AUTOCORRELATION

Order 1 2 3 4 5

ly 0.7389 0.5458 0.4030 0.2974 0.2192

lh 0.6860 0.4571 0.2910 0.1711 0.0852

lc 0.9811 0.9517 0.9155 0.8751 0.8326

li 0.6931 0.4690 0.3060 0.1880 0.1031

lk 0.9901 0.9668 0.9345 0.8966 0.8553

z 0.7400 0.5476 0.4052 0.2999 0.2219

Page 55: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Impulse response functions (IRF)

Page 56: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

How to write the solution in a VAR form

POLICY AND TRANSITION FUNCTIONS

Dynare output

Log(y) Log(h) Log(c) Log(i) Log(k) z

Constant 0,019 -1,099 -0,246 -1,441 2,288 0,000

Log(k(-1)) -0,008 -0,504 0,496 -1,673 0,936 0,000

z(-1) 1,868 1,684 0,184 7,434 0,178 0,740

e 2,524 2,275 0,249 10,046 0,241 1,000

Levels Exp(Constant)

Steady state 1,019 0,333 0,782 0,237 9,859 1,000

Page 57: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

We rewrite the table in equations

Dynare output Trasfor

m

ly lh lc li lk z ly = 0,019 + -0,008 lk(-1)- 2,288 + 1,868 z(-1) + 2,524 e

Constant 0,019 -1,099 -0,246 -1,441 2,288 0,000 lh= -1,099 + -0,504 lk(-1)- 2,288 + 1,684 z(-1) + 2,275 e

lk(-1) -0,008 -0,504 0,496 -1,673 0,936 0,000 lc= -0,246 + 0,496 lk(-1)- 2,288 + 0,184 z(-1) + 0,249 e

z(-1) 1,868 1,684 0,184 7,434 0,178 0,740 li= -1,441 + -1,673 lk(-1)- 2,288 + 7,434 z(-1) + 10,046 e

e 2,524 2,275 0,249 10,046 0,241 1,000 lK= 2,288 + 0,936 lk(-1)- 2,288 + 0,178 z(-1) + 0,241 e

z= 0,000 + 0,000 lk(-1)- 2,288 + 0,740 z(-1) + 1,000 e

Page 58: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

We rewrite the table in equations

Dynare output Trasfor

m

ly lh lc li lk z ly = 0,019 + -0,008 lk(-1)- 2,288 + 1,868 z(-1) + 2,524 e

Constant 0,019 -1,099 -0,246 -1,441 2,288 0,000 lh= -1,099 + -0,504 lk(-1)- 2,288 + 1,684 z(-1) + 2,275 e

lk(-1) -0,008 -0,504 0,496 -1,673 0,936 0,000 lc= -0,246 + 0,496 lk(-1)- 2,288 + 0,184 z(-1) + 0,249 e

z(-1) 1,868 1,684 0,184 7,434 0,178 0,740 li= -1,441 + -1,673 lk(-1)- 2,288 + 7,434 z(-1) + 10,046 e

e 2,524 2,275 0,249 10,046 0,241 1,000 lK= 2,288 + 0,936 lk(-1)- 2,288 + 0,178 z(-1) + 0,241 e

z= 0,000 + 0,000 lk(-1)- 2,288 + 0,740 z(-1) + 1,000 e

Page 59: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

We rewrite the table in equations

Dynare output Trasfor

m

ly lh lc li lk z ly = 0,019 + -0,008 lk(-1)- 2,288 + 1,868 z(-1) + 2,524 e

Constant 0,019 -1,099 -0,246 -1,441 2,288 0,000 lh= -1,099 + -0,504 lk(-1)- 2,288 + 1,684 z(-1) + 2,275 e

lk(-1) -0,008 -0,504 0,496 -1,673 0,936 0,000 lc= -0,246 + 0,496 lk(-1)- 2,288 + 0,184 z(-1) + 0,249 e

z(-1) 1,868 1,684 0,184 7,434 0,178 0,740 li= -1,441 + -1,673 lk(-1)- 2,288 + 7,434 z(-1) + 10,046 e

e 2,524 2,275 0,249 10,046 0,241 1,000 lK= 2,288 + 0,936 lk(-1)- 2,288 + 0,178 z(-1) + 0,241 e

z= 0,000 + 0,000 lk(-1)- 2,288 + 0,740 z(-1) + 1,000 e

Page 60: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

We rewrite the table in equations

Dynare output Trasfor

m

ly lh lc li lk z ly = 0,019 + -0,008 lk(-1)- 2,288 + 1,868 z(-1) + 2,524 e

Constant 0,019 -1,099 -0,246 -1,441 2,288 0,000 lh= -1,099 + -0,504 lk(-1)- 2,288 + 1,684 z(-1) + 2,275 e

lk(-1) -0,008 -0,504 0,496 -1,673 0,936 0,000 lc= -0,246 + 0,496 lk(-1)- 2,288 + 0,184 z(-1) + 0,249 e

z(-1) 1,868 1,684 0,184 7,434 0,178 0,740 li= -1,441 + -1,673 lk(-1)- 2,288 + 7,434 z(-1) + 10,046 e

e 2,524 2,275 0,249 10,046 0,241 1,000 lK= 2,288 + 0,936 lk(-1)- 2,288 + 0,178 z(-1) + 0,241 e

z= 0,000 + 0,000 lk(-1)- 2,288 + 0,740 z(-1) + 1,000 e

Page 61: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Now we manipulate our equations

Given

ly = 0,019 + -0,008 lk(-1)- 2,288 + 1,868 z(-1) + 2,524 e

lh= -1,099 + -0,504 lk(-1)- 2,288 + 1,684 z(-1) + 2,275 e

lc= -0,246 + 0,496 lk(-1)- 2,288 + 0,184 z(-1) + 0,249 e

li= -1,441 + -1,673 lk(-1)- 2,288 + 7,434 z(-1) + 10,046 e

lK= 2,288 + 0,936 lk(-1)- 2,288 + 0,178 z(-1) + 0,241 e

z + 0,000 lk(-1)- 2,288 + 0,740 z(-1) + 1,000 e

We move the steady state on the left

ly - 0,019 = -0,008 lk(-1)- 2,288 + 1,868 z(-1) + 2,524 e

lh - -1,099 = -0,504 lk(-1)- 2,288 + 1,684 z(-1) + 2,275 e

lc - -0,246 = 0,496 lk(-1)- 2,288 + 0,184 z(-1) + 0,249 e

li - -1,441 = -1,673 lk(-1)- 2,288 + 7,434 z(-1) + 10,046 e

lk - 2,288 = 0,936 lk(-1)- 2,288 + 0,178 z(-1) + 0,241 e

z = 0,000 lk(-1)- 2,288 + 0,740 z(-1) + 1,000 e

Obtaining the log deviations

y = -0,008 k(-1) + 1,868 z(-1) + 2,524 E

h = -0,504 k(-1) + 1,684 z(-1) + 2,275 E

c = 0,496 k(-1) + 0,184 z(-1) + 0,249 E

i = -1,673 k(-1) + 7,434 z(-1) + 10,046 E

k = 0,936 k(-1) + 0,178 z(-1) + 0,241 E

z = 0,000 k(-1) + 0,740 z(-1) + 1,000 e

Page 62: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Looking at the shock

Form log deviations (y=log(y)-log(yss) …)

y = -0,008 k(-1) + 1,868 z(-1) + 2,524 e

h = -0,504 k(-1) + 1,684 z(-1) + 2,275 e

c = 0,496 k(-1) + 0,184 z(-1) + 0,249 e

i = -1,673 k(-1) + 7,434 z(-1) + 10,046 e

k = 0,936 k(-1) + 0,178 z(-1) + 0,241 e

z = 0,000 k(-1) + 0,740 z(-1) + 1,000 e

Note

z = phi z(-1) + e

0,740

Multiply

2,524 * z = 1,868 z(-1) 2,52 + e

2,275 * z = 1,684 z(-1) 2,27 + e

0,249 * z = 0,184 z(-1) 0,24 + e

10,046 * z = 7,434 z(-1) 10,0 + e

0,241 * z = 0,178 z(-1) 0,24 + e

Page 63: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Looking at the shock

Form log deviations

y = -0,008 k(-1) + 1,868 z(-1) + 2,524 e

h = -0,504 k(-1) + 1,684 z(-1) + 2,275 e

c = 0,496 k(-1) + 0,184 z(-1) + 0,249 e

i = -1,673 k(-1) + 7,434 z(-1) + 10,046 e

k = 0,936 k(-1) + 0,178 z(-1) + 0,241 e

z = 0,000 k(-1) + 0,740 z(-1) + 1,000 e

Note that

z = phi z(-1) + e

0,740

Multiply by

2,524 * z = 1,868 z(-1) 2,524 + e

2,275 * z = 1,684 z(-1) 2,275 + e

0,249 * z = 0,184 z(-1) 0,249 + e

10,046 * z = 7,434 z(-1) 10,05 + e

0,241 * z = 0,178 z(-1) 0,241 + e

Hence we can write

y = -0,008 k(-1) + 2,524 z

h = -0,504 k(-1) + 2,275 z

c = 0,496 k(-1) + 0,249 z

i = -1,673 k(-1) + 10,046 z

k = 0,936 k(-1) + 0,241 z

z = 0,740 z(-1) + e

Page 64: Using Dynare - ComUniTedibartolomeo.comunite.it/courses/amtp/Dynare.pdf · Using Dynare Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Advanced Monetary Theory and Policy

Compact form

y = -0,008 k(-1) + 2,524 z

h = -0,504 k(-1) + 2,275 z

c = 0,496 k(-1) + 0,249 z

i = -1,673 k(-1) + 10,046 z

k = 0,936 k(-1) + 0,241 z

z = 0,740 z(-1) + e

1

1

t t t

t t t

X AX BZ

Z Z S