Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE...

64
Nonlinear approximation of DSGE models with Dynare. Workshop: Identication analysis and global sensitivity analysis for macroeconomic models Michel Juillard, Banque de France Ispra, November 24, 2017

Transcript of Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE...

Page 1: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Nonlinear approximation of DSGE modelswith Dynare.

Workshop: Identification analysis and global sensitivityanalysis for macroeconomic models

Michel Juillard, Banque de France

Ispra, November 24, 2017

Page 2: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

DYNARE

1. computes the solution of deterministic models (arbitraryaccuracy),

2. computes first, second and third order approximation tosolution of stochastic models,

Page 3: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

The general problem

Deterministic, perfect foresight, case:

f (yt+1, yt , yt−1,ut ) = 0

Stochastic case:

Et {f (yt+1, yt , yt−1,ut )} = 0

y : vector of endogenous variablesu : vector of exogenous shocks

Page 4: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Solution methods

I For a deterministic, perfect foresight, it is possible tocompute numerical trajectories for the endogenousvariables

I In a a stochastic framework, the unknowns are thedecision functions:

yt = g(yt−1,ut )

For a large class of DSGE models, DYNARE computesapproximated decision rules and transition equations by aperturbation method.

Page 5: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example: Neoclassical growth model

max{ct}∞t=1

∞∑t=1

βt−1 c1−σt

1− σ

s.t.ct + kt = Atkαt−1 + (1− δ)kt−1

First order conditions:

c−σt = βc−σt+1

(αAt+1kα−1

t + 1− δ)

ct + kt = Atkαt−1 + (1− δ)kt−1

Steady state:

k =

(1− β(1− δ)

βαA

) 1α−1

c = Akα − δk

Page 6: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Calibration

α = 0.3β = 0.98δ = 0.025σ = 1

Page 7: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Dynare syntax// variables declarationvar c k;varexo A;

// parameters declarationparameters alpha beta delta sigma;alpha = 0.3;beta = 0.98;delta = 0.025;sigma = 1;

// model equationsmodel;c^(-sigma) = beta*c(+1)^(-sigma)

*(alpha*A(+1)*k^(alpha-1)+1-delta);c+k = A*k(-1)^alpha+(1-delta)*k(-1);end;

Page 8: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Dynare syntax

// setting value for exogenous variable// providing exact value for steady state of// endogenous variablessteady_state_model;k = ((1-beta*(1-delta))/

(beta*alpha*A))^(1/(alpha-1));c = A*k^alpha-delta*k;end;

Page 9: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Computation of first order approximation

I Perturbation approach: recovering a Taylor expansion ofthe solution function from a Taylor expansion of the originalmodel.

I A first order approximation is nothing else than a standardsolution thru linearization.

I A first order approximation in terms of the logarithm of thevariables provides standard log-linearization.

Page 10: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

General model

Et {f (yt+1, yt , yt−1,ut )} = 0

E(ut ) = 0E(utu′t ) = Σu

E(utu′τ ) = 0 t 6= τ

y : vector of endogenous variablesu : vector of exogenous stochastic shocks

Page 11: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Timing assumptions

Et {f (yt+1, yt , yt−1,ut )} = 0

I shocks ut are observed at the beginning of period t ,I decisions affecting the current value of the variables yt , are

function ofI the previous state of the system, yt−1,I the shocks ut .

Page 12: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

The stochastic scale variable

Et {f (yt+1, yt , yt−1,ut )} = 0

I At period t , the only unknown stochastic variable is yt+1,and, implicitly, ut+1.

I We introduce the stochastic scale variable, σ and theauxiliary random variable, εt , such that

ut+1 = σεt+1

Page 13: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

The stochastic scale variable (continued)

E(εt ) = 0 (1)E(εtε

′t ) = Σε (2)

E(εtε′τ ) = 0 t 6= τ (3)

andΣu = σ2Σε

Page 14: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Remarks

Et {f (yt+1, yt , yt−1,ut )} = 0

I The exogenous shocks may appear only at the currentperiod

I There is no deterministic exogenous variablesI Not all variables are necessarily present with a lead and a

lagI Generalization to leads and lags on more than one period

(2nd order approximation requires a more complicatedalgorithm)

Page 15: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Solution function

yt = g(yt−1,ut , σ)

