89
Deterministic Models Perfect foresight, nonlinearities and occasionally binding constraints SØbastien Villemot June 12, 2018 SØbastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 1 / 72

Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Deterministic ModelsPerfect foresight, nonlinearities and occasionally binding constraints

Sébastien Villemot

June 12, 2018

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 1 / 72

Page 2: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Introduction

Perfect foresight = agents perfectly anticipate all future shocksConcretely, at period 1:

I agents learn the value of all future shocks;I since there is shared knowledge of the model and of future shocks,

agents can compute their optimal plans for all future periods;I optimal plans are not adjusted in periods 2 and later⇒ the model behaves as if it was deterministic.

Cost of this approach: the effect of future uncertainty is not takeninto account (e.g. no precautionary motive)Advantage: numerical solution can be computed exactly (up torounding errors), contrarily to perturbation or global solution methodsfor rational expectations modelsIn particular, nonlinearities fully taken into account (e.g. occasionallybinding constraints)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 2 / 72

Page 3: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 3 / 72

Page 4: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 4 / 72

Page 5: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The (deterministic) 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

Note the absence of stochastic elements!No expectancy term, no probability distribution

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 5 / 72

Page 6: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Dynare code (1/3)rcb_basic.mod

var c k;varexo A;parameters alpha beta gamma delta;

alpha=0.5;beta=0.95;gamma=0.5;delta=0.02;

model;c + k = A*k(-1)^alpha + (1-delta)*k(-1);c^(-gamma) = beta*c(+1)^(-gamma)*(alpha*A(+1)*k^(alpha-1) +

1 - delta);end;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 6 / 72

Page 7: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Dynare code (2/3)rcb_basic.mod

// Steady state (analytically solved)initval;A = 1;k = ((1-beta*(1-delta))/(beta*alpha*A))^(1/(alpha-1));c = A*k^alpha-delta*k;

end;

// Check that this is indeed the steady statesteady;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 7 / 72

Page 8: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Dynare code (3/3)rcb_basic.mod

// Declare a positive technological shock in period 1shocks;var A;periods 1;values 1.2;

end;

// Prepare the deterministic simulation over 100 periodsperfect_foresight_setup(periods=100);

// Perform the simulationperfect_foresight_solver;

// Display the path of consumptionrplot c;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72

Page 9: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Simulated consumption path

0 20 40 60 80 1005.9

5.95

6

6.05

6.1

Periods

Plot of c

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 9 / 72

Page 10: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The general problem

Deterministic, perfect foresight, case:

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

y : vector of endogenous variablesu : vector of exogenous shocks

Identification rule: as many endogenous (y) as equations (f )

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 10 / 72

Page 11: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Return to the neoclassical growth model

yt =(

ctkt

)

ut = At

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

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

(αAt+1kα−1

t + 1− δ)

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

)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 11 / 72

Page 12: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

What if more than one lead or one lag?

A model with more than one lead or lag can be transformed in theform with one lead and one lag using auxiliary variablesTransformation done automatically by DynareFor example, if there is a variable with two leads xt+2:

I create a new auxiliary variable aI replace all occurrences of xt+2 by at+1I add a new equation: at = xt+1

Symmetric process for variables with more than one lagWith future uncertainty, the transformation is more elaborate (butstill possible) on variables with leads

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 12 / 72

Page 13: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Steady state

A steady state, y , for the model satisfies

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

Note that a steady state is conditional to:I The steady state values of exogenous variables uI The value of parameters (implicit in the above definition)

Even for a given set of exogenous and parameter values, some(nonlinear) models have several steady statesThe steady state is computed by Dynare with the steady commandThat command internally uses a nonlinear solver

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 13 / 72

Page 14: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

A two-boundary value problem

Stacked system for a perfect foresight simulation over T periods:f (y2, y1, y0, u1) = 0f (y3, y2, y1, u2) = 0

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

for y0 and yT+1 given.

Compact representation:F (Y ) = 0

