dynare class on heathcote-perri jme 2002 -...

31
Dynare Class on Heathcote-Perri JME 2002 Tim Uy University of Cambridge March 10, 2015

Upload: lyhuong

Post on 09-May-2018

228 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Dynare Class on Heathcote-Perri JME 2002

Tim UyUniversity of Cambridge

March 10, 2015

Page 2: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Introduction

I Solving DSGE models used to be very time consuming due tolog-linearization required

I Dynare is a collection of Matlab codes that essentially allowsyou to solve models without having to do log-linearization

I It is also useful for estimating and simulating a wide variety ofmodels and hence is becoming increasingly more popular

I It is limited by its inability to handle models that requireglobal solution methods (e.g. discrete choice, etc)

Page 3: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Introduction

I To set up Dynare, simply download it from the Dynarewebsite

I Choose a destination folder for storing the files, and set theMatlab path to include this folder

I To solve your model, create a filename.mod file that containsthe model equations and parameterization

I Then simply type “dynare filename” and off you go!

Page 4: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

This Class

I In this class, we will focus on the models in Heathcote PerriJME (2002)

I There are essentially three models discussed in that paper: amodel with complete markets (CM), a bond economy (BE),and an environment with financial autarky (FA)

I I will go over the models and then talk about how I implementthem in Dynare

I I will share my code with you but it is only meant to be forstudents in this class- please ask for my permission beforesharing them with anyone else

Page 5: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Heathcote and Perri JME 2002

I Two-country, two-good IRBC model with production

I There are two shocks in the economy: productivity shocksthat are highly persistent and correlated across countries

I Capital and labor are not mobile across countries, andpreferences are non-separable in consumption and leisure

I The three model setups only differ in asset trade that showsup in the budget constraint faced by households

I With CM, households have access to a full set of Arrowsecurities (state-contingent claims on output); With BE,households only have access to a non-contingent bond; underFA, households do not trade assets, only goods

I FA comes closest to matching data on RER volatility andcross-country correlations (positive for investment, labor, etc)

Page 6: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Intuition

I Three shortcomings of the standard IRBC model:cross-country consumption levels more correlated than output,negative cross-country correlation in investment and labor,and relatively non-volatile RER

I This is best understood from a CM perspective: CM providesinsurance against output shocks so that consumption becomesstrongly positively correlated across countries (risk sharing)

I With a positive shock in country A, CM implies movingresources from B to A to increase investment and labor in A,hence the negative cross-country correlation

I RER need not be volatile as adjustment in quantitiesmitigates adjustment to prices induced by productivity shock

I BE is close to CM because it still allows agents to borrowabroad, so shock need not imply big TOT adjustment andshocks are small (so gains from pooling risks are small)

Page 7: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Model

I Period utility

U(ci , 1 − ni ) =1

γ[cµi (1 − ni )

1−µ]γ

I Production function

F (z , ki , ni ) = exp(zi )kθi n

1−θi

I Law of motion for vector of shocks z = [z1, z2]

zt = Azt−1 + εt

where A is a 2x2 matrix and ε is a 2x1 vector of iid randomvariables with covariance matrix Σ. History dependence issuppressed when possible to simplify notation.

Page 8: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Model

I Capital accumulation

kit+1 = (1 − δ)kit + xit

I Goods productionHome:

G1(a1, b1) = [ωaσ−1σ

1 + (1 − ω)bσ−1σ

1 ]

Foreign:

G2(a2, b2) = [(1 − ω)aσ−1σ

2 + ωbσ−1σ

2 ]

Two key parameters: ω > 0.5 home bias, σ elasticity ofsubstitution

I Firm problem

maxai ,bi

Gi (ai , bi ) − qai ai − qbi bi

Page 9: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Budget constraints

I Complete markets

c1(st) + x1(st) + qa1(st)∑st+1

Q(st , st+1)B1(st , st+1) =

qa1(st)[r1(st)k1(st) + w1(st)n1(st)] + qa1(st)B1(st)

I Bond economy

c1(st) + x1(st) + qa1(st)Q(st)B1(st) =

qa1(st)[r1(st)k1(st) + w1(st)n1(st)] + qa1(st)B1(st−1)

I Financial autarky

c1(st) + x1(st) = qa1(st)[r1(st)k1(st) + w1(st)n1(st)]