where σ is the stochastic scale of the model. If σ = 0, themodel is deterministic. For σ > 0, the model is stochastic.Under some conditions, the existence of g() function is provenvia an implicit function theorem. See H. Jin and K. Judd“Solving Dynamic Stochastic Models”(http://bucky.stanford.edu/papers/PerturbationMethodRatEx.pdf)

Page 16: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Solution function (continued)

Then,

yt+1 = g(yt ,ut+1, σ)

= g(g(yt−1,ut , σ),ut+1, σ)

F (yt−1,ut , εt+1, σ)

= f (g(g(yt−1,ut , σ), σεt+1, σ),g(yt−1,ut , σ), yt−1,ut )

Et {F (yt−1,ut , εt+1, σ)} = 0

Page 17: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

The perturbation approach

I Obtain a Taylor expansion of the unkown solution functionin the neighborhood of a problem that we know how tosolve.

I The problem that we know how to solve is the deterministicsteady state.

I One obtains the Taylor expansion of the solution for theTaylor expansion of the original problem.

I One consider two different perturbations:1. points in the neighborhood from the steady sate,2. from a deterministic model towards a stochastic one (by

increasing σ from a zero value).

Page 18: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

The perturbation approach (continued)

I The Taylor approximation is taken with respect to yt−1, utand σ, the arguments of the solution function

yt = g(yt−1,ut , σ).

I At the deterministic steady state, all derivatives aredeterministic as well.

Page 19: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Steady state

A deterministic steady state, y , for the model satisfies

f (y , y , y ,0) = 0

A model can have several steady states, but only one of themwill be used for approximation.Furthermore,

y = g(y ,0,0)

Page 20: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

First order approximated decision function

yt = y + gy y + guu

E {yt} = yΣy = gy Σyg′y + σ2guΣεg′u

The variance is solved for with an algorithm for Lyapunovequations.

Page 21: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Second and third order approximation of the model

I Second and third order approximation of the solutionfunction are obtained from second, respectively third, orderapproximation of the model.

I It requires only the solution of (tricky) linear problems.I The stochastic scale of the model, σ, appears in the

solution and breaks certainty equivalence

Page 22: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Second order approximation of the model

Et

{F (2)(yt−1, ut , εt+1, σ)

}=

Et

{F (1)(yt−1, ut , ut+1, σ)

+0.5(

Fy−y− (y ⊗ y) + Fuu(u ⊗ u) + Fu′u′σ2(ε′ ⊗ ε′) + Fσσσ

2)

+Fy−u(y ⊗ u) + Fy−u′ (y ⊗ σε′) + Fy−σ yσ + Fuu′ (u ⊗ σε′) + Fuσuσ + Fu′σσε′σ}

= Et

{F (1)(yt−1, ut , εt+1, σ)

}+0.5

(Fy−y− (y ⊗ y) + Fuu(u ⊗ u) + Fu′u′ (σ

2~Σε) + Fσσσ2)

+Fy−u(y ⊗ u) + Fy−σ yσ + Fuσuσ

= 0

Page 23: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Representing the second order derivatives

The second order derivatives of a vector of multivariatefunctions is a three dimensional object. We use the followingnotation

∂2F∂x∂x

=

∂2F1∂x1∂x1

∂2F1∂x1∂x2

. . . ∂2F1∂x2∂x1

. . . ∂2F1∂xn∂xn

∂2F2∂x1∂x1

∂2F2∂x1∂x2

. . . ∂2F2∂x2∂x1

. . . ∂2F2∂xn∂xn

....... . .

.... . .

...∂2Fm∂x1∂x1

∂2Fm∂x1∂x2

. . . ∂2Fm∂x2∂x1

. . . ∂2Fm∂xn∂xn

Page 24: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Composition of two functions

Let

y = g(s)

f (y) = f (g(s))

then,∂2f∂s∂s

=∂f∂y

∂2g∂s∂s

+∂2f∂y∂y

(∂g∂s⊗ ∂g∂s

)

Page 25: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Recovering gyy

Fy−y− = fy+ (gyy (gy ⊗ gy ) + gygyy ) + fy0gyy + B= 0

where B is a term that doesn’t contain second order derivativesof g().The equation can be rearranged:

(fy+gy + fy0) gyy + fy+gyy (gy ⊗ gy ) = −B

This is a Sylvester type of equation and must be solved with anappropriate algorithm.

Page 26: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Recovering gyu

Fy−u = fy+ (gyy (gy ⊗ gu) + gygyu) + fy0gyu + B= 0

where B is a term that doesn’t contain second order derivativesof g().This is a standard linear problem:

gyu = − (fy+gy + fy0)−1 (B + fy+gyy (gy ⊗ gu))

Page 27: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Recovering guu

Fuu = fy+ (gyy (gu ⊗ gu) + gyguu) + fy0guu + B= 0

where B is a term that doesn’t contain second order derivativesof g().This is a standard linear problem:

guu = − (fy+gy + fy0)−1 (B + fy+gyy (gu ⊗ gu))

Page 28: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Recovering gyσ, guσ

Fyσ = fy+gygyσ + fy0gyσ

= 0Fuσ = fy+gyguσ + fy0guσ

= 0

as gσ = 0. Thengyσ = guσ = 0

Page 29: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Recovering gσσ

Fσσ + Fu′u′Σε = fy+ (gσσ + gygσσ) + fy0gσσ+ (fy+y+(gu ⊗ gu) + fy+guu) ~Σε

= 0

taking into account gσ = 0.This is a standard linear problem:

gσσ = − (fy+(I + gy ) + fy0)−1 (fy+y+(gu ⊗ gu) + fy+guu) ~Σε

Page 30: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Second and third order decision functions

I Second order

yt = y + 0.5gσσσ2 + gy y + guu+ 0.5 (gyy (y ⊗ y) + guu(u ⊗ u)) + gyu(y ⊗ u)

I Third order

yt = y +12

gσσσ2 +16σ3 +

12

gyσσyσ2 +12

guσσuσ2

+ gy y + guu +12

(gyy (y ⊗ y) + guu(u ⊗ u)) + gyu(y ⊗ u)

+16

(gyyy (y ⊗ y ⊗ y) + guuu(u ⊗ u ⊗ u))

+12

(gyyu(y ⊗ y ⊗ u) + gyuu(y ⊗ y ⊗ u))

We can fix σ = 1.

Page 31: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Second order accurate moments

Σy = gy Σyg′y + σ2guΣεg′u

E {yt} = y + (I − gy )−1(

0.5(

gσσ + gyy ~Σy + guu~Σε

))

Page 32: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Further issues

I Impulse response functions depend of state at time ofshocks and history of future shocks.

I For large shocks second order approximation simulationmay explode

I pruning algorithm (Sims)I truncate normal distribution (Judd)

Page 33: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Dynare example: Neoclassical growth model (I)// variables declarationvar c k A;varexo ea;

// parameters declarationparameters alpha beta delta sigma;alpha = 0.3;beta = 0.98;delta = 0.025;sigma = 1;

// model equationsmodel;c^(-sigma) = beta*c(+1)^(-sigma)

*(alpha*A(+1)*k^(alpha-1)+1-delta);c+k = A*k(-1)^alpha+(1-delta)*k(-1);A = exp(ea);end;

Page 34: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Dynare example: Neoclassical growth model (II)

steady_state_model;A = 1;k = ((1-beta*(1-delta))/

(beta*alpha*A))^(1/(alpha-1));c = A*k^alpha-delta*k;end;

shocks;var ea; stderr 0.01;end;// display steady statesteady;// check BK conditionscheck;

stoch_simul(order=1);

Page 35: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Approximated decision function

POLICY AND TRANSITION FUNCTIONSc

Constant 1.875089k(-1) 0.072144ea 0.158801

ct ≈ 1.875 + 0.072(kt−1 − k) + 0.159eat

Page 36: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

The general problem

Deterministic, perfect foresight, case:

f (yt+1, yt , yt−1,ut ) = 0

y : vector of endogenous variablesu : vector of exogenous shocks

Page 37: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Solution of deterministic models

I based on work of Laffargue, Boucekkine and myselfI recently much accelerated by MihoubiI approximation: impose return to equilibrium in finite time

instead of asymptoticallyI computes the trajectory of the variables numericallyI uses a Newton–type methodI usefull to study full implications of non–linearities

Page 38: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Perfect foresight algorithm

Approximation of an infinite horizon model by a finite horizonone.The stacked system for a simulation on T periods:

f (y0, y1, y2, x1) = 0f (y1, y2, y3, x2) = 0

...f (yT−1, yT , yT +1, xT ) = 0

for y0 and yT +1 given, or

F (Y ) = 0

where Y =[

y ′1 y ′2 . . . y ′T]′.

Page 39: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A Newton approach

I for an initial guess Y (0)

I updated solutions Y (k+1) are obtained by solving[∂F∂Y

](Y (k+1) − Y (k)

)= −F (Y (k))

I until ||Y (k+1) − Y (k)|| < εY and/or ||F (Y (k))|| < εF .

Page 40: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A sparse Jacobian matrix

∂F

∂Y=

B1 C1A2 B2 C2

. . .. . .

. . .At Bt Ct

. . .. . .

. . .AT−1 BT−1 CT−1

AT BT

with

At =∂f (yt−1, yt , yt+1, xt )

∂yt−1

Bt =∂f (yt−1, yt , yt+1, xt )

∂yt

Ct =∂f (yt−1, yt , yt+1, xt )

∂yt+1

Page 41: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example: neoclassical growth model

max{ct}∞t=1

∞∑t=1

βt−1 c1−σt

1− σ

s.t.ct + kt = Atkαt−1 + (1− δ)kt−1

First order conditions:

c−σt = βc−σt+1

(αAt+1kα−1

t + 1− δ)

ct + kt = Atkαt−1 + (1− δ)kt−1

Steady state:

k =

(1− β(1− δ)

βαA

) 1α−1

c = Akα − δk

Page 42: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Calibration

α = 0.3β = 0.98δ = 0.025σ = 1

A = 1

First example: return to equilibrium when k0 = 0.5k .

Page 43: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

neoclassical1.mod

var c k;varexo A;

parameters alpha beta delta sigma;alpha = 0.3;beta = 0.98;delta = 0.025;sigma = 1;

model;c^(-sigma) = beta*c(+1)^(-sigma)

*(alpha*A(+1)*k^(alpha-1)+1-delta);c+k = A*k(-1)^alpha+(1-delta)*k(-1);end;

Page 44: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

neoclassical1.mod (continued)

steady_state_model;k = ((1-beta*(1-delta))/(beta*alpha*A))

^(1/(alpha-1));c = A*k^alpha-delta*k;end;

initval;A=1;end;

steady;

histval;k(0) = 0.5*((1-beta*(1-delta))/(beta*alpha*A))

^(1/(alpha-1));end;

Page 45: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

neoclassical1.mod (continued)

simul(periods=100);rplot k;rplot c;

Page 46: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A temporary shock to TFP

I the economy is at the steady stateI their is an unexpected drop in TFP of 10% at the beginning

of period 1I deterministic shocks are described in shocks blockI See neoclassical2.mod

Page 47: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Fragment from neoclassical2.modsteady_state_model;k = ((1-beta*(1-delta))/(beta*alpha*A))

^(1/(alpha-1));c = A*k^alpha-delta*k;end;

initval;A=1;end;

steady;

shocks;var A;periods 1;values 0.9;end;

Page 48: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A period of temporary favorable shocks announced inthe future

I the economy is at the steady stateI TFP jumps by 4% in period 4 and grows by 1% during the

4 following periodsI See neoclassical3.mod

shocks;var A;periods 4, 5, 6, 7, 8;values 1.04, 1.05, 1.06, 1.07, 1.08;end;

Page 49: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A permanent shock

I the economy is at the initial steady state (A = 1)I in period 1, TFP jumps to 1.05, permanentlyI See neoclassical4.mod

Page 50: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A permanent shock (continued)steady_state_model;k = ((1-beta*(1-delta))/(beta*alpha*A))

^(1/(alpha-1));c = A*k^alpha-delta*k;end;

initval;A=1;end;

steady;

endval;A=1.05;end;

steady;

Page 51: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A pre–announced permanent shock

I the economy is at the initial steady state (A = 1)I in period 6, TFP jumps to 1.05, permanentlyI one uses shocks to maintain TFP at initial value during

the first 5 periodsI See neoclassical5.mod

shocks;var A;periods 1:5;values 1;end;

Page 52: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

A two–country overlapping generation modelInspired by W. Buiter (1981) “Time Preference and InternationalLending and Borrowing in an Overlapping- Generations Model.”Journal of Political Economy, 89, pp. 769-97.

I All agents live for T periods. The first periods are spentworking. The last periods are spent in retirement.

I Agents of age i in country n = h, f maximizeT−i+1∑

t=1

(1

1 + ρn

)t−1 c1−σi,n,t

1− σ

I During their active life (TA periods), they supply one unit oflabor in each period.

I They face a budget constraint

si,n,t + ci,n,t = wt + (1 + rt )si−1,n,t−1

I During retirement, agents live out of their savings, withbudget constraint

si,n,t + ci,n,t = wt + (1 + rt )si−1,n,t−1

Page 53: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

OLG model (continued)I Agents enter active life without savings

s0,n,t = 0

I With perfect-foresight, they don’t leave any inheritance

sT ,n,t = 0

I There is a common technology worldwideI Wage rate

wt = (1− α)Akαt−1

I Rate of return on capital

rt = αAkα−1t−1

I Worldwide resource constraint with population sizes `n,t

kt(`h,t+1 + `f ,t+1

)= sh,t`h,t + sf ,t`f ,t

Page 54: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

First order conditions

c−σi,n,t =1

1 + ρnc−σi+1,n,t+1(1 + rt+1) i = 1, . . . ,T − 1

s1,n,t + c1,n,t = wt

si,n,t + ci,n,t = wt + (1 + rt )si−1,n,t1 i = 2, . . . ,TA

si,n,t + ci,n,t = (1 + rt )si−1,n,t−1 i = TA + 1, . . . ,T − 1cT ,n,t = (1 + rt )sT−1,n,t−1

wt = A(1− α)kαt−1

rt = αAkα−1t−1

kt(`h,t+1 + `f ,t+1

)= sh,t`h,t + sf ,t`f ,t

Page 55: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example: 2 countries, 2 generations

var w,hc1,hc2,fc1,fc2,r,k,hs,fs;varexo drho,fl,hl;

parameters sigma hrho frho alpha A;

sigma = .6;hrho=0.80;frho=0.80;alpha=0.2;A=1;

Page 56: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example: 2 countries, 2 generations (continued)

model;

(hc2(+1)/hc1)^sigma = (1+r(+1))/(1+hrho+drho);hs(-1)*(1+r) = hc2;w = hs + hc1;(fc2(+1)/fc1)^sigma = (1+r(+1))/(1+frho);fs(-1)*(1+r) = fc2;w = fs + fc1;

w = A*(1-alpha)*k(-1)^alpha;r = A*alpha*k(-1)^(alpha-1);k*(hl(+1)+fl(+1)) = hs*hl+fs*fl;end;

Page 57: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example: 2 countries, 2 generations (continued)initval;drho=0;fl=1;hl=1;

w=.28;hc1=.12;hc2=.16;fc1=.12;fc2=.16;k=0.15;r=0.6;hs=0.2;fs=0.2;end;

steady;

Page 58: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example: 2 countries, 2 generations (continued)

A permanent increase of the discount rate in the home country:

endval;drho=0.05;end;

steady;

simul(periods=20);

rplot hc1;rplot r;

Page 59: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example with macros

@#define countries = ["h", "f"]@#define T = 10@#define Ta = 6

var w r k;@#for c in countries@# for t in 1:T

var @{c}_c_@{t}@#if t < T@{c}_s_@{t}

@#endif;

@#endfor@#endfor

varexo drho f_l h_l;

Page 60: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example with macros (continued)

parameters sigma h_rho f_rho alpha A;

sigma = .6;h_rho=0.80;f_rho=0.80;alpha=0.2;A=1;

Page 61: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example with macros (continued)model;@#for c in countries

@# for t in 1:T-1@{c}_c_@{t}^(-sigma) =

@{c}_c_@{t+1}(+1)^(-sigma)*(1+r(+1))/(1+@{c}_rho+drho);

@#if t == 1@{c}_s_@{t} + @{c}_c_@{t} = w;

@#endif@#if (t > 1) && (t <= Ta)

@{c}_s_@{t} + @{c}_c_@{t} =w + (1+r)*@{c}_s_@{t-1}(-1);

@#endif@#if t > Ta

@{c}_s_@{t} + @{c}_c_@{t} =(1+r)*@{c}_s_@{t-1}(-1);

@#endif@#endfor@{c}_c_@{T} = (1+r)*@{c}_s_@{T-1}(-1);

@#endfor

Page 62: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example with macros (continued)

w = A*(1-alpha)*k(-1)^alpha;r = A*alpha*k(-1)^(alpha-1);(h_l(+1)+f_l(+1))*k = (h_s_1@#for t in 2:T-1+h_s_@{t}

@#endfor)*h_l + (f_s_1@#for t in 2:T-1+f_s_@{t}

@#endfor)*f_l;end;

Page 63: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example with macros (continued)initval;drho=0;f_l=1;h_l=1;

w=.5;@#for c in countries@#for t in 1:T@{c}_c_@{t} = 0.13;@#if t < T@{c}_s_@{t} = 0.2;

@#endif@#endfor

@#endfork=0.1;r=1.0;end;

Page 64: Nonlinear approximation of DSGE models with . · PDF fileNonlinear approximation of DSGE models with Dynare. Workshop: Identification analysis and global sensitivity analysis for

Example with macros (continued)

steady;

endval;drho=0.05;w=1.0;end;

steady;

simul(periods=20);

rplot h_c_1;rplot r;