where Y =[

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

and y0, yT+1, u1 . . . uT are implicit

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 14 / 72

Page 15: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Solution of perfect foresight models

This technique numerically computes trajectories for given shocksover a finite number of periodsNo possibility of computing a recursive policy function (as withperturbation methods), because future shock paths are statevariables, and those are infinite-dimensional objectsHowever, it is possible to approximate the asymptotic return toequilibrium with yT+1 = y and a large enough TResolution uses a Newton-type method on the stacked system

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 15 / 72

Page 16: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 16 / 72

Page 17: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 18: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 19: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 20: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 21: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 22: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 23: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 24: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 25: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 26: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 27: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 28: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 29: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 30: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 31: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 32: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 33: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 34: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (unidimensional)

Copyright © 2005 Ralf Pfeifer / Creative Commons Attribution-ShareAlike 3.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 17 / 72

Page 35: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The Newton method (multidimensional)

Start from an initial guess Y (0)

Iterate. Updated solutions Y (k+1) are obtained by solving a linearsystem:

F (Y (k)) +[∂F∂Y

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

)= 0

Terminal condition:

||Y (k+1) − Y (k)|| < εY

or||F (Y (k))|| < εF

Convergence may never happen if function is ill-behaved or initialguess Y (0) too far from a solution⇒ to avoid an infinite loop, abort after a given number of iterations

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 18 / 72

Page 36: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Controlling the Newton algorithm from Dynare

The following options to the perfect_foresight_solver can be used tocontrol the Newton algorithm:

maxit Maximum number of iterations before aborting (default: 50)tolf Convergence criterion based on function value (εF ) (default:

10−5)tolx Convergence criterion based on change in the function

argument (εY ) (default: 10−5)stack_solve_algo select between the different flavors of Newton

algorithms (see thereafter)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 19 / 72

Page 37: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

A practical difficulty

The Jacobian can be very large: for a simulation over T periods of amodel with n endogenous variables, it is a matrix of dimension nT × nT .

Three alternative ways of dealing with the large problem size:Exploit the particular structure of the Jacobian using a relaxationtechnique developped by Laffargue, Boucekkine and Juillard (was thedefault method in Dynare ≤ 4.2)Handle the Jacobian as one large, sparse, matrix (now the defaultmethod)Block decomposition, which is a divide-and-conquer method,implemented by Mihoubi

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 20 / 72

Page 38: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Shape of the Jacobian

∂F∂Y =

B1 C1A2 B2 C2

. . . . . . . . .At Bt Ct

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

AT BT

where

As = ∂f∂yt−1

(ys+1, ys , ys−1)

Bs = ∂f∂yt

(ys+1, ys , ys−1)

Cs = ∂f∂yt+1

(ys+1, ys , ys−1)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 21 / 72

Page 39: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Relaxation (1/5)

The idea is to triangularize the stacked system:

B1 C1A2 B2 C2

. . . . . . . . .. . . . . . . . .

AT−1 BT−1 CT−1AT BT

∆Y = −

f (y2, y1, y0, u1)f (y3, y2, y1, u2)

...

...f (yT , yT−1, yT , uT−1)f (yT+1, yT , yT−1, uT )

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 22 / 72

Page 40: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Relaxation (2/5)

First period is special:

I D1B2 − A2D1 C2

A3 B3 C3. . . . . . . . .

AT−1 BT−1 CT−1AT BT

∆Y = −

d1f (y3, y2, y1, u2) + A2d1

f (y4, y3, y2, u3)...

f (yT , yT−1, yT , uT−1)f (yT+1, yT , yT−1, uT )

where

D1 = B−11 C1

d1 = B−11 f (y2, y1, y0, u1)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 23 / 72

Page 41: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Relaxation (3/5)

Normal iteration:

I D1I D2

B3 − A3D2 C3. . . . . . . . .

AT−1 BT−1 CT−1AT BT

∆Y = −

d1d2

f (y4, y3, y2, u3) + A3d2...

f (yT , yT−1, yT , uT−1)f (yT+1, yT , yT−1, uT )

where

D2 = (B2 − A2D1)−1C2

d2 = (B2 − A2D1)−1(f (y3, y2, y1, u2) + A2d1)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 24 / 72

Page 42: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Relaxation (4/5)

Final iteration:

I D1I D2

I D3. . . . . .

I DT−1I

∆Y = −

d1d2d3...

dT−1dT

where

dT = (BT − AT DT−1)−1(f (yT+1, yT , yT−1, uT ) + AT dT−1)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 25 / 72

Page 43: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Relaxation (5/5)

The system is then solved by backward iteration:

yk+1T = yk

T − dT

yk+1T−1 = yk

T−1 − dT−1 − DT−1(yk+1T − yk

T )...

yk+11 = yk

1 − d1 − D1(yk+12 − yk

2 )

No need to ever store the whole Jacobian: only the Ds and ds have tobe storedThis technique is memory efficient (was the default method in Dynare≤ 4.2 for this reason)Still available as option stack_solve_algo=6 ofperfect_foresight_solver command

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 26 / 72

Page 44: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Sparse matrices (1/3)Consider the following matrix with most elements equal to zero:

A =

0 0 2.5−3 0 00 0 0

Dense matrix storage (in column-major order) treats it as aone-dimensional array:

[0,−3, 0, 0, 0, 0, 2.5, 0, 0]

Sparse matrix storage:I views it as a list of triplets (i , j , v) where (i , j) is a matrix coordinate

and v a non-zero valueI A would be stored as

{(2, 1,−3), (1, 3, 2.5)}

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 27 / 72

Page 45: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Sparse matrices (2/3)

In the general case, given an m× n matrix with k non-zero elements:I dense matrix storage = 8mn bytesI sparse matrix storage = 16k bytesI sparse storage more memory-efficient as soon as k < mn/2

(assuming 32-bit integers and 64-bit floating point numbers)In practice, sparse storage becomes interesting if k � mn/2, becauselinear algebra algorithms are vectorized

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 28 / 72

Page 46: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Sparse matrices (3/3)

The Jacobian of the deterministic problem is a sparse matrix:I Lots of zero blocksI The As , Bs and Cs usually are themselves sparse

Family of optimized algorithms for sparse matrices (including matrixinversion for our Newton algorithm)Available as native objects in MATLAB/Octave (see the sparsecommand)Works well for medium size deterministic modelsNowadays more efficient than relaxation, even though it does notexploit the particular structure of the Jacobian⇒ now the default method in Dynare (stack_solve_algo=0)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 29 / 72

Page 47: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Block decomposition (1/3)

Idea: apply a divide-and-conquer technique to model simulationPrinciple: identify recursive and simultaneous blocks in the modelstructureFirst block (prologue): equations that only involve variablesdetermined by previous equations; example: AR(1) processesLast block (epilogue): pure output/reporting equationsIn between: simultaneous blocks, that depend recursively on eachotherThe identification of the blocks is performed through a matchingbetween variables and equations (normalization), then a reordering ofboth

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 30 / 72

Page 48: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Block decomposition (2/3)Form of the reordered Jacobian (equations in lines, variables in columns)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 31 / 72

Page 49: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Block decomposition (3/3)

Can provide a significant speed-up on large modelsImplemented in Dynare by Ferhat MihoubiAvailable as option block to the model commandBigger gains when used in conjunction with bytecode option

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 32 / 72

Page 50: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

HomotopyAnother divide-and-conquer method, but in the shocks dimensionUseful if shocks so large that convergence does not occurIdea: achieve convergence on smaller shock size, then use the resultas starting point for bigger shock sizeAlgorithm:

1 Starting point for simulation path: steady state at all t2 λ← 0: scaling factor of shocks (simulation succeeds when λ = 1)3 s ← 1: step size4 Try to compute simulation with shocks scaling factor equal to λ+ s

(using last successful computation as starting point)F If success: λ← λ + s. Stop if λ = 1. Otherwise possibly increase s.F If failure: diminish s.

5 Go to 4Can be combined with any deterministic solverUsed by default by perfect_foresight_solver (can be disabledwith option no_homotopy)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 33 / 72

Page 51: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 34 / 72

Page 52: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Example: neoclassical growth model with investment

The social planner problem is as follows:

max{ct+j ,`t+j ,kt+j}∞j=0

Et

∞∑j=0

βju(ct+j , `t+j)

s.t.

yt = ct + ityt = At f (kt−1, `t)

kt = it + (1− δ)kt−1

At = A?eat

at = ρ at−1 + εt

where εt is an exogenous shock.

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 35 / 72

Page 53: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Specifications

Utility function:

u(ct , `t) =

(cθt (1− `t)1−θ

)1−τ

1− τ

Production function:

f (kt−1, `t) =(αkψt−1 + (1− α)`ψt

) 1ψ

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 36 / 72

Page 54: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

First order conditions

Euler equation:

uc(ct , `t) = β Et[uc(ct+1, `t+1)

(At+1fk(kt , `t+1) + 1− δ

)]Arbitrage between consumption and leisure:

u`(ct , `t)uc(ct , `t) + At f`(kt−1, `t) = 0

Resource constraint:

ct + kt = At f (kt−1, `t) + (1− δ)kt−1

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 37 / 72

Page 55: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Dynare code (1/3)

var k, y, L, c, A, a;varexo epsilon;parameters beta, theta, tau, alpha, psi, delta, rho, Astar;

beta = 0.9900;theta = 0.3570;tau = 2.0000;alpha = 0.4500;psi = -0.1000;delta = 0.0200;rho = 0.8000;Astar = 1.0000;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 38 / 72

Page 56: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Dynare code (2/3)

model;a = rho*a(-1) + epsilon;A = Astar*exp(a);y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);k = y-c + (1-delta)*k(-1);(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);(c^theta*(1-L)^(1-theta))^(1-tau)/c =

beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);

end;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 39 / 72

Page 57: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Dynare code (3/3)

steady_state_model;a = epsilon/(1-rho);A = Astar*exp(a);Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)

/(1-alpha))^(1/psi);Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital

/Labour_per_unit_of_Capital;

% Compute steady state of the endogenous variables.L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)

*Output_per_unit_of_Labour^(1-psi)));c=Consumption_per_unit_of_Labour*L;k=L/Labour_per_unit_of_Capital;y=Output_per_unit_of_Capital*k;

end;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 40 / 72

Page 58: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Scenario 1: Return to equilibrium

Return to equilibrium starting from k0 = 0.5k.

Fragment from rbc_det1.mod...steady;

ik = varlist_indices(’k’,M_.endo_names);kstar = oo_.steady_state(ik);

histval;k(0) = kstar/2;

end;

perfect_foresight_setup(periods=300);perfect_foresight_solver;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 41 / 72

Page 59: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Scenario 2: A temporary shock to TFPThe economy starts from the steady stateThere is an unexpected negative shock at the beginning of period 1:ε1 = −0.1

Fragment from rbc_det2.mod...steady;

shocks;var epsilon;periods 1;values -0.1;

end;

perfect_foresight_setup(periods=300);perfect_foresight_solver;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 42 / 72