Page 10: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Market Clearing

I Intermediate goods a and b

a1 + a2 = F (z1, k1, n1)

b1 + b2 = F (z2, k2, n2)

I Final goods

ci + xi = Gi (ai , bi ), i = 1, 2

I Bond markets

B1(st , st+1) + B2(st , st+1) = 0, [CM]

B1(st) + B2(st) = 0, [BE]

Page 11: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Additional Variables of Interest

I GDPyi = qa1F (z1, k1, n1)

I Net exports (for country 1)

nx =qa1a2 − qb1b1

y1I Import ratio: ratio of imports to non-traded domestic

intermediate good production

ir =q̄b1q̄a1

I Terms of trade: price of imports to exports

p =qb1qa1

=1 − ω

ωir

−1σ

I Real Exchange Rate: price of consumption in 2 relative to 1

rx =qa1qa2

=qb1qb2

Page 12: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Endogenous variables

v a r G1 , G2 , F1 , F2 , y1 , y2 , c1 , c2 , n1 , n2 ,k1 , k2 , x1 , x2 , a1 , a2 , b1 , b2 , z1 , z2 ,

qa1 , qb1 , qa2 , qb2 , nx , xp , im , p , rx ,i r 1 , i r 2 ;

I Exogenous variables

v a r e x o e1 , e2 ;

I Parameters

p a r a m e t e r s omega , t he ta , p1 , p2 ,p3 , p4 , sigma , gamma , beta , mu, d e l t a ;

Page 13: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Parameters values

omega = 0 . 8 7 3 ;t h e t a = 0 . 3 6 ;p1 = 0 . 9 7 ;p2 = 0 . 0 2 5 ;p3 = 0 . 0 2 5 ;p4 = 0 . 9 7 ;s igma = 0 . 9 0 ;gamma = −1;be ta = 0 . 9 9 ;mu = 0 . 3 4 ;d e l t a = 0 . 0 2 5 ;

Page 14: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Model: market clearing conditions

model ;a1 + a2 = F1 ;b1 + b2 = F2 ;c1 + k1 − (1− d e l t a )∗ k1 (−1) = G1 ;c2 + k2 − (1− d e l t a )∗ k2 (−1) = G2 ;

I Production functions

G1 = ( omega∗a1 ˆ ( ( sigma −1)/ s igma )+(1−omega )∗b1 ˆ ( ( sigma −1)/ s igma ) ) ˆ ( s igma /( sigma −1)) ;G2 = ( omega∗b2 ˆ ( ( sigma −1)/ s igma )+(1−omega )∗a2 ˆ ( ( sigma −1)/ s igma ) ) ˆ ( s igma /( sigma −1)) ;F1 = exp ( z1 )∗ k1 (−1)ˆ t h e t a ∗n1ˆ(1− t h e t a ) ;F2 = exp ( z2 )∗ k2 (−1)ˆ t h e t a ∗n2ˆ(1− t h e t a ) ;

Page 15: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Shock processes

z1 = p1∗ z1 (−1) + p2∗ z2 (−1) + e1 ;z2 = p3∗ z1 (−1) + p4∗ z2 (−1) + e2 ;

I Intertemporal Euler equations for capital (2)

I Intratemporal Euler equations for consumption and leisure (2)

I International risk sharing conditions for a and b

I These 16 equations determinea1, a2, b1, b2,G1,G2,F1,F2, z1, z2, c1, c2, k1, k2, n1, n2

Page 16: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Equations to determines other endogenous variables: prices

qa1 = G1ˆ(1/ sigma )∗ omega∗a1 ˆ(−1/ sigma ) ;qb1 = G1ˆ(1/ sigma )∗(1−omega )∗ b1ˆ(−1/ sigma ) ;qa2 = G2ˆ(1/ sigma )∗(1−omega )∗ a2 ˆ(−1/ sigma ) ;qb2 = G2ˆ(1/ sigma )∗ omega∗b2ˆ(−1/ sigma ) ;

I Relative prices

p = qb1/ qa1 ;r x = qa1 / qa2 ;

I GDP

y1 = qa1∗F1 ;y2 = qb2∗F2 ;

Page 17: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Additional equations for other interesting variables

