Dynare Working Papers Series http://www.dynare.org/wp/

Solving rational expectations models at first order: what Dynare does S´ebastien Villemot

Working Paper no. 2 April 2011

142, rue du Chevaleret — 75013 Paris — France http://www.cepremap.ens.fr

Solving rational expectations models at first order: what Dynare does∗ S´ebastien Villemot† First version: December 2009

This version: April 2011

Abstract This paper describes in detail the algorithm implemented in Dynare for computing the first order approximated solution of a nonlinear rational expectations model. The core of the algorithm is a generalized Schur decomposition (also known as the QZ decomposition), as advocated by several authors in the litterature. The contribution of the present paper is to focus on implementation details that make the algorithm more generic and more efficient, especially for large models. JEL classification: C63; C68 Keywords: Dynare; Numerical methods; Perturbation; Rational expectations

1

Introduction

Perturbation techniques are widely used for solving and estimating rational expectation models and Dynare1 offers a popular, user-friendly access to these techniques. The purpose of the present paper is to describe in detail the algorithm implemented in Dynare for computing the first order approximated solution of nonlinear rational expectations models.2 This algorithm is based on a generalized Schur decomposition—also known as the QZ decomposition—and is therefore essentially a variation on the methods presented by Klein (2000), Sims (2002) and Uhlig (1999). The contribution of this paper is to present some implementation details that make the algorithm more generic and more efficient for large models. In particular I describe the algorithm for removing the leads and lags of more than one in a nonlinear model. I also describe a way ∗

c 2009, 2011 S´ebastien Villemot. Permission is granted to copy, distribute and/or modify this Copyright document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found at: http://www.gnu.org/licenses/fdl.txt The author acknowledges funding through the Seventh Framework Programme for Research (FP7) of the European Commission’s Socio-economic Sciences and Humanities (SSH) Program under grant agreement SSH-CT2009-225149. † Paris School of Economics and CEPREMAP. E-mail: [email protected]. 1 Dynare is a free software platform for handling a wide class of economic models. See http://www.dynare.org and Adjemian et al. (2011) for more details. 2 This algorithm is available using the stoch simul command of Dynare. The original implementation of this algorithm was done by Michel Juillard, using MATLAB, and is available in the matlab/dr1.m file which is distributed with Dynare. Another implementation was done by the author, in C++, in the DecisionRules class, in the mex/sources/estimation directory of the source tree. The notations used in the present paper are closer to the C++ implementation than to the MATLAB implementation.

1

of reducing the size of the Schur decomposition problem by dealing separately with endogenous variables that appear only at the current date (called static endogenous variables in the following). It should be noted that Dynare is able to go further than first order and can deliver second and third order approximation of the solution of rational expectations models. These higher order solutions can be computed recursively using the first order solution as a starting point. For algorithmic details on this issue, the interested reader can refer to Collard and Juillard (2001) or Schmitt-Groh´e and Ur´ıbe (2004). The rest of this paper is organized as follows. Section 2 presents the class of models to be solved and defines a typology of the endogenous variables. Section 3 defines the solution to the model and characterizes its first order approximation. Sections 4 and 5 describe the algorithm used to recover this first order approximation.

2 2.1

The problem to be solved The model