Page 60: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Scenario 3: Pre-announced favorable shocks in the futureThe economy starts from the steady stateThere is a sequence of positive shocks to At : 4% in period 5 and anadditional 1% during the 4 following periods

Fragment from rbc_det3.mod...steady;

shocks;var epsilon;periods 4, 5:8;values 0.04, 0.01;

end;

perfect_foresight_setup(periods=300);perfect_foresight_solver;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 43 / 72

Page 61: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Scenario 4: A permanent shockThe economy starts from the initial steady state (a0 = 0)In period 1, TFP increases by 5% permanently (and this wasunexpected)

Fragment from rbc_det4.mod...initval;epsilon = 0;

end;

steady;

endval;epsilon = (1-rho)*log(1.05);

end;

steady;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 44 / 72

Page 62: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Scenario 5: A pre-announced permanent shock

The economy starts from the initial steady state (a0 = 0)In period 6, TFP increases by 5% permanentlyA shocks block is used to maintain TFP at its initial level duringperiods 1–5

Fragment from rbc_det5.mod...// Same initval and endval blocks as in Scenario 4...

shocks;var epsilon;periods 1:5;values 0;

end;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 45 / 72

Page 63: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Summary of commands

initval for the initial steady state (followed by steady)endval for the terminal steady state (followed by steady)