xp = a2 ;im = b1 ;x1 = k1 − (1− d e l t a )∗ k1 ( −1);x2 = k2 − (1− d e l t a )∗ k2 ( −1);nx = ( a2−p∗b1 )/ y1 ;i r 1 = b1/ a1 ;i r 2 = b2/ a2 ;end ;

I We started out by declaring 31 endogenous variables;combining these 15 equations to the 16 mentioned earlieryields the system of 31 equations needed to solve the model

Page 18: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Provide initial values for endogenous variables

i n i t v a l ;G1 = 1 . 6 5 1 9 ;G2 = 1 . 6 5 1 9 ;F1 = 1 . 5 1 0 3 ;F2 = 1 . 5 1 0 3 ;c1 = 1 . 2 2 8 3 ;c2 = 1 . 2 2 8 3 ;n1 = 0 . 3 8 7 7 ;n2 = 0 . 3 8 7 7 ;. . .end ;

Page 19: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: CM

I Specify shock process

s h o c k s ;v a r e1 ; s t d e r r 0 . 0 0 7 3 ;v a r e2 ; s t d e r r 0 . 0 0 7 3 ;v a r e1 , e2 = 0 . 2 9∗0 . 0 0 7 3∗0 . 0 0 7 3 ;end ;

I Ask Dynare to check to make sure the model can be solved

s t e a d y ;check ;

I Specify what to do with the model

s t o c h s i m u l ( o r d e r = 1 , h p f i l t e r = 1600 ,i r f =0);

Page 20: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

CM vs BE and FA

I Notice that in solving the CM economy we did not solve forthe decentralized equilibrium

I The welfare theorems and functional forms assumed allow usto solve the planning problem instead

I This will no longer be the case in BE and FA

I When markets are not complete, we will have to solve for thedecentralized equilibrium directly

I The main difference is that now we have to solve for pricesexplicitly as part of equilibrium

Page 21: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: FA

I What are the differences relative to CM?

I The main difference is in the budget constraint, which we nowspecify explicitly

c1 + x1 = qa1 ∗( r 1 ∗k1(−1)+w1∗n1 ) ;c2 + x2 = qb2 ∗( r 2 ∗k2(−1)+w2∗n2 ) ;

I What conditions did these equations replace? We still havethe same number of endogenous variables

p = qb1/ qa1 ;r x = qa1 / qa2 ;

I The international risk sharing conditions! Why? (Hint:Walras Law.)

Page 22: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: FA

I Are there other differences?

I For completeness, we also specify the prices, which aretechnically required to complete equilibrium

r1 = t h e t a ∗F1 /( k1 ( −1)) ;r2 = t h e t a ∗F2 /( k2 ( −1)) ;w1 = (1− t h e t a )∗F1/n1 ;w2 = (1− t h e t a )∗F2/n2 ;

I Given that we’ve added these conditions, what other parts ofthe code have to be modified?

I Hint: number of equations = number of ? What else isrequired to solve the model?

Page 23: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: FA

I The two places that have to be updated are: (1) the var list,and the (2) initval conditions

I We have introduced four new variables

v a r G1 , G2 , F1 , F2 , y1 , y2 , c1 , c2 , n1 , n2 ,k1 , k2 , x1 , x2 , a1 , a2 , b1 , b2 , z1 , z2 ,qa1 , qa2 , qb1 , qb2 , i r 1 , i r 2 , p , rx , xp ,

im , nx , r1 , r2 , w1 , w2 ;

I Four initial values to help Dynare find steady state

r1 = 0 . 0 5 2 5 ;r2 = 0 . 0 5 2 5 ;w1 = 1 . 8 9 0 5 ;w2 = 1 . 8 9 0 5 ;

Page 24: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: FA and BE

I Do we expect something similar for BE?

I No. Why not? Which conditions change?

I Hint 1: think about the conditions that are affected by thebudget constraint

I Hint 2: a more subtle point - is FA really that different fromCM (when you think from a planner’s perspective)

Page 25: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: BE

I Relative to FA, these conditions are different:

B1 + B2 = 0 ;c1 + x1 + qa1∗Q∗B1 + qa1∗ p h i ∗B1ˆ2 =qa1 ∗( r 1 ∗k1(−1)+w1∗n1 ) + qa1∗B1( −1);c2 + x2 + qa1∗Q∗B2 + qa1∗ p h i ∗B2ˆ2 =qb2 ∗( r 2 ∗k2(−1)+w2∗n2 ) + qa1∗B2( −1);( c1 ˆmu∗(1−n1 )ˆ(1−mu) ) ˆ gamma/ c1∗(Q∗qa1+2∗qa1∗ p h i ∗B1) =be ta ∗ ( ( c1 (+1))ˆmu∗(1−n1 (+1))ˆ(1−mu) )ˆgamma/ c1 (+1)∗qa1 (+1);( c2 ˆmu∗(1−n2 )ˆ(1−mu) ) ˆ gamma/ c2∗(Q∗qa1+2∗qa1∗ p h i ∗B2) =be ta ∗ ( ( c2 (+1))ˆmu∗(1−n2 (+1))ˆ(1−mu) )ˆgamma/ c2 (+1)∗qa1 (+1);

I What are these conditions, and why are they different?

Page 26: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: BE

I First, ask the following question: do we need to introduce newvariables relative to FA?

I Yes. We need to have bonds in each country. Anything else?

I Yes. The bond needs to have a price in equilibrium. Whatdoes this mean?

I If we have three new variables, we only need three newequations. Why do we have five? (Hint: remember whatchanged in FA relative to CM)

Page 27: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: BE

I The budget constraints also change, hence five equationsbetween the two setups: three new equations and twomodified budget constraints

I Where are the three new equations coming from?

I One is obvious: bond market clearing. What about the othertwo? What are

( c1 ˆmu∗(1−n1 )ˆ(1−mu) ) ˆ gamma/ c1∗(Q∗qa1+2∗qa1∗ p h i ∗B1) =be ta ∗ ( ( c1 (+1))ˆmu∗(1−n1 (+1))ˆ(1−mu) )ˆgamma/ c1 (+1)∗qa1 (+1);( c2 ˆmu∗(1−n2 )ˆ(1−mu) ) ˆ gamma/ c2∗(Q∗qa1+2∗qa1∗ p h i ∗B2) =be ta ∗ ( ( c2 (+1))ˆmu∗(1−n2 (+1))ˆ(1−mu) )ˆgamma/ c2 (+1)∗qa1 (+1);

Page 28: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: BE

I They are intertemporal Euler equations for bonds; hence wehave EEs for bonds and capital

I Are we done? No. Why not?

I Remember what we had to do in switching from CM to FA.

I We also have to declare the new variables and assign initialvalues to them.

Page 29: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Implementation in Dynare: FA

I The command declaring variables now becomes

v a r G1 , G2 , F1 , F2 , y1 , y2 , c1 , c2 , n1 , n2 ,k1 , k2 , x1 , x2 , a1 , a2 , b1 , b2 , z1 , z2 ,qa1 , qa2 , qb1 , qb2 , i r 1 , i r 2 , p , rx , xp ,

im , nx , r1 , r2 , w1 , w2 , B1 , B2 , Q;

I Initial values to help Dynare find steady state

B1 = 0 ;B2 = 0 ;Q = 1 ;

Page 30: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Two Things

I Two things before we move away from Dynare and back tothe model

I First, the code presented asks Dynare to compute linearapproximations of the levels of the variables

I We do this for presentation purposes (to avoid notationalclutter). To compute a long-linear version of the model,replace variables y with exp(y). Careful though: somevariables are already in logs so you need not add exp(.)!

I Second, bond economies like BE above tend to exhibit unitroot behavior; see Schmitt-Grohe and Uribe for ways on howto get around this issue

Page 31: Dynare Class on Heathcote-Perri JME 2002 - Weeblytimothyuy.weebly.com/uploads/2/5/9/1/2591989/heathcote_perri... · Dynare Class on Heathcote-Perri JME 2002 Tim Uy ... I To solve

Conclusion

I In this lecture, we looked at Heathcote-Perri JME 2002 and inparticular, how to implement the three economies thereinusing Dynare

I Aside from being an introduction to Dynare as it applies tointernational models, the paper addresses three counterfactualpredictions under CM: (1) high cross-country correlations ofconsumption relative to output; (2) negative cross-countrycorrelations of investment and labor; (3) low RER volatility

I The paper finds that the FA setup comes closest to the data

I The main reason is that in the absence of asset trade,quantities adjust less (hence lower consumption correlation,and also less investment and labor in country with positiveshock) so prices pick up the slack (hence more volatile RER)