In the following, we consider a dynamic nonlinear rational expectations model composed of several variables (endogenous and exogenous) and several equations. In compact form, the model is written as: − + , ut ) = 0 (1) , yt , yt−1 Et f (yt+1 − + ) is the subset of variables of yt (resp. yt−1 where yt is the vector of endogenous variables, yt+1 that appear with a lead (resp. a lag), and ut is the vector of exogenous variables. For obvious identification reasons, the model must contain as many equations as there are endogenous variables; let n be this number. For the timing of variables, the convention used here is the same as in Dynare: a variable decided at date t should have a time subscript of t. For example, in a typical RBC model, the capital stock used to produce date t output is actually decided at date t − 1, so it will be written as kt−1 using this convention. Thus accordingly, the law of motion of capital will be kt = (1 − δ)kt−1 + it . Another way of expressing this timing convention is that stock variables should use the “end-of-period” convention. The vector of exogenous variables ut (of dimension p) follows a Markov process:

ut = P (ut−1 , εt ) where the εt are independent and identically distributed innovations with zero mean and variance-covariance matrix Σ. Note that the stochastic process adopted here for exogenous variables is more generic than the one allowed in Dynare (which only accepts a white noise for stochastic variables, i.e. ut = εt ).

2.2

Typology of variables

All endogenous variables are required to appear at least at one period. However it is not required that all endogenous variables appear at the current period (a weaker condition is actually sufficient, see assumption (5) below). We define four types of endogenous variables: Static endogenous variables: those that appear only at the current period. Their number is ns ≤ n, and their indices in the yt vector are ζjs , j = 1 . . . ns

2

Purely forward endogenous variables: those that appear only at the future period, possibly at the current period, but not at the previous period. Their number is n++ ≤ n, and their indices ζj++ , j = 1 . . . n++ Purely backward endogenous variables: those that appear only at the previous period, possibly at the current period, but not at the future period. Their number is n−− ≤ n, and their indices ζj−− , j = 1 . . . n−− Mixed endogenous variables: those that appear both at the future and the previous period, and possibly at the current period. Their number is nm ≤ n, and their indices ζjm , j = 1 . . . nm These four types of variables form a partition of the endogenous variables, and we therefore have: nm + n++ + n−− + ns = n We also define: Forward endogenous variables: the union of mixed and purely forward endogenous variables. Their number is n+ = n++ + nm , and their indices ζj+ , j = 1 . . . n+ . Backward endogenous variables: the union of mixed and purely backward endogenous variables. Their number is n− = n−− + nm , and their indices ζj− , j = 1 . . . n− Dynamic endogenous variables: all the variables except static endogenous variables. Their number is nd = n − ns , and their indices ζjd , j = 1 . . . nd The seven indices are such that 1 ≤ ζ1k < ζ2k < . . . < ζnkk ≤ n, where k ∈ {s, +, ++, −, −−, m, d}. We denote by yt = (y1,t , . . . , yn,t )0 the vector of endogenous variables at date t. We denote by k yt = (yζ k ,t , . . . , yζ k ,t )0 a subvector of endogenous variables, where k ∈ {s, +, ++, −, −−, m, d}. 1

nk

We denote by βj+ , j = 1 . . . nm the indices of mixed endogenous variables inside the ζj+ sequence, i.e. βj+ is such that ζβ++ is a mixed endogenous variable. We similarly define βj− j

for mixed endogenous variables inside the ζj− sequence. We similarly define πj+ (resp. πj− ) for purely forward (resp. purely backward) endogenous variables inside ζj+ (resp ζj− ). Finally, the vector of state variables is formed by the union of backward endogenous variables at the previous period and of exogenous variables at the current period, and is therefore of size n− + p.

2.3

Removing extra leads and lags

The form given in equation (1) makes the assumption that endogenous variables appear with at most one lead and one lag, and that exogenous variables appear only at the current period. This assumption does not imply any loss of generality, since it is easy to transform a nonlinear model with many leads and lags into an equivalent model of the form given in (1), as is detailed below.3 For every variable xt in the original model whose maximum lag is xt−d−k with k > 0 (and d = 1 if x is an endogenous variable or d = 0 if it is an exogenous variable), the transformation is the following: 3

The algorithm described in the present section is implemented in the Dynare preprocessor, since version 4.1. Auxiliary variables are created automatically and will show up at several places in Dynare output; see Adjemian et al. (2011) for the names of these variables.

3

• introduce k new endogenous variables ztj , for j ∈ {1, . . . , k}; • add k new equations to the model:  1 zt = xt−d ; j−1 ztj = zt−1 for j ∈ {2, . . . , k} j • replace all occurrences of xt−d−j (with j > 0) in the original model by zt−1 in the transformed model.

The transformation for variables with a lead is a bit more elaborate because one has to handle the fact that there is an expectation operator in front of all equations. The algorithm is as follows: • decompose every equation of the original model in the following form: X A+ Bi Et Ci = 0 i∈I

where A and the Bi are (possibly nonlinear) expressions containing only current or lagged variables, and the Ci are (possibly nonlinear) expressions which may contain leads; this decomposition is not unique, but one should aim at making the Ci terms as simple as possible; • for every Ci where there is a lead of 2 or more on an endogenous variable, or a lead on an exogenous variable: (−k)

– let k be the minimal number of periods so that Ci has at most one lead on (−k) endogenous variables and no lead on exogenous variables (where Ci stands for the transformation of Ci where all variables have been lagged by k periods); – introduce k new endogenous variables ztj , for j ∈ {1, . . . , k}; – add k new equations to the model: ( (−k) zt1 = Et Ci ; j−1 ztj = Et zt+1 for j ∈ {2, . . . , k} k – replace all occurrences of Et Ci in the original model by Et zt+1 in the transformed model.

It is straightforward to see that this transformed model is under the form given in (1). And by the law of iterated expectations, it is equivalent to the original one.

3

The solution and its first order approximation

We first define the deterministic steady state of the model as the vector (¯ y, u ¯, ε¯) satisfying: ε¯ = 0 u ¯ = P (¯ u, ε¯) f (¯ y + , y¯, y¯− , u ¯) = 0 4

Finding the deterministic steady state involves the resolution of a multivariate nonlinear system.4 Then, finding the rational expectation solution of the model means finding the policy functions (also known as decision rules), which give current endogenous variables as a function of state variables: − yt = g(yt−1 , ut ) Note that, by definition of the deterministic steady state, we have y¯ = g(¯ y−, u ¯). The function g is characterized by the following functional equation:   − − − Et f g + (g − (yt−1 , ut ), ut+1 ), g(yt−1 , ut ), yt−1 , ut = 0

(2)

where g + (resp. g − ) is the restriction of g to forward (resp. backward) endogenous variables. In the general case, this functional equation cannot be solved exactly, and one has to resort to numerical techniques to get an approximated solution. The remainder of this paper describes the first order perturbation technique implemented in Dynare. Let: fy+ =

∂f ∂f ∂f ∂f + , fy 0 = ∂y , fy − = − , fu = ∂u ∂yt+1 ∂yt−1 t t gy =

∂g ∂g − , gu = ∂u ∂yt−1 t

Pu =

∂P ∂P , Pε = ∂ut−1 ∂εt

where the derivatives are taken at y¯, u ¯ and ε¯. The first order approximation of the policy function is therefore: − − + gu u ˆt , ut ) = y¯ + gy yˆt−1 gˆ(yt−1 − − − y¯− , u ˆt = ut − u ¯, and gy and gu are unknowns at this stage. = yt−1 where yˆt−1 A first order approximation of (2) around y¯ and u ¯ gives: − f (¯ y + , y¯, y¯− , u ¯) + fy+ [gy+ (gy− yˆt−1 + gu− u ˆt ) + gu+ Et [Pu u ˆt + Pε εt+1 ]] − − + gu u ˆt ) + fy− yˆt−1 + fu u ˆt = 0 + fy0 (gy yˆt−1

where gy+ , gy− , gu− , gu+ are the derivatives of the restrictions of g with obvious notation. Computing the expectancy term, taking into account the property of the deterministic steady state, and reorganizing the terms, we obtain: − (fy+ gy+ gy− + fy0 gy + fy− )ˆ yt−1 + (fy+ gy+ gu− + fy+ gu+ Pu + fy gu + fu )ˆ ut = 0

(3)

In the next sections, we exploit this equation in order to recover the unknown coefficients gu and gy .

4

Recovering gy

− Taking into account the term multiplying yˆt−1 , equation (3) imposes:

fy+ gy+ gy− + fy0 gy + fy− = 0 4

Dynare offers efficient ways of performing this task, but this is out of the scope of the present paper.

5

This amounts to: + − fy+ yˆt+1 + fy0 yˆt + fy− yˆt−1 =0

(4)

Let S be the n × ns submatrix of fy0 where only the columns for static endogenous variables are kept, i.e. Si,j = fy0 ,i,ζjs . A QR decomposition5 gives S = QR where Q is an n×n orthogonal matrix and R an n × ns upper triangular matrix. For the model to be identified, we assume that: rank(R) = ns .

(5)

+ − A+ yˆt+1 + A0 yˆt + A− yˆt−1 =0

(6)

Thus, equation (4) can be rewritten as:

where A+ = Q0 fy+ , A0 = Q0 fy0 and A− = Q0 fy− . By construction, columns of static endogenous variables in A0 are zero in their lower part: ∀i > ns , ∀j ≤ ns , A0i,ζ s = 0. j

4.1

Non-static endogenous variables

Taking only the nd lower rows of system (6), we get: − + =0 + A˜0+ yˆt+ + A˜0− yˆt− + A˜− yˆt−1 A˜+ yˆt+1

(7)

where A˜+ (resp. A˜− ) contains the last nd rows of A+ (resp. A− ). Matrices A˜0+ and A˜0− can be defined in two ways, depending on where we deal with mixed endogenous variables: • A˜0+ is a submatrix of A0 where only the last nd rows and the columns for forward 0 ˜0− is such that purely backward endogenous variables are kept (A˜0+ i,j = Ans +i,ζ + ), and A j

columns are taken from A0 (A˜0− = A0ns +i,ζ −− ), and the rest is zero; i,π − j

j

• A˜0− is a submatrix of A0 where only the last nd rows and the columns for backward 0 ˜0+ is such that purely forward endogenous variables are kept (A˜0− i,j = Ans +i,ζ − ), and A j

columns are taken from

A0

(A˜0+ = A0ns +i,ζ ++ ), and the rest is zero. i,π + j

j

Note that in equation (7), static endogenous variables no longer appear. The structural state space representation of (7) is:  −   0−  −   yˆt yˆt−1 A˜ A˜+ −A˜− −A˜0+ = + yˆt+1 yˆt+ 0 I+ I− 0 | | {z } {z } D

where

I−

is an

nm

×

n−

E

− selection matrix for mixed endogenous variables, such that Ii,β − = 1, i

+ and zero otherwise. Similarly, I + is an nm × n+ matrix, such that Ii,β + = 1, and zero otherwise.

Therefore, D and E are square matrices of size n++ + n−− + 2nm . + Using the fact that yˆt+1 = gy+ yˆt− , this can be rewritten as:     In− In− − − D yˆt = E yˆt−1 gy+ gy+ 5

See Golub and Van Loan (1996, section 5.2).

6

i

(8)

where In− is the identity matrix of size n− . A generalized Schur decomposition (also known as the QZ decomposition) of the pencil (D, E) is performed:6  D = QT Z E = QSZ where T is upper triangular, S quasi upper triangular, and Q and Z are orthogonal matrices. The decomposition is done is such a way that stable generalized eigenvalues (modulus less than 1) are in the upper left corner of T and S. Matrices T and S are block decomposed so that the upper left block of both matrices is square and contains generalized eigenvalues of modulus less than 1, and the lower right block is square and contains generalized eigenvalues of modulus strictly greater than 1. Equation (8) can be rewritten as:         In− In− T11 T12 Z11 Z12 S11 S12 Z11 Z12 − − yˆt = yˆt−1 (9) gy+ gy+ 0 T22 Z21 Z22 0 S22 Z21 Z22 where T11 and S11 are square and contain stable generalized eigenvalues, while T22 and S22 are square and contain explosive generalized eigenvalues. To exclude explosive trajectories, we impose:      In− Z11 Z12 X (10) = gy+ Z21 Z22 0 which implies: gy+ = −(Z22 )−1 Z21 Note that the squareness of Z22 is the Blanchard and Kahn (1980) order condition (i.e. the requirement to have as many explosive eigenvalues as forward or mixed endogenous variables), and the non-singularity of Z22 is the Blanchard and Kahn (1980) rank condition. − , equation (9) implies: Using equation (10) and the fact that yˆt− = gy− yˆt−1 

T11 T12 0 T22

     S11 S12 X − X gy = 0 0 S22 0

0 )−1 , the upper part of this Then, using the fact that solving equation (10) for X gives X = (Z11 − system gives the solution for gy : −1 −1 0 0 −1 S11 (Z11 ) gy− = X −1 T11 S11 X = Z11 T11

Note that mixed variables appear in both g + and g − : the corresponding lines will be equal across the two matrices by construction.

4.2

Static endogenous variables

The ns upper lines of equation (6) can be written as: + − A˘+ yˆt+1 + A˘0d yˆtd + A˘0s yˆts + A˘− yˆt−1 =0

(11)

where A˘+ (resp. A˘− ) contains the first ns rows of A+ (resp. A− ). Matrix A˘0s (resp. A˘0d ) contains the first ns rows and only the static (resp. non-static) columns of A0 . Recall that A˘0s 6

See Golub and Van Loan (1996, section 7.7) for theoretical and practical details on this decomposition.

7

is a square upper triangular matrix by construction, and it is invertible because of assumption (5). Equation (11) can be rewritten as: − − − A˘+ gy+ gy− yˆt−1 + A˘0d gyd yˆt−1 + A˘0s yˆts + A˘− yˆt−1 =0

where gyd , the restriction of gy to non-static endogenous variables, is obtained by combining gy+ and gy− . We therefore have: h i−1   gys = − A˘0s A˘+ gy+ gy− + A˘0d gyd + A˘−

5

Recovering gu

Equation (3) restricted to u ˆt imposes: fy+ gy+ gu− + fy+ gu+ Pu + fy gu + fu = 0, and be rewritten as: (fy+ gy+ J − + fy )gu + fy+ J + gu Pu + fu = 0 where J − (resp J + ) is an n− × n matrix (resp. n+ × n matrix) selecting only the backward (resp. forward) endogenous variables. In the particular case solved by Dynare, where Pu = 0, the solution to this equation is: gu = −(fy+ gy+ J − + fy )−1 fu In the general case, this equation is a specialized Sylvester equation, which can be solved using the algorithm proposed by Kamenik (2003)7 .

References Adjemian, S., H. Bastani, M. Juillard, F. Mihoubi, G. Perendia, M. Ratto, and S. Villemot (2011): “Dynare: Reference Manual, Version 4,” Dynare Working Papers 1, CEPREMAP. Blanchard, O. J. and C. M. Kahn (1980): “The Solution of Linear Difference Models under Rational Expectations,” Econometrica, 48, 1305–11. Collard, F. and M. Juillard (2001): “A Higher-Order Taylor Expansion Approach to Simulation of Stochastic Forward-Looking Models with an Application to a Nonlinear Phillips Curve Model,” Computational Economics, 17, 125–39. Golub, G. H. and C. F. Van Loan (1996): Matrix Computations, The John Hopkins University Press, third ed. Kamenik, O. (2003): “Solution of Specialized Sylvester Equation,” Tech. rep., Manuscript. Klein, P. (2000): “Using the generalized Schur form to solve a multivariate linear rational expectations model,” Journal of Economic Dynamics and Control, 24, 1405–1423. 7

This paper is distributed with Dynare, in the sylvester.pdf file under the documentation directory.

8

´, S. and M. Ur´ıbe (2004): “Solving dynamic general equilibrium models Schmitt-Grohe using a second-order approximation to the policy function,” Journal of Economic Dynamics and Control, 28, 755–775. Sims, C. A. (2002): “Solving Linear Rational Expectations Models,” Computational Economics, 20, 1–20. Uhlig, H. (1999): “A toolkit for analysing nonlinear dynamic stochastic models easily,” in Computational Methods for the Study of Dynamic Economics, ed. by R. Marimon and A. Scott, Oxford University Press, 30–61.

9

Solving rational expectations models at first order: what ...

Apr 2, 2011 - The original implementation of this algorithm was done by Michel Juillard, using MATLAB, and is available in the matlab/dr1.m file which is distributed with Dynare. Another implementation was done by the author, in C++, in the DecisionRules class, in the mex/sources/estimation directory of the source tree.

348KB Sizes 0 Downloads 211 Views

Recommend Documents

Linear Rational Expectations Models: Construction ...
Oct 22, 2006 - suggestion that singular A matrices u[...] arise from nonexpectational behav' ior relations or dynamic identities present in the singular linear ...

Can Rational Expectations Sticky-Price Models Explain ...
marginal cost. The resulting measure of real marginal cost is labor's share of income (nom- inal compensation divided by nominal output). A. Output Gap Model ..... by agents at time t. Under rational expectations, the orthogonality condition. (17) E

Ambiguity and rational expectations equilibria
May 3, 2010 - the Spring 2007 Cornell/Penn State Macro Conference, 2007 GE Europe meeting, the 2007 ... In every market equilibrium, positive prices at least ...... We call conditional beliefs γ(·) that satisfy assumption 2 finitely-generated.

C3-L8 - Solving Rational Equations.pdf
Whoops! There was a problem loading more pages. Retrying... C3-L8 - Solving Rational Equations.pdf. C3-L8 - Solving Rational Equations.pdf. Open. Extract.

Rational Expectations and the Puzzling No-Effect of the ... - CiteSeerX
Germany. Phone: +49-228-3894-0 ... The Institute for the Study of Labor (IZA) in Bonn is a local and virtual international research center and a place of ..... Those markets are characterized by a large number of relatively small employers and high .

Estimating the rational expectations model of ...
The objective is to estimate when f()) does not have a tractable form, but the data for y. R ... most empirical applications of SMM use simulations, we will continue to refer to the SMM as a ...... Princeton University Press, Princeton,. NJ. Du$e, D.

Adaptive Monetary Policy and Rational Expectations
Park, Los Angeles, California. 9ooO7. Received May 16 .... necessary and sufficient conditions for the stability of a second order system see Gandolfo [6, p. 561.

First-Order Probabilistic Models for Information Extraction
highly formatted documents (such as web pages listing job openings) can be ..... likely to be transcribed as “Doctor Zhivago” or “Doctor Zi- vago”. Then when we ...

Self-Fulfilling Mechanisms and Rational Expectations in ...
by Pf , such that Pf (s) = Pf (r) ⇔ f(s) = f(r), for all s, r ∈ S. The private information of each trader t ∈ T is described by a partition Pt of S. If s in. S occurs, each ...

Rational Expectations and the Puzzling No-Effect of ...
the analysis of the effects of the minimum wage on employment. We show in a standard ..... effi cient and may compensate for the reduction in job openings.8. In this paper we ...... Princeton, NJ: Princeton University Press. Card, D. and A. B. ...

Estimating the rational expectations model of ...
We begin with an illustration of how the three estimators work in a very simple example. ... in Gauss is used to draw random numbers with seed and seed .... gg"50 in this paper, and found no signi"cant changes in the resulting price function or ...

Rational Expectations and the Puzzling No-Effect of the ... - CiteSeerX
Germany. Phone: +49-228-3894-0. Fax: +49-228-3894-180. E-mail: [email protected] ... The Institute for the Study of Labor (IZA) in Bonn is a local and virtual ...

First Hour-Expectations-2.pdf
... tutorial on the Pacer's website. Speed Skates can. not be sharpened by a machine. You should sharpen the blades every 23 weeks. Check the blades after.

C1-L8 - Solving Rational Equations and Inequalities.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. C1-L8 - Solving ...

C1-L8 - Solving Rational Equations and Inequalities.pdf
Page 2 of 3. MHF4U1 Date: Strategies for solving a rational inequality like: Example: Therefore the function. (The lower branch and the part of the upper branch that is to the right of 5.2). Page 2 of 3 ...

The Solution of Linear Difference Models under Rational ...
We use information technology and tools to increase productivity and facilitate new forms. of scholarship. For more information about JSTOR, please contact ...

Bayesian Variable Order Markov Models
ference on Artificial Intelligence and Statistics (AISTATS). 2010, Chia Laguna .... over the set of active experts M(x1:t), we obtain the marginal probability of the ...

Solving Dynamic Models with Heterogeneous Agents ...
Uhlig's toolbox, Schmitt-Grohe and Uribe codes, Dynare, ...). ▻ Issues that require heterogeneous agent framework. ▻ Distribution of wealth and income.