histval for initial or terminal conditions out of steady stateshocks for shocks along the simulation path

perfect_foresight_setup prepare the simulationperfect_foresight_solver compute the simulation

simul do both operations at the same time (deprecated syntax,alias for perfect_foresight_setup +perfect_foresight_solver)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 46 / 72

Page 64: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Under the hoodThe paths for exogenous and endogenous variables are stored in twoMATLAB/Octave matrices:

oo_.endo_simul = ( y0 y1 . . . yT yT+1 )oo_.exo_simul’ = ( � u1 . . . uT � )

perfect_foresight_setup initializes those matrices, given theshocks, initval, endval and histval blocks

I y0, yT+1 and u1 . . . uT are the constraints of the problemI y1 . . . yT are the initial guess for the Newton algorithm

perfect_foresight_solver replaces y1 . . . yT in oo_.endo_simulby the solutionNotes:

I for historical reasons, dates are in columns in oo_.endo_simul and in lines inoo_.exo_simul, hence the transpose (’) above

I this is the setup for no lead and no lag on exogenousI if one lead and/or one lag, u0 and/or uT+1 would become relevantI if more than one lead and/or lag, matrices would be larger

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 47 / 72

Page 65: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Initial guess

The Newton algorithm needs an initial guess Y (0) = [y (0)1′. . . y (0)

T′].

What is Dynare using for this?

By default, if there is no endval block, it is the steady state asspecified by initval (repeated for all simulations periods)Or, if there is an endval block, then it is the final steady statedeclared within this blockPossibility of customizing this default by manipulatingoo_.endo_simul after perfect_foresight_setup (but of coursebefore perfect_foresight_solver!)If homotopy is triggered, the initial guess of subsequent iterations isthe result of the previous iteration

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 48 / 72

Page 66: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Alternative way of specifying terminal conditions

With the differentiate_forward_vars option of the model block,Dynare will substitute forward variables using new auxiliary variables:

I Substitution: xt+1 → xt + at+1I New equation: at = xt+1 − xt

If the terminal condition is a steady state, the new auxiliary variableshave obvious zero terminal conditionUseful when:

I the final steady state is hard to compute (this transformation actuallyprovides a way to find it)

I the model is very persistent and takes time to go back to steady state(this transformation avoids a kink at the end of the simulation if T isnot large enough)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 49 / 72

Page 67: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 50 / 72

Page 68: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Zero nominal interest rate lower bound

Implemented by writing the law of motion under the following form inDynare:

it = max{0, (1− ρi )i∗ + ρi it−1 + ρπ(πt − π∗) + εi

t

}Warning: this form will be accepted in a stochastic model, but theconstraint will not be enforced in that case!

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 51 / 72

Page 69: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Irreversible investmentSame model as above, but the social planner is constrained to positiveinvestment paths:

max{ct+j ,`t+j ,kt+j}∞j=0

∞∑j=0

βju(ct+j , `t+j)

s.t.

yt = ct + ityt = At f (kt−1, `t)

kt = it + (1− δ)kt−1

it ≥ 0At = A?eat

at = ρ at−1 + εt

where the technology (f ) and the preferences (u) are as above.

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 52 / 72

Page 70: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

First order conditions

uc(ct , `t)− µt = β Et[uc(ct+1, `t+1) (At+1fk(kt , `t+1) + 1− δ)

− µt+1(1− δ)]

u`(ct , `t)uc(ct , `t) + At fl (kt−1, `t) = 0

ct + kt = At f (kt−1, `t) + (1− δ)kt−1

Slackness condition:µt = 0 and it ≥ 0

or

µt > 0 and it = 0

where µt ≥ 0 is the Lagrange multiplier associated to the non-negativityconstraint for investment.

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 53 / 72

Page 71: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Mixed complementarity problems

A mixed complementarity problem (MCP) is given by:I function F (x) : Rn → Rn

I lower bounds `i ∈ R ∪ {−∞}I upper bounds ui ∈ R ∪ {+∞}

A solution of the MCP is a vector x ∈ Rn such that for eachi ∈ {1 . . . n}, one of the following alternatives holds:

I `i < xi < ui and Fi (x) = 0I xi = `i and Fi (x) ≥ 0I xi = ui and Fi (x) ≤ 0

Notation:` ≤ x ≤ u ⊥ F (x)

Solving a square system of nonlinear equations is a particular case(with `i = −∞ and ui = +∞ for all i)Optimality problems with inequality constraints are naturally expressedas MCPs (finite bounds are imposed on Lagrange multipliers)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 54 / 72

Page 72: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The irreversible investment model in Dynare

MCP solver triggered with option lmmcp ofperfect_foresight_solver

Slackness condition described by equation tag mcp

Fragment from rbcii.mod(c^theta*(1-L)^(1-theta))^(1-tau)/c - mu =beta*((c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta)-mu(+1)*(1-delta));

...[ mcp = ’i > 0’ ]mu = 0;

...perfect_foresight_setup(periods=400);perfect_foresight_solver(lmmcp, maxit=200);

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 55 / 72

Page 73: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 56 / 72

Page 74: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Simulating unexpected shocks

With a perfect foresight solver:shocks are unexpected in period 1but in subsequent periods they are anticipated

How to simulate an unexpected shock at a period t > 1?Do a perfect foresight simulation from periods 0 to T without theshockDo another perfect foresight simulation from periods t to T

I applying the shock in t,I and using the results of the first simulation as initial condition

Combine the two simulations:I use the first one for periods 1 to t − 1,I and the second one for t to T

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 57 / 72

Page 75: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

A Dynare example (1/2)Simulation of a scenario with:

Pre-announced (negative) shocks in periods 5 and 15Unexpected (positive) shock in period 10

From rbc_unexpected.mod:

...// Declare pre-announced shocksshocks;var epsilon;periods 5, 15;values -0.1, -0.1;

end;

perfect_foresight_setup(periods=300);perfect_foresight_solver;

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 58 / 72

Page 76: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

A Dynare example (2/2)

// Declare unexpected shock (after first simulation!)oo_.exo_simul(11, 1) = 0.1; // Period 10 has index 11!

// Strip first 9 periods and save themsaved_endo = oo_.endo_simul(:, 1:9); // Save periods 0 to 8saved_exo = oo_.exo_simul(1:9, :);oo_.endo_simul = oo_.endo_simul(:, 10:end); // Keep periods 9 to 301oo_.exo_simul = oo_.exo_simul(10:end, :);

periods 291;perfect_foresight_solver;

// Combine the two simulationsoo_.endo_simul = [ saved_endo oo_.endo_simul ];oo_.exo_simul = [ saved_exo; oo_.exo_simul ];

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 59 / 72

Page 77: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Consumption path

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 60 / 72

Page 78: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Extended path (EP) algorithmGeneralization of the previous method, where unexpected shocks mayhappen in all periodsAt every period, compute endogenous variables by running adeterministic simulation with:

I the previous period as initial conditionI the steady state as terminal conditionI a random shock drawn for the current periodI but no shock in the future

Advantages:I shocks are unexpected at every periodI nonlinearities fully taken into account

Inconvenient: solution under certainty equivalence (Jensen inequalityis violated)Method introduced by Fair and Taylor (1983)Implemented under the command extended_path (with optionorder = 0, which is the default)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 61 / 72

Page 79: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Extended path in Dynare

From rbc_ep.mod:

...// Declare shocks as in a stochastic setupshocks;var epsilon;stderr 0.02;

end;

extended_path(periods=300);

// Plot 20 first periods of consumptionic = varlist_indices(’c’,M_.endo_names);plot(oo_.endo_simul(ic, 1:21));

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 62 / 72

Page 80: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

k-step ahead extended path

Accuracy can be improved by computing conditional expectation byquadrature, computing next period endogenous variables with theprevious algorithmApproximation: at date t, agents assume that there will be no moreshocks after period t + k (hence k measures the degree of futureuncertainty taken into account)If k = 1: one-step ahead EP; no more certainty equivalenceBy recurrence, one can compute a k-step ahead EP: even moreuncertainty taken into accountDifficulty: computing complexity grows exponentially with kk-step ahead EP triggered with option order = k ofextended_path command

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 63 / 72

Page 81: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Outline

1 Presentation of the problem

2 Solution techniques

3 Shocks: temporary/permanent, unexpected/pre-announced

4 Occasionally binding constraints

5 More unexpected shocks, extended path

6 Dealing with nonlinearities using higher order approximation ofstochastic models

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 64 / 72

Page 82: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Local approximation of stochastic models

The general problem:

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

y : vector of endogenous variablesu : vector of exogenous shocks

with:

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

E(utu′s) = 0 for t 6= s

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 65 / 72

Page 83: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

What is a solution to this problem?

A solution is a policy function of the form:

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

where σ is the stochastic scale of the problem and:

ut+1 = σ εt+1

The policy function must satisfy:

Et f (g (g (yt−1, ut , σ) , ut+1, σ) , g (yt−1, ut , σ) , yt−1, ut) = 0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 66 / 72

Page 84: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Local approximations

g (1) (yt+1, ut , σ) = y + gy yt−1 + guut

g (2) (yt+1, ut , σ) = y + 12gσσ + gy yt−1 + guut

+ 12 (gyy (yt−1 ⊗ yt−1) + guu (ut ⊗ ut))

+ gyu (yt−1 ⊗ ut)

g (3) (yt+1, ut , σ) = y + 12gσσ + 1

6gσσσ + 12gσσy yt−1 + 1

2gσσuut

+ gy yt−1 + guut + . . .

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 67 / 72

Page 85: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Breaking certainty equivalence (1/2)

The combination of future uncertainty (future shocks) and nonlinearrelationships makes for precautionary motives or risk premia.

1st order: certainty equivalence; today’s decisions don’t depend onfuture uncertainty2nd order:

g (2) (yt+1, ut , σ) = y + 12gσσ + gy yt−1 + guut

+ 12 (gyy (yt−1 ⊗ yt−1) + guu (ut ⊗ ut))

+ gyu (yt−1 ⊗ ut)

Risk premium is a constant: 12gσσ

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 68 / 72

Page 86: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Breaking certainty equivalence (2/2)

3rd order:

g (3) (yt+1, ut , σ) = y + 12gσσ + 1

6gσσσ + 12gσσy yt−1 + 1

2gσσuut

+ gy yt−1 + guut + . . .

Risk premium is linear in the state variables:

12gσσ + 1

6gσσσ + 12gσσy yt−1 + 1

2gσσuut

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 69 / 72

Page 87: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

The cost of local approximations

1 High order approximations are accurate around the steady state, andmore so than lower order approximations

2 But can be totally wrong far from the steady state (and may be moreso than lower order approximations)

3 Error of approximation of a solution g , at a given point of the statespace (yt−1, ut):

E (yt−1, ut) =Et f (g (g (yt−1, ut , σ) , ut+1, σ) , g (yt−1, ut , σ) , yt−1, ut)

4 Necessity for pruning

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 70 / 72

Page 88: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Approximation of occasionally binding constraints withpenalty functionsThe investment positivity constraint is translated into a penalty on thewelfare:

max{ct+j ,`t+j ,kt+j}∞j=0

∞∑j=0

βju(ct+j , `t+j) + h · log(it+j)

s.t.

yt = ct + ityt = At f (kt−1, `t)

kt = it + (1− δ)kt−1

At = A?eat

at = ρ at−1 + εt

where the technology (f ) and the preferences (u) are as before, and hgoverns the strength of the penalty (barrier parameter)

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 71 / 72

Page 89: Deterministic Models - Perfect foresight, …Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 8 / 72 Simulatedconsumptionpath 0 20 40 60 80 100 5.9 5.95 6 6.05 6.1

Thanks for your attention!

Questions?

cba Copyright © 2015-2018 Dynare TeamLicense: Creative Commons Attribution-ShareAlike 4.0

Sébastien Villemot (CEPREMAP) Deterministic Models June 12, 2018 72 / 72