Top Banner
Linear Rational Expectations Models: Construction, Solution and Applications Michael K. Johnston and Robert G. King February 10, 2008
58

Linear Rational Expectations Models: Construction, Solution

Feb 03, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linear Rational Expectations Models: Construction, Solution

Linear Rational Expectations Models:Construction, Solution and Applications

Michael K. Johnston and Robert G. King

February 10, 2008

Page 2: Linear Rational Expectations Models: Construction, Solution

Contents

1 A quick theoretical review 1

2 A Basic Muthian Model 32.1 Analytical approach . . . . . . . . . . . . . . . . . . . . . . . . 3

2.1.1 System Reduction . . . . . . . . . . . . . . . . . . . . . 42.1.2 Counting rule . . . . . . . . . . . . . . . . . . . . . . . 52.1.3 Solving the reduced system a la Blanchard-Kahn . . . 62.1.4 Imposing the driving process. . . . . . . . . . . . . . . 7

2.2 Numerical analysis . . . . . . . . . . . . . . . . . . . . . . . . 82.2.1 Step 1: Variable List Speci�cation . . . . . . . . . . . . 92.2.2 Step 2: Coe¢ cient Matrix Speci�cation . . . . . . . . . 102.2.3 Step 3: Driving Process Speci�cation . . . . . . . . . . 122.2.4 Step 4: Start RESOLKW . . . . . . . . . . . . . . . . 13

2.3 Listing of system �le . . . . . . . . . . . . . . . . . . . . . . . 16

3 First-order form 213.1 Another Muth Example . . . . . . . . . . . . . . . . . . . . . 213.2 More tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.2.1 Lagged expectations . . . . . . . . . . . . . . . . . . . 23

3.2.2 Longer lags . . . . . . . . . . . . . . . . . . . . . . . . 233.2.3 Longer leads . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.4 Recursive Equilibria . . . . . . . . . . . . . . . . . . . 24

v

Page 3: Linear Rational Expectations Models: Construction, Solution

vi CONTENTS

4 DSGE modeling 274.1 Developing model equations . . . . . . . . . . . . . . . . . . . 27

4.1.1 First order conditions . . . . . . . . . . . . . . . . . . . 284.1.2 Driving process . . . . . . . . . . . . . . . . . . . . . . 29

4.2 Linear Approximation (Analytical) . . . . . . . . . . . . . . . 294.3 Steps in specifying the model . . . . . . . . . . . . . . . . . . 32

4.3.1 Step 1: Variable List Speci�cation . . . . . . . . . . . . 324.3.2 Step 2A: Steady State Calculation . . . . . . . . . . . . 334.3.3 Step 2B: Implications for model coe¢ cients . . . . . . 36

4.3.4 Step 2C: Coe¢ cient matrix speci�cation . . . . . . . . 37

4.3.5 Listing of system program (linrbc.m) . . . . . . . . . . 39

4.3.6 Step 3: Driving Process Speci�cation . . . . . . . . . . 414.3.7 Step 4: Compute solution using RESOLKW . . . . . . 42

5 Using the RE Solution 455.1 Impulse Responses . . . . . . . . . . . . . . . . . . . . . . . . 455.2 Frequency domain implications . . . . . . . . . . . . . . . . . 475.3 Spectra of �ltered series . . . . . . . . . . . . . . . . . . . . . 485.4 Population Second Moments . . . . . . . . . . . . . . . . . . . 49

5.4.1 Frequency domain computation of moments . . . . . . 495.5 Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5.5.1 Arti�cial shock inputs . . . . . . . . . . . . . . . . . . 525.5.2 VAR shock inputs . . . . . . . . . . . . . . . . . . . . . 52

5.5.3 Filtering simuluation results . . . . . . . . . . . . . . . 52

6 Timing Models 53

7 Strategies for Larger Models 557.1 Pre-Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Page 4: Linear Rational Expectations Models: Construction, Solution

Introduction

Macroeconomic research makes substantial use of linear rational expectationsmodels of the form

A Etyt+1 = B yt +JXj=0

Cj Etxt+j (1)

where y is a vector of endogenous variables, x is a vector of exogenous vari-ables, and A, B, and C(F ) are matrices of coe¢ cients. Some of the elementsof yt are predetermined, in that they cannot respond to unexpected variationsin xt.

These models are usually solved under the assumption that there is adriving process for the exogenous variable which respond to state variables,as in

xt = Q & t (2)

& t = � & t�1 +G "t (3)

where � is a matrix of coe¢ cients for the autoregressive process andG governsthe response of the exogenous state variables to innovations "t:

Under conditions elaborated in the literature and below, there is a uniquestable rational expectations solution that can be cast in the following statespace form,

ix

Page 5: Linear Rational Expectations Models: Construction, Solution

x CONTENTS

24ytxt

35 =

24�yk �y&0 Q

35| {z }

24kt& t

35| {z }St

(4)

24kt& t

35| {z }St

=

24Mkk Mk&

0 �

35| {z }

M

24kt�1& t�1

35| {z }St�1

+

240G

35| {z }G

"t (5)

where � de�nes the relation between the rational expectations link betweenthe observable variables at a given point at time and the state variables ofthe same period. The vector of state variables St contains both endogenouspredetermined kt and exogenous xt variables. The second equation gives thedynamic behavior of the state variables as a function of their values in theprevious period and current period innovations.This document describes three aspects of constructing such rational ex-

pectations models:Step 1: Formulation of the linear model (1)Step 2: Formulation of the driving process (2,3)Step 3: Use of the RE solution (4,5) in various applied contexts, including

stochastic simulation; impulse response analysis; time and frequency domainmoments and so forth.The document also reviews two aspects of computation that can be im-

portant for constructing and using rational expectations models. First, weprovide a brief guide to the theory of such model solution as developed inBlanchard and Kahn [1980] and King and Watson [1998]. Second, we de-scribes the solution of these models along lines described by King andWatson[2002], which is one method of moving from (1,2,3) to (4,5).To begin using these programs, you must unzip the �le KWRE.zip to

make use of the core programs and to explore introductory programs thatare associated with the examples in this document. In the discussion thatfollows, it is assumed that this directory is located on the "C" drive and iscalled "C:/KWRE/". To unzip the �le, then you would place it in the "C"directory of your computer and then use Windows Explorer to extract the�les, by going to "�le" (alt-f) and then selecting "extract all" option, whichwill automatically create the following directories and subdirectories

Page 6: Linear Rational Expectations Models: Construction, Solution

CONTENTS xi

level name task

D c:/KWRE entire package

S c:/KWRE/main core solution programs

S c:/KWRE/utilities utilities, mainly for setting up model

S c:/KWRE/outputs programs for impulse responses, moments, etc

S c:/KWRE/examples examples discussed in this guide

Page 7: Linear Rational Expectations Models: Construction, Solution

Chapter 1

A quick theoretical review

The linear rational expectations model (1) has been much studied in the lit-erature, following the important work of Blanchard and Kahn [1980].1 Theseauthors studied the nonsingular case, where A could be inverted to yield

Etyt+1 = Wyt +JXj=0

j Etxt+j (1.1)

with W = A�1B and j = A�1Cj.Blanchard and Kahn [1980] established that there was a unique stable

rational expectations solution to this model so long as two conditions weresatis�ed. First, there have to be as many stable eigenvalues of W as there arepredetermined variables, a result which is sometimes called the "Blanchardand Kahn counting rule" and has been widely used in applied research. Sec-ond, a particular matrix which linked the unstable "canonical variables" andnonpredetermined variables had to be of full rank. This "rank condition" canonly be checked in the course of a detailed model solution and has thereforebeen less stressed.King and Watson [1998] established that a unique stable rational expec-

tations solution obtained for the general model (1) so long as the followingconditions were ful�lled. First, there has to exist some scalar z such that

jAz �Bj 6= 0

as a necessary condition for any nontrivial solution to exist. Second, theBlanchard and Kahn counting rule, stated as equality between the number

1For additional details in the current notation, see King and Watson [1998].

1

Page 8: Linear Rational Expectations Models: Construction, Solution

2 CHAPTER 1 A QUICK THEORETICAL REVIEW

of stable roots and predetermined variables, must be satis�ed for there tobe a unique stable rational expectations solution. In this formulation of thecounting rule, a root is a solution to

jAz �Bj = 0

i.e., a generalized eigenvalue of the matrices A and B. Third, a generalizedrank condition has to be satis�ed.King and Watson [2002] also established that any solvable model of the

form (1), including models with multiple solutions, also possessed a reduceddimension dynamic system of the form

ft = Hdt +

JfXj=0

fj Etxt+j (1.2)

Etdt+1 = Wdt +

JdXj=0

dj Etxt+j (1.3)

They also described an algorithm for computing this "system reduction"and an additional algorithm for solving the resulting lower dimension dy-namic model (1.3) using variants of the Blanchard-Kahn approach that areimprovements from the standpoint of numerical analysis.

Page 9: Linear Rational Expectations Models: Construction, Solution

Chapter 2

A Basic Muthian Model

To begin the discussion of solving and using linear rational expectationsmodels, it is convenient to study an example in the style of Muth [1961]. Weconsider this model �rst from an analytical standpoint and we then considerit as an application of the methods described in this handbook.

2.1 Analytical approach

The basic Muthian model is convenient in that it is already linear, does notrequire steady state calculation, and it is simple enough to be solved easily byhand. In this model, expectations are important in that inventory investmenttoday is based upon expectations about price in the future.

Supply : qt = �pt + kt

Demand : qt = ��pt + xt + kt+1

Investment : kt+1 = �[�Etpt+1 � pt]

The three behavioral equations of the model are respectively, a supply curvefor the agricultural product that depends positively on the current price (pt)and stock brought into the period (kt); a demand that depends negatively oncurrent price but positively on a demand shock (xt) and a demand for stockto be carried over (kt+1); and an investment demand that depends positivelyon the gap between the discounted (at rate � < 1) future expected price(Etpt+1) and the current price pt.

3

Page 10: Linear Rational Expectations Models: Construction, Solution

4 CHAPTER 2 A BASIC MUTHIAN MODEL

If we write this as a linear di¤erence system, we have:

266640 0 0

0 0 1

0 ��� 1

37775| {z }

A

Et

26664qt+1

pt+1

kt+1

37775| {z }yt+1

=

26664�1 � 1

1 � 0

0 �� 0

37775| {z }

B

26664qt

pt

kt

37775| {z }yt

+

266640

�1

0

37775| {z }

C

xt

From the presence of a row of zeros, it is clear that the matrixA is singularand cannot be inverted. This leaves the model in a form which cannot besolved by the method described in Blanchard and Kahn [1980].

2.1.1 System Reduction

However, it is possible to reduce the system analytically by hand. Equatingsupply and demand, we determine a restriction on price, �pt + kt = ��pt +xt + kt+1. (We also know that we can always determine quantity from thesupply curve once we have solve for pt and kt.)

Eliminating qt, we thus have a simpli�ed system with two equations:

Price : �pt + kt = ��pt + xt + kt+1

Investment : kt+1 = �[�Etpt+1 � pt]

We can write this system as a linear di¤erence system,

24��� 10 1

35| {z }

A

Et

24pt+1kt+1

35| {z }yt+1

=

24 �� 0

�+ � 1

35| {z }

B

24ptkt

35| {z }yt

+

24 0�1

35| {z }

C

xt

which has an nonsingular matrix A so long neither of � and � is equal to zero.Since A is nonsingular, we can solve for the reduced system by inverting A

Page 11: Linear Rational Expectations Models: Construction, Solution

2.1 ANALYTICAL APPROACH 5

and premultiplying,

Et

24pt+1kt+1

35| {z }yt+1

=

24� 1��

1��

0 1

3524 �� 0

�+ � 1

35| {z }

W

24ptkt

35| {z }yt

+

24� 1��

1��

0 1

3524 0�1

35| {z }

xt

=

24 1� + �+���

1��

�+ � 1

35| {z }

W

24ptkt

35| {z }yt

+

24� 1��

�1

35| {z }

xt

This small system thus provides an example of King and Watson�s [1998]suggestion that singular A matrices �[...] arise from nonexpectational behav-ior relations or dynamic identities present in the singular linear di¤erencesystem.�It also illustrates the idea of system reduction: equating supply anddemand to eliminate quantity creates a smaller system in which the leadmatrix A is nonsingular.

2.1.2 Counting rule

As discussed above, Blanchard and Kahn [1980] specify a �counting rule�that is a necessary condition for a unique and stable solution. This ruleis sometimes stated as "the number of unstable roots must be equal to thenumber of nonpredetermined variables" and sometimes as "the number ofstable roots must be equal to the number of predetermined variables". An-alytically, a root z is considered stable i¤ jzj < 1 and is considered unstablei¤ jzj > 1: In the present system, there is one predetermined variable (kt)and one nonpredetermined variable (pt). To check the Blanchard and Kahn�counting rule�analytically, we examine the system eigenvalues. These maybe written either as jIz � W j = 0 or as jAz � Bj = 0: the result is thesame because the roots of the characteristic polynomials are the same (i.e.,jAz � Bj = jAA�1[Az � B]j = jA[Iz �W ]j = jAjjIz �W j = 0 which di¤eronly by a constant term that does not a¤ect the roots). It is sometimes con-venient for us to calculate one expression or the other. Using either of theseapproaches, we determine that the roots are the solutions to

z2 ��1 +

1

�+�+ �

��

�z +

1

�= 0

Page 12: Linear Rational Expectations Models: Construction, Solution

6 CHAPTER 2 A BASIC MUTHIAN MODEL

Hence, if we call the roots �1 and �2, then it follows that (z � �1)(z � �2) =z2 �

�1 + 1

�+ �+�

��

�z + 1

�= 0 implies that

�1�2 =1

�1 + �2 = 1 +1

�+�+ �

��

From above, we take that � < 1: For � + � = 0; the roots are 1 and 1�:

For �+ � < 0, both roots are greater than one (in modulus) and there is nostable solution. For � + � > 0, there are two unique roots, one greater thanone and one less than one, and the Blanchard and Kahn "counting rule" issatis�ed.1

2.1.3 Solving the reduced system a la Blanchard-Kahn

Any nonsingular system of the form (1.1) can be studied using the approach ofBlanchard and Kahn. We �rst describe this approach and then we determinethe solution for the particular two variable system at hand. The BK approachis based on the Jordan form of the matrix W (also called canonical form;see the appendix on Mathematics), with the model�s equations and variabletransformed by the eigenvectors of W . That is, let P � [P1; :::; Pn] be ann � n matrix of eigenvectors and let J be the Jordan matrix, assumed tocontain the roots on its diagonal with these roots ordered in diminishingabsolute value. Since W � PJP�1, the system can be written as

Etyt+1 = Wyt +0xt +1Etxt+1

Etyt+1 = PJP�1yt +0xt +1Etxt+1

EtP�1yt+1| {z }y�t+1

= P�1PJP�1yt| {z }y�t

+ P�1[0xt +1Etxt+1]

Ety�t+1 = Jy�t +

�0xt +

�1Etxt+1

As the Jordan matrix is block diagonal, the system is e¤ectively decou-pled. That is, the system can be partitioned into two sets of equations: oneset governs stable dynamics and the other governs unstable dynamics. More

1Study problem: verify that the roots of the original three variable system are thesame as those of the reduced system.

Page 13: Linear Rational Expectations Models: Construction, Solution

2.1 ANALYTICAL APPROACH 7

speci�cally, the partitioning implies that there are "canonical variables" withstable dynamics (st) and with unstable dynamics (ut):

Etut+1 = Juut +�0uxt +

�1uEtxt+1

Etst+1 = Jsst + C�0sxt + C�1sEtxt+1

where Ju and Js are partitions from the Jordan matrix, one containing stableroots and the other containing unstable roots.The unstable equations of this model can be solved by unwinding forward

the unstable canonical variables forward, as suggested by Sargent [xxxx].

ut = J�1u [Etut+1 +�0uxt +

�1uEtxt+1]

= �1Xi=0

�J�1u

�i+1Et [

�0uxt+i +

�1uEtxt+i+1]

The nonpredetermined and predetermined variables in which we truly in-terested are linked to the related to the solution derived for the stable andunstable partitions above,24Vu� Vuk

Vsk Vsk

3524�tkt

35 =24�tst

35 :Hence, the solutions for the predetermined and nonpredetermined vari-

ables, respectively, are:

kt+1 = wkkkt + wk��t +0kxt +1kEtxt+1

�t = V �1u� [ut � Vukkt]

Note that this solution requires the Blanchard-Kahn "rank condition", whichis that Vu� is of full rank.

2.1.4 Imposing the driving process.

The discussion has proceeded to this point without imposing any assumptionsabout the driving process. However, let�s now assume that it takes the form

xt = q& t

& t = �& t�1 + g"t

Page 14: Linear Rational Expectations Models: Construction, Solution

8 CHAPTER 2 A BASIC MUTHIAN MODEL

which is a version of (2,3) but will lower case letters to remind us that allvariables are scalars. Hence, given this system

Etxt+j = q�j& t.

Using this in the solutions above, we can write

ut = �qf1Xi=0

�J�1u

�i+1Et��0u�

i +�1u�i+1�g& t = �u&& t

then

�t = V �1u� [ut � Vukkt] = V �1

u� �u&& t � V �1u� Vukkt = ��&& t + ��kkt

kt+1 = wkkkt + wk��t +0kq& t +1kq�& t

= wkkkt + wk�(��&& t + ��kkt) + 0kq& t +1kq�& t

= �k&& t + �kkkt

which completes the derivations necessary to place the system in state spaceform.

2.2 Numerical analysis

The solution of the singular model considered above can be obtained usingthe method of King and Watson [2002]. In what follows, code shown istaken from �les in the c:nKWREnexamplesnEX1_muth2 directory. To run theprograms, you need to make this your active directory. You also need torun a SETPATH.m command at the beginning of the session, which modi�esthat path structure so that MATLAB knows where to look for the solutioncode and utilities. Hence, if you have chosen a location other than c:nKWREas a location to unzip the �les, setpath.m must be edited. Notice that thesetpath command contains links to the main model solution programs, theutilities for setting up the model and the output programs.

1 % setpath.m2

3 path(path,�C:\KWRE\main�)4 path(path,�C:\KWRE\utilities�)5 path(path,�C:\KWRE\outputs�)

Page 15: Linear Rational Expectations Models: Construction, Solution

2.2 NUMERICAL ANALYSIS 9

Notice that there are line numbers to the left of the text material: this isa signal that you are looking at the printout of an actual program, in thiscase c:nKWREnexamplesnEX1_muth2nsetpath.m. This is a signal that wewill use throughout this manual, so that you will be able to go the examplessubdirectory and �nd the program, modifying it if you like for your ownpurposes.

In the discussion below, we indicate �les that are from the standardKWRE code with upper case letters and highlight that they are programs byusing the typewriter font. We indicate �les that are user generated or usermodi�ed by the bold bold typewriter font. These identi�cation rules werejust followed with the programs that control the path. It is assumed that thereader is su¢ ciently familiar with MATLAB to follow the discussion withoutcomments. The companion document xxxx.pdf provides an overview of keyMATLAB commands.

2.2.1 Step 1: Variable List Speci�cation

One starts by specifying a list of variables for the model, as in vlistmuth2.m.The variables p, q, and k can be added to the vector of names, ylist, asfollows. The elements that the user needs to supply are highlighted in bold.

% ********************************* %

% List of Names of Elements of Y(t) %

% ********************************* %

ylist=[�q �

�p �

�k �];

% ********************************* %

% List of Names of Elements of x(t) %

% ********************************* %

xlist=[�x �];

% ********************************* %

% Make ids for these variables

Page 16: Linear Rational Expectations Models: Construction, Solution

10 CHAPTER 2 A BASIC MUTHIAN MODEL

% ********************************* %

MAKEID(ylist,xlist,�imuth2�)

The last line calls the MAKEID utility to create IDs for the variablesand to store them in the �le imuth2.mat. The format of the IDs is simple:for example, since the variable name for the stock of goods is "k", the idname is "ik" and ik=3 since this is the third variable in the variable list.These are lines of code from the vlistmuth2.m program that sets of

the variable list. Using our earlier convention, the above is not an actualprogram listing, but instead just a sampling of code from a program that wehave copied in to this manual.

2.2.2 Step 2: Coe¢ cient Matrix Speci�cation

The equations for the singular system are266640 0 0

0 0 1

0 �� 1

37775| {z }

A

Et

26664qt+1

pt+1

kt+1

37775| {z }yt+1

=

266641 �� �1

1 � 0

0 �1 0

37775| {z }

B

26664qt

pt

kt

37775| {z }yt

+

266640

�1

0

37775| {z }

C

xt

The program sysmuth2.m creates the coe¢ cient matrices: a complete list-ing of this program is given later, but we begin by highlighting the user inputsthat are necessary.. The system �le sysmuth2.m also executes the creationof the variable lists in sysmuth2.m and loads the resulting imuth2.mat.

User Input 1: Specifying variable lists and ids

The user starts by specifying variable lists and ids. We just saw how to dothis, but we now show where the call to a list-creating program enters intothe larger "system �le" that we are constructing.

% **********************

% LISTS OF VARIABLES

Page 17: Linear Rational Expectations Models: Construction, Solution

2.2 NUMERICAL ANALYSIS 11

% AND ASSOCIATED INDICES

% **********************

vlstmuth2

load imuth2

User Input 2: Specifying lead length and predetermined variables

It is necessary to specify the number of leads of the exogenous variables (xt)and the location of the predetermined variables. Rather than specifying thelocation of the predetermined variables explicitly, we make use of the IDscreated by the MAKEID utility. To refer to capital (kt), the only predeter-mined variable in the system, we simply enter ik:

nlead=1;

lpd=[ik];

User Input 3: Specifying model parameters

Every model has parameters. The values of the various Muth model para-meters are speci�ed as:

% Model parameters

sigma=.1;

alpha=.2;

phi=4;

b=.99;

Note that we deviate from the notation of the model by renaming theparameter � as b in the text. We do this because "beta.m" is a built-inMATLAB function. Throughout our discussion, we identify such functionswithout capitals or bolding.

Page 18: Linear Rational Expectations Models: Construction, Solution

12 CHAPTER 2 A BASIC MUTHIAN MODEL

User Input 4: Specifying equations

System equations are speci�ed as follows. The �rst command for each equa-tion passes the existing equations list, the equation number, and a namefor the equation to be created to the ADDEQN utility; which returns thenew list of equation names (elist) and the updated equation number (eqn).2 The remaining code is straightforward. Note that equation IDs are usedagain in place of explicitly stating the location of a variable.

% EQN1[elist,eqn]=ADDEQN(�supply�,elist,eqn);B(eqn,iq)=-1;B(eqn,ip)=sigma;B(eqn,ik)=1;% EQN2[elist,eqn]=ADDEQN(�demand�,elist,eqn);B(eqn,iq)=1;B(eqn,ip)=alpha;A(eqn,ik)=1;CF0(eqn,ix)=-1;% EQN3[elist,eqn]=ADDEQN(�inventory�,elist,eqn);A(eqn,ik)=1;A(eqn,ip)=-b*theta;B(eqn,ip)=-theta;

2.2.3 Step 3: Driving Process Speci�cation

A driving process for the exogenous state variables must be speci�ed in thedriver �le drvmuth2.m. The driver �le simply contains the coe¢ cient matri-ces for the forcing process equations xt = Q�t and �t = ��t�1 +G"t:

% drvmuth2.m

rho=.9;

2The list is initialized as an empty text vector (elist=[]) and the equation number isinitialized to zero (eqn=0) inside the system program, as displayed later.

Page 19: Linear Rational Expectations Models: Construction, Solution

2.2 NUMERICAL ANALYSIS 13

nx=1;

ndelta=1;

nshock=1;

Q=1;

RHO=rho;

Gbar=1;

Note that these choices correspond to de�ning the forecasting process in(2,3) above.

2.2.4 Step 4: Start RESOLKW

The last step is to pull together the elements of the previous steps and topass them to the King and Watson code for a solution.3

To solve the system, deriving the coe¢ cient matrices for the state spacesolution, call RESOLKW.m:

[M,PI,G,ylist,xlist,lpd,elist]=

resolkw(�sysmuth2�,�drvmuth2�,track,comp,etype);

The last three input arguments �track,comp and etype�are optional.Track sets the desired level of command window output regarding solutionalgorithm progress:

track=0 no tracking

track=1 minimal tracking (includes reports on eigenvalues)

track=10 extensive tracking

3The beginning of the start or master �le mastermuth2.m it is one place to specify thepaths to thethe kwrenmain directory and the kwrenutilities directory.

Page 20: Linear Rational Expectations Models: Construction, Solution

14 CHAPTER 2 A BASIC MUTHIAN MODEL

Comp speci�es the speci�c solution algorithm to be used for solving twoaspects of the model. The �rst row speci�es how the nonsingular system(1.1) is solved:

comp(1,:)=[0 0] eigenvalue decomposition method

comp(1,:)=[0 1] non-balanced eigenvalue decomposition method

comp(1,:)=[1 0] Schur decomposition

The second row speci�es how the system is reduced

comp(2,:)=[1 0] QR factorization method

comp(2,:)=[2 0] singular value decomposition (SVD) method

Note that an earlier generation of programs (prior to 2008) had no secondoption, so that the researcher speci�ed only a vector. The current generationof programs is designed to be backward compatible, so that if only a vectoris speci�ed, then the SVD method is employed. The default option is QRfactorization for the reduction step and Schur decomposition for the solutionstep.The �nal option, etype, involves declaring that some of the equations of

the model are of a particular form so that the system can be more easilyreduced. This is valuable in very large models, as explained in the sectionon that topic below.If you wish to solve the system using the default level of tracking and

the default solution algorithm, call RESOLKW.m without the last two ar-guments:

[M,PI,G,ylist,xlist,lpd,elist]=

resolkw(�sysmuth2�,�drvmuth2�);

MATLAB will produce the coe¢ cient matrices for the correct state-spacesolution when the code is run. In our example, the output given for track=1is:

Page 21: Linear Rational Expectations Models: Construction, Solution

2.2 NUMERICAL ANALYSIS 15

Reduced dimension dynamic system analysis (DYNKW.m):

reduced system dimension = 2

Root counting using a critical value of bcrit =0.99999

unstable eigenvalues = 1

nonpredetermined variables = 1

Information on eigenvalues of reduced system

abs(mu) bcrit*abs(mu)

1.3215 1.3215

0.7644 0.7644

Notice that this information matches what we worked out by hand: thereis a two variable reduced dimension system, which contains two eigenvalues(one stable and one unstable, in terms of modulus). Note also that thestability de�nition adopted by the program treats a root as unstable only ifbcrit*(abs(�))>1, where bcrit has a default value of 0.99999. This defaultvalue can be changed by editing RESOLKW.m

The state space coe¢ cient matrices can be found in the workspace win-dow. These are

26666664qt

pt

kt

xt

37777775 =

26666664�qk �q&

�pk �p&

1 0

0 q

37777775| {z }

24kt& t

35| {z }St

24kt& t

35| {z }St

=

24mkk mk&

0 �

35| {z }

M

24kt�1& t�1

35| {z }St�1

+

240q

35|{z}G

"t

Note that the matrices listed below satsify several general restrictions sug-gested by the equations above

Page 22: Linear Rational Expectations Models: Construction, Solution

16 CHAPTER 2 A BASIC MUTHIAN MODEL

PI =[ 0.9215 0.2463-0.7855 2.46261.0000 0.00000.0000 1.0000]

M=[0.7644 -0.26120.0000 0.9000]

2.3 Listing of system �le

A complete listing of the system �le for the basic model (sysmuth2.m) isprovided next. Note that each of the "user inputs" discussed above is o¤setin the program list below. The remainder of the code is standard acrossvarious applications and program comments explain the general nature ofcomponent.

1 % sysmuth2.m2

3 % *******************************************************4 % This is an example of a system file which creates a5 % a dynamic model in6 %7 % A*y(t+1/t) = B*y(t) + C(F)*x(t/t),8 %9 % where C(F) = C0 + C1*F + C2*F^2 + ... + CN*F^N.10 % In this expression, F11 % the forward shift operator; i.e., F*x(k/t) = x(k+1/t).12 %13 % The program produces the matrics14 % A15 % B16 % C = [C0, C1,..., CN]17

18 % It also creates some key vectors19 % lpd = Array that contains locations of predetermined20 % variables in the y vector.21 %

Page 23: Linear Rational Expectations Models: Construction, Solution

2.3 LISTING OF SYSTEM FILE 17

22 % ylist = Array of names of the elements of y (strings)23 % xlist = Array of names of the elements of x (strings)24 % ny = number of y variables25 % nx = number of x variables26 % nlead: Number of leads of x(t+j/t) -- (i.e., n in the above

equation).27

28

29 % **********************30 % LISTS OF VARIABLES31 % AND ASSOCIATED INDICES32 % **********************33

34 % USER INPUT 1: Create lists and load ids35 vlstmuth236 load imuth237

38

39 % USER INPUT 2: Specufy Location of predetetermined variables40

41 lpd=[ik];42

43 % USER INPUT 3: Specify Length of leads in C matrices44

45 nlead = 0;46

47 % ****************48 % system dimension49 % ****************50

51 ny=ROWS(ylist);52 nx=ROWS(xlist);53

54

55 % ********************************* %56 % DEFINING THE MATRICES A, B AND C %57 % ********************************* %58 %

Page 24: Linear Rational Expectations Models: Construction, Solution

18 CHAPTER 2 A BASIC MUTHIAN MODEL

59

60 % Initialize Matrices:61

62 A=zeros(ny,ny);63 B=zeros(ny,ny);64

65 for i=0:nlead;66 eval([�CF� num2str(i) �=zeros(ny,nx);�]);67 end68

69 % initialize equation list and equation number70 elist=[];71 eqn=0;72

73 % USER INPUT 4: Specify model parameters74

75 sigma=.1;76 alpha=.2;77 phi=4;78 b=.99;79

80 % USER INPUT 5: specify model equations81

82 % EQN183

84 [elist,eqn]=ADDEQN(�supply�,elist,eqn);85

86 B(eqn,iq)=-1;87 B(eqn,ip)=sigma;88 B(eqn,ik)=1;89

90 % EQN291

92 [elist,eqn]=ADDEQN(�demand�,elist,eqn);93

94 B(eqn,iq)=1;95 B(eqn,ip)=alpha;96 A(eqn,ik)=1;

Page 25: Linear Rational Expectations Models: Construction, Solution

2.3 LISTING OF SYSTEM FILE 19

97 CF0(eqn,ix)=-1;98

99 % EQN3100

101 [elist,eqn]=ADDEQN(�inventory�,elist,eqn);102

103 A(eqn,ik)=1;104

105 A(eqn,ip)=-b*phi;106 B(eqn,ip)=-phi;107

108

109 % **********************110 % COMBINE Ci matrcies111 % **********************112

113 CF=[];114 for i=0:nlead;115 loc=eval([�CF� num2str(i)]);116 CF=[CF loc];117 end

Page 26: Linear Rational Expectations Models: Construction, Solution

Chapter 3

First-order form

Solving models using the methods described here requires that the model becast in the standard �rst-order form (1). There exist many models which arenot naturally in �rst-order form but which may be placed in �rst-order formwith a few tricks.

3.1 Another Muth Example

Muth [1961] begins his study of rational expectations models with a simpleexample, which we now discuss. Production must be determined one periodin advance, which introduces expectations into the model equations.

Supply : qt = �Et�1pt

Demand : qt = ��pt + xt

After equating supply and demand so as to eliminate quantity (q) and reducethe system, we �nd a di¤erence equation very similar to the example thatBlanchard and Kahn [1980] refer to as being �zeroth-order.�

�pt = ��Et�1pt + �xt

21

Page 27: Linear Rational Expectations Models: Construction, Solution

22 CHAPTER 3 FIRST-ORDER FORM

This model possesses a natural solution for values of �+ � 6= 0:

�Et�1pt = ��Et�1pt + �Et�1xt

Et�1pt =�

�+ �Et�1xt

pt =1

�����+ �

Et�1xt + �xt

While this model is not immediately in �rst-order form, there exists aconvenient transformation which yields a singular linear rational expectationsmodel easily solvable by the methods discussed here. De�ne wt � Et�1pt andinclude this de�nition as an equation in a �rst-order di¤erence system

240 0

1 �1

35| {z }

A

Et

24wt+1pt+1

35| {z }yt+1

=

24� �

0 0

35| {z }

B

24wtpt

35| {z }yt

+

24�10

35| {z }

C

xt

in which the �rst equation is the original and uses date t variables and thesecond equation is the new variable de�nition and uses date t+ 1 variables.Naturally, both of the coe¢ cient matrices A and B are singular. Whilethe requirement for solvability that there must be a z s.t. jAz �Bj 6= 0 isnot always intuitive, it is in this case. There is a z such that jAz �Bj =�z (�+ �) is not equal to zero so long as �+� 6= 0, exactly the requirementimposed by the analytical solution. Note also that there is a zero root forthis speci�cation, so that there is an important sense in which it really is a"zero-th order" di¤erence equation.1

3.2 More tricks

We now discuss some additional tricks for placing models in �rst order form.

1Study problem: Follow the steps above to make this model operational, creatingyour own code or modifying the code in the "muth 2" directory. The answer to thisproblem is provided in the "muth 1" directory.

Page 28: Linear Rational Expectations Models: Construction, Solution

3.2 MORE TRICKS 23

3.2.1 Lagged expectations

The procedure discussed above can be directly extended to a vector system.Suppose that the model is

AEtyt+1 = Byt + �Et�1yt + Cxt

Then a system in standard form can be created as24 A 0

I �I

35Et24 yt+1

Etyt+1

35 =24 B �

0 0

3524 yt

Et�1yt

35+24 C0

35xtIt is not always necessary to add all of the lagged expecations variables

in a model. Suppose instead that the system is

AEtyt+1 = Byt + �Et�1zt + Cxt

zt = yt

where is a selection matrix for the subset of variables. Then, the �rst ordersystem would be24 A 0

�I

35Et24 yt+1

Etzt+1

35 =24 B �

0 0

3524 yt

Et�1zt

35+24 C0

35xtwhich could contain many fewer equations.

3.2.2 Longer lags

It is also easy to add lags of variables. Suppose, for example, that the originalmodel was written in the form

AEtyt+1 = Byt +Dyt�1 + Cxt

which is quite frequently encountered in the literature. Then, the �rst ordersystem takes the form24 A 0

0 I

35Et24 yt+1

yt

35 =24 B D

I 0

3524 yt

yt�1

35+24 C0

35xtand higher order lags can be handled similarly.

Page 29: Linear Rational Expectations Models: Construction, Solution

24 CHAPTER 3 FIRST-ORDER FORM

3.2.3 Longer leads

Suppose that we had an RE model of the form

A2Etyt+2 + A1Etyt+1 = B0yt +B1yt�1 +B2yt�2 + Cxt

Then we could write it as26666664I 0 0 0

0 I 0 0

0 0 I 0

0 0 A1 A2

37777775Et26666664yt�1

yt

yt+1

yt+2

37777775

=

266666640 I 0 0

0 0 I 0

0 0 0 I

B2 B2 B0 0

37777775

26666664yt�2

yt�1

yt

yt+1

37777775+266666640

0

0

C

37777775xt

which is the necessary �rst order form.

3.2.4 Recursive Equilibria

The "big trick" is simply to model in a recursive manner, which very naturallyleads to models in a �rst order form as we will see in the next section. In thesimpler context of the Muthian model just discussed, for example, supposethat there is a farmer who decides at t to plant a certain acerage, qt+1, thatwill yield output at date t+1. The date t farmer�s optimality condition mighttake the linear form

qt+1 = �Etpt+1

The price is determined at t by

qt = ��pt + xt

Page 30: Linear Rational Expectations Models: Construction, Solution

3.2 MORE TRICKS 25

Hence, this system would naturally be written as240 0

1 ��

35Et24qt+1pt+1

35 =241 �0 0

3524qtpt

35+24�10

35xtNotice that thinking directly about the economic variable that makes date tsupply depend on prior expectations means that it is not necessary to thinkabout carrying the expectation itself.

Page 31: Linear Rational Expectations Models: Construction, Solution

Chapter 4

DSGE modeling

The previous chapters considered models which are already linear and do notrequire steady-state calculation. Modern dynamic stochastic general equilib-rium (DSGE) models are typically nonlinear, but are linearized about thecertainty stationary point. We now consider a basic RBC model with en-dogenous labor supply as an example of DSGE modeling. Code for thisexample can be found in the nkwrenexamplesnEX3_rbc directory.

4.1 Developing model equations

Dynamic programming and recursive equilibrium analysis provide convenientmeans of producing a set of model equations which take the general form

EtF (yt+1; yt; xt+1; xt) = 0

which, upon linearization, produce a system of the form (1) for a large classof Markovian driving processes. That is, as dynamic programming "looksahead" one period, it leads naturally to systems of �rst-order form.For the basic RBC model studied in this chapter, the Bellman equation

is:

v (kt; & t) = max fu (ct; lt) + �Etv (kt+1; & t+1) j (kt; & t)gwhere the functional forms are

u (ct; lt) = ln ct ��

1 + �(1� lt)

1+�

atf (kt; nt) = atk1��t n�t

27

Page 32: Linear Rational Expectations Models: Construction, Solution

28 CHAPTER 4 DSGE MODELING

The maximization involves the selection of [ct; nt; lt; it; kt+1] and the restric-tions are

1 = nt + lt

ct + it + gt = af (kt; nt)

kt+1 = (1� �) kt + it

In dynamic programming, we are interested in �nding optimal policieswhich maximize the objective subject to the constraints, which are givenabove. If we attach a multiplier to each constraint, then we can form theLagrangian,

L(kt; & t; ct; lt; nt; kt+1; �t; !t)

= u (ct; lt) + �Ev (kt+1; & t+1) j (kt; & t)+pt [atf (kt; nt)� ct � it � gt]

+�t[(1� �) kt + it � kt+1]

+!t [1� nt � lt]

We minimize the Lagrangian with respect to the multipliers (�t; !t) andmaximize with respect to the choices (ct; lt; it; nt; kt+1).

4.1.1 First order conditions

For all functions f , de�ne fx � @f�x: In this notation, implied �rst order

conditions include:

ct : 0 = uc (ct; lt)� pt

lt : 0 = ul (ct; lt)� !t

it : 0 = �pt + �t

nt : 0 = �tatfn (kt; nt)� !t

kt+1 : 0 = ��t + �Evk (kt+1; & t+1) j (kt; & t)pt : 0 = atf (kt; nt)� ct � it � gt

�t : 0 = (1� �) kt + it � kt+1

!t : 0 = 1� nt � lt

ET : 0 = �vk (kt; & t) + ptatfk (kt; nt) + �t (1� �)

Page 33: Linear Rational Expectations Models: Construction, Solution

4.2 LINEAR APPROXIMATION (ANALYTICAL) 29

4.1.2 Driving process

Notice that we have been able to pose the dynamic programming problemand to state the FOCS without making any assumptions about the drivingprocess, other than that productivity and government purchases are functionsof a Markov process (& t):

In our example, we assume that the exogenous variables are governed bya simple loglinear speci�cation,

24ln atln gt

35| {z }

xt

=

241 00 1

35| {z }

Q

24ln atln gt

35| {z }

&t24ln atln gt

35| {z }

&t

=

24�a 0

0 �g

35| {z }

24ln at�1ln gt�1

35| {z }

&t�1

+

241 00 1

35| {z }

"t

G

which is of the general form (2,3) and also is Markovian.

4.2 Linear Approximation (Analytical)

De�ne the value of a marginal unit of capital as m(kt; & t) = vk (kt; & t) forconvenience. Total di¤erentiation provides the appropriate linearly approxi-

Page 34: Linear Rational Expectations Models: Construction, Solution

30 CHAPTER 4 DSGE MODELING

mated equations:

ct : 0 = ucc (c; l) dct + ucl (c; l) dlt � dpt

lt : 0 = ull (c; l) dlt + ulc (c; l) dct � d!t

it : 0 = �dpt + d�t

nt : 0 = �d!t + pa [fnn (k; n) dnt + fnk (k; n) dkt]

+afn (k; n) dpt + pfn (k; n) dat

kt+1 : 0 = �d�t + �Et [dmt+1]

pt : 0 = a [fk (k; n) dkt + fn (k; n) dnt] + f (k; n) dat

�dct � dit � dgt

�t : 0 = (1� �) dkt + dit � dkt+1

!t : 0 = �dnt � dlt

ET : 0 = �dmt + pa [fkk (k; n) dkt + fkn (k; n) dnt]

+afk(k; n)dpt + pfk (k; n) dat

+(1� �)d�t

We can write these equations in matrix form as (note that dlt = �dntand for simplicity write fx (�) = fx). Note that these equations are written inan unusual manner, with an additional material to help keep track of whichequation we are looking at and which variable we are looking at. For example,the �rst order condition for labor is the row in the "B" matrix that beginswith n; the e¤ect of higher capital on the marginal product of labor (afkn)occurs at the intersection of the n row and the k column. This notation isnot used in coding, but just in presentation.

Page 35: Linear Rational Expectations Models: Construction, Solution

4.2 LINEAR APPROXIMATION (ANALYTICAL) 3126666666666666666666666664

c l i n p � ! k m

c 0 0 0 0 0 0 0 0 0

l 0 0 0 0 0 0 0 0 0

i 0 0 0 0 0 0 0 0 0

n 0 0 0 0 0 0 0 0 0

k0 0 0 0 0 0 0 0 0 �

p 0 0 0 0 0 0 0 0 0

� 0 0 0 0 0 0 0 1 0

! 0 0 0 0 0 0 0 0 0

ET 0 0 0 0 0 0 0 0 0

37777777777777777777777775

Et

26666666666666666666664

dct+1

dlt+1

dit+1

dnt+1

dpt+1

d�t+1

d!t+1

dkt+1

dmt+1

3777777777777777777777526666666666666666666666664

::: c l i n p � ! k m

c ucc ucl 0 0 �1 0 0 0 0

l ulc ull 0 0 0 0 �1 0 0

i 0 0 0 0 �1 1 0 0 0

n 0 0 0 afnn 0 0 �1 afkn 0

k0 0 0 0 0 0 1 0 0 0

p �1 0 �1 afn 0 0 0 afk 0

� 0 0 1 0 0 0 0 (1� �) 0

! 0 1 0 1 0 0 0 0 0

ET 0 0 0 pafkn afk(k; n) 1� � 0 pafkk �1

37777777777777777777777775

26666666666666666666664

dct

dlt

dit

dnt

dpt

d�t

d!t

dkt

dmt

37777777777777777777775

+

26666666666666666666666664

::: a g

c 0 0

l 0 0

i 0 0

n fn 0

k0 0 0

p f �1

� 0 0

! 0 0

ET pfk (k; n) 0

37777777777777777777777775

24datdgt

35

Page 36: Linear Rational Expectations Models: Construction, Solution

32 CHAPTER 4 DSGE MODELING

Note that these equations suggest that there is a reduced dimension dynamicsystem of no more than two variables, since all other rows of A are zero.

4.3 Steps in specifying the model

We parallel the steps in model speci�cation of the introductory Muth modelof chapter 1, highlighting the new elements implied by the RBC model.In broad form, the RBC model is a system of possibly equations,

EtF (yt+1; yt; xt+1; xt; �) = 0

where the variables are de�ned as in (1) and � is a vector of parameters.A stationary point of this model is a (y, x, and �) such that

F (y; y; x; x; �) = 0

Suppose that there are n equations in this setting. Then, we can choose tosatisfy these equations by various choices of endogenous variables y, exoge-nous variables x, and parameters �.

4.3.1 Step 1: Variable List Speci�cation

We begin by specifying the list of variables in vlstrbc.m.. The variable listmatches the vector of endogenous variables derived in the previous section(aside from a few notational changes for coding purposes). We code thevariable list making use of the ADDVAR utility, introduced above. Sincethe reader is familiar with the process from above, we simply provide a listingfor the program vlstrbc.m

1 % vlstrbc.m2

3 % ********************************* %4 % List of Names of Elements of Y(t) %5 % ********************************* %6

7 ylist=[];

Page 37: Linear Rational Expectations Models: Construction, Solution

4.3 STEPS IN SPECIFYING THE MODEL 33

8 count=0;9 [ylist,count]=ADDVAR(�c�,ylist,count);10 [ylist,count]=ADDVAR(�l�,ylist,count);11 [ylist,count]=ADDVAR(�i�,ylist,count);12 [ylist,count]=ADDVAR(�n�,ylist,count);13 [ylist,count]=ADDVAR(�p�,ylist,count);14 [ylist,count]=ADDVAR(�lam�,ylist,count);15 [ylist,count]=ADDVAR(�om�,ylist,count);16 [ylist,count]=ADDVAR(�k�,ylist,count);17 [ylist,count]=ADDVAR(�m�,ylist,count);18

19 % ********************************* %20 % List of Names of Elements of x(t) %21 % ********************************* %22

23 xlist=[];24 count=0;25 [xlist,count]=ADDVAR(�a�,xlist,count);26 [xlist,count]=ADDVAR(�g�,xlist,count);27

28 [ylist,xlist]=MAKEID(ylist,xlist,�idrbc�);

Note that the last line again calls the MAKEID utility to create IDs forthe variables and to store them in idrbc.mat.

4.3.2 Step 2A: Steady State Calculation

In the RBC model, the speci�cation of the linear system cannot be un-dertaken until the steady-state of the model is �rst solved. For this steadystate, there are typically certain features of the data which we wish to match.Given these values, we can analytically calculate the steady state values forthe remaining parameters. One program to perform such steady-state com-putations is ssrbc.m.

1 %ssrbc.m2

3

Page 38: Linear Rational Expectations Models: Construction, Solution

34 CHAPTER 4 DSGE MODELING

4 % Calculate steady state of model5

6 % Features of data to match7

8 sg=.2; % g/y9 sn=.67; % wn/y10 sk=1-sn; % qk/y = 1 - wn/y11 r=.01; % four percent real rate per year (1% per quarter)12 delta=.025; % 10 percent depreciation rate per year (2.5% per

quarter)13 gamma=.5; % inverse of labor supply elasticity14 sigma=1; % intertemporal15 bstar=1/(1+r);16

17 % choose whether to calibrate utility parameter chi18 % to hit specific labor value or whether to fix utility19 % parameter and determine particular labor value.20

21 cal=1;22

23 if cal==124 nbar=.2;25 else26 chi=5;27 end28

29 % Normalization30

31 a=1;32

33 % Determine other elements of steady-state from34 % Calculate capital-labor ratio35 % from MPK=r+delta36

37 knratio=((a*sk)/(r+delta))^(1/(1-sk));38

39 % Calculate the real wage rate40

Page 39: Linear Rational Expectations Models: Construction, Solution

4.3 STEPS IN SPECIFYING THE MODEL 35

41 wss=a*sn*(knratio^sk);42

43 % Calculate the ratio of output to labor input44

45 ynratio=a*(knratio^sk);46

47 % Calculate the ratio of consumption to labor input48

49 cnratio=(1-sg)*ynratio-delta*knratio;50

51 % The requirement that52 % w-(mun)/muc=chi*(n^gamma)*(c^sigma)53 % now is "one equation in one unknown" given the54 % information above since the rhs is55 % chi*(n^(gamma+sigma))*(cnratio^sigma)56 % We can use it to "calibrate" the labor preference57 % parameter chi given a specified value of nbar or58 % to "calculate" the ss level of labor given59 % a particular chi value.60

61 if (cal==1)62 denom=(nbar^(gamma+sigma))*(cnratio^sigma);63 chi=(wss/denom);64 nss=nbar;65 else66 nss=(wss/(chi*(cnratio^sigma)));67 ns=ns^(1/(gamma+sigma));68 end69

70 css=cnratio*nss;71 yss=a*(knratio^sk)*nss;72 kss=knratio*nss;73 lamss=css^(-sigma);74 pss=lamss;75 lss=1-nss;76 omss=wss*pss;77

78 % Checking 4 nonlinear equations at these parameter values

Page 40: Linear Rational Expectations Models: Construction, Solution

36 CHAPTER 4 DSGE MODELING

79

80 gap=zeros(4,1);81

82 gap(1)=(css^(-sigma))-lamss;83 gap(2)=chi*nss^gamma-lamss*wss;84 gap(3)=bstar*lamss*(a*sk*((nss/kss)^sn)+(1-delta)) - lamss;85 yss2=a*(kss^sk)*(nss^sn);86 gap(4)=(1-sg)*yss2+(1-delta)*kss-kss-css;87

88 disp(�Equation gaps for calibrated model�)89 disp(gap�)90

91 x=[lamss kss css chi];92

93 disp(�solutions for [lamss kss css chi]�);94 disp(x)95

96

97 % Calculate derivative information98 derivinfo99

100 % Save ss values101

102 save ssrbc.mat css nss lss yss kss pss lamss omss

4.3.3 Step 2B: Implications for model coe¢ cients

Many of the model coe¢ cients involve derivatives evalued at the steady state.Given the steady state parameters above, these derivative information iscomputed in derivinfo.m, which is called by ssrbc.m.

1 % derivinfo.m2

3 % Compute some derivative information that will be used inlinear system

4

Page 41: Linear Rational Expectations Models: Construction, Solution

4.3 STEPS IN SPECIFYING THE MODEL 37

5 Mss=1/bstar;6

7 DccU=-sigma*css^(-sigma-1);8 DclU=0;9 DncU=0;10 DllU=-chi*gamma*(nss^(gamma-1));11

12 F=(nss^sn)*(kss^sk);13 DnF=sn*(nss^(sn-1))*(kss^sk);14 DkF=sk*(nss^sn)*(kss^(sk-1));15 DnnF=sn*(sn-1)*(nss^(sn-2))*(kss^sk);16 DnkF=sn*sk*(nss^(sn-1))*(kss^(sk-1));17 DknF=DnkF;18 DkkF=sk*(sk-1)*(nss^sn)*(kss^(sk-2));

4.3.4 Step 2C: Coe¢ cient matrix speci�cation

The coe¢ cient matrices are speci�ed by linrbc.m, but for clarity of presen-tation this is accomplished in another program eqnsrbc.m, which is calledby linrbc.m

1 % eqnsrbc.m2

3 % EQN4

5 [elist,eqn]=ADDEQN(�FOC:c�,elist,eqn);6

7 B(eqn,ic)=DccU;8 B(eqn,il)=DclU;9 B(eqn,ip)=-1;10

11 % EQN12

13 [elist,eqn]=ADDEQN(�FOC:l�,elist,eqn);14

15 B(eqn,ic)=DclU;

Page 42: Linear Rational Expectations Models: Construction, Solution

38 CHAPTER 4 DSGE MODELING

16 B(eqn,il)=DllU;17 B(eqn,iom)=-1;18

19 % EQN20

21 [elist,eqn]=ADDEQN(�FOC:i�,elist,eqn);22 B(eqn,ip)=-1;23 B(eqn,ilam)=1;24

25 % EQN26

27 [elist,eqn]=ADDEQN(�FOC:n�,elist,eqn);28

29 B(eqn,in)=pss*a*DnnF;30 B(eqn,ik)=pss*a*DnkF;31 B(eqn,iom)=-1;32 B(eqn,ip)=a*DnF;33

34 CF0(eqn,ia)=pss*DnF;35

36 % EQN37

38 [elist,eqn]=ADDEQN(�FOC:kprime�,elist,eqn);39

40 B(eqn,ilam)=1;41 A(eqn,im)=bstar;42

43 % EQN44

45 [elist,eqn]=ADDEQN(�FOC: p (commodity resource)�,elist,eqn);

46

47 B(eqn,ik)=a*DkF;48 B(eqn,in)=a*DnF;49 B(eqn,ic)=-1;50 B(eqn,ii)=-1;51 CF0(eqn,ia)=F;52 CF0(eqn,ig)=-1;

Page 43: Linear Rational Expectations Models: Construction, Solution

4.3 STEPS IN SPECIFYING THE MODEL 39

53

54 % EQN55

56 [elist,eqn]=ADDEQN(�FOC:lam (k accumulation)�,elist,eqn);

57

58 A(eqn,ik)=1;59 B(eqn,ik)=1-delta;60 B(eqn,ii)=1;61

62 % EQN63

64 [elist,eqn]=ADDEQN(�FOC: om (time constraint)�,elist,eqn);

65 B(eqn,il)=1;66 B(eqn,in)=1;67

68 %EQN69

70 [elist,eqn]=ADDEQN(�Envelope theorem�,elist,eqn);71

72 B(eqn,im)=-1;73 B(eqn,ik)=pss*a*DkkF;74 B(eqn,in)=pss*a*DknF;75 B(eqn,ip)=a*DkF;76 B(eqn,ilam)=(1-delta);77

78 CF0(eqn,ia)=pss*DkF;

The abbreviations used should be clear. For example, DccU is used in thecode above to represent ucc (c; l).

4.3.5 Listing of system program (linrbc.m)

The linrbc.m program is a linear system program (similar to sysmuth2.m).As with that program, we highlight the user-speci�ed elements by indentingthese.

Page 44: Linear Rational Expectations Models: Construction, Solution

40 CHAPTER 4 DSGE MODELING

1 % linrbc.m2

3 % **********************4 % LISTS OF VARIABLES5 % AND ASSOCIATED INDICES6 % **********************7

8 % USER INPUT 1: Create lists and load ids9 vlstrbc10 load idrbc11

12

13 % USER INPUT 2: Specufy Location of predetetermined variables14

15 lpd=[ik];16

17 % USER INPUT 3: Specify Length of leads in C matrices18

19 nlead = 0;20

21 % ****************22 % system dimension23 % ****************24

25 ny=ROWS(ylist);26 nx=ROWS(xlist);27

28

29 % ********************************* %30 % DEFINING THE MATRICES A, B AND C %31 % ********************************* %32 %33

34 % Initialize Matrices:35

36 A=zeros(ny,ny);37 B=zeros(ny,ny);38

Page 45: Linear Rational Expectations Models: Construction, Solution

4.3 STEPS IN SPECIFYING THE MODEL 41

39 for i=0:nlead;40 eval([�CF� num2str(i) �=zeros(ny,nx);�]);41 end42

43 CF=zeros(ny,nx);44

45 % initialize equation list and equation number46 elist=[];47 eqn=0;48

49

50 % USER INPUT 4A: Solve steady state and specify modelparameters

51

52 ssrbc53

54 % USER INPUT 4B: Specify Equations55

56 eqnsrbc57

58 % **********************59 % COMBINE Ci matrcies60 % **********************61

62 CF=[];63 for i=0:nlead;64 loc=eval([�CF� num2str(i)]);65 CF=[CF loc];66 end

4.3.6 Step 3: Driving Process Speci�cation

The driving process is speci�ed in drvrbc.m and contains the coe¢ cientmatrices for the forcing process equations xt = Q& t and & t = �& t�1 +G"t:

1 % drvrbc.m2

3 rhoa=.9;

Page 46: Linear Rational Expectations Models: Construction, Solution

42 CHAPTER 4 DSGE MODELING

4 rhog=.75;5

6 nx=2;7 ndelta=2;8 nshock=2;9

10 Q=eye(2);11 RHO=eye(2);12 Gbar=eye(2);13

14 RHO(1,1)=rhoa;15 RHO(2,2)=rhog;

4.3.7 Step 4: Compute solution using RESOLKW

The program masterrbc.m sets the MATLAB path; uses RESOLKW tocompute a solution; produces an impulse response; and plots the results.

1 % master.m2

3 % Set path for KWRE package4 setpath5

6 vlstrbc7

8 % calculate RE solution9

10 [M,PI,G,ylist,xlist,lpd,elist]=RESOLKW(�linrbc�,�drvrbc�);11

12

13

14 ir=1;15

16 if (ir==1)17

18 % Set shock vector19

Page 47: Linear Rational Expectations Models: Construction, Solution

4.3 STEPS IN SPECIFYING THE MODEL 43

20 mm=ROWS(M);21 shock=zeros(1,mm);22

23 sc=input(�Choose 1 for A shock and 2 for G shock�)24

25 if (sc==1)26 % A shock27 shock(2)=1;28 else29 % Gshock30 shock(3)=1;31 end32

33 % Compute impulse response34

35 nir=20;36

37 IR=IMPKW(M,PI,G,ylist,xlist,lpd,shock,nir);38

39 % plot impulse responses;40 plotrbc41

42 end

One can see the solution matrices M;PI;G in the MATLAB workspaceby typing their names at the prompt. For example, the M matrix is

M =0.9512 0.0163 0.00860 0.9000 00 0 0.7500

Note that this matrix indicates that the driving process for the two shocks,a and g, is a pair of �rst order autoregressions with coe¢ cients �a = :9 and�g = :75:

Page 48: Linear Rational Expectations Models: Construction, Solution

Chapter 5

Using the RE Solution

We now turn to a variety of applications of the RE solution, using the RBCcase as an example.

5.1 Impulse Responses

The state space model (4,5) makes it easy to compute an impulse responseto a shock vector et. This takes the form of

EtZt+j � Et�1Zt+j = �MjGet

where Z =

24 yx

35.The program IMPKW.m included in the c:nKWREnoutputs folder is an

example of a function �le used to produce outputs from a set of RE models.It computes the impulse responses recursively

Etst � Et�1st = Get

Etst+j � Et�1st+j = M(Etst+j�1 � Et�1st+j�1)

EtZt+j � Et�1Zt+j = �(Etst+j � Et�1st+j)

In masterrbc.m, the impulse responses are calculated. The call to theIMPKW.m program is

IR=IMPKW(M,PI,G,ylist,xlist,lpd,shock,nir);

45

Page 49: Linear Rational Expectations Models: Construction, Solution

46 CHAPTER 5 USING THE RE SOLUTION

That is, the impulse responses for the model described by matricesM;PI;Gand variable lists ylist and xlist are calculated for a shock vector (e inthe above). These are calculated for nir periods. When by plotrbc.m, theseimpulse responses are selected by their ID and the variable names are usedas labels in the plots.

1 % plotrbc.m2

3 vlstrbc4 load idrbc5 load ssrbc6

7 ny=ROWS(ylist);8

9 % Plot selected variables10

11 date=IR(:,1);12 if (sc==1)13 subplot(221),plot(date,IR(:,1+ia+ny),�k-�),14 title(�Productivity�)15 else16 subplot(221),plot(date,IR(:,1+ig+ny)/yss,�k-�),17 title(�Government purchases�)18 end19 subplot(222),plot(date,IR(:,1+ic)/css,�k-�),...20 title(�Consumption response�)21 subplot(223),plot(date,IR(:,1+in)/nss,�k-�),...22 title(�Labor response�)23 subplot(224),plot(date,IR(:,1+ik)/kss,�k-�),...24 title(�Capital�)

The following impulse response �gure is produced by this program.

Page 50: Linear Rational Expectations Models: Construction, Solution

5.2 FREQUENCY DOMAIN IMPLICATIONS 47

5.2 Frequency domain implications

Since the solution to the model obtains in state space form,

Yt � Y = �(St � S)

St � S = M(St�1 � S) +Get

it is easy to determine that the matrix power spectrum takes the form

FY (!) = �FS(!)�0

FS(!) = [I �Me�i!]�1GFeG0[I �M 0ei!]�1

where Fe = 12�Vee is the matrix power spectrum of the vector white noise

input. In this expression, as in MATLAB, M 0 denotes both conjugation ofthe elements of the matrix M and the transposition of the resulting matrix.The program SPECKW.m included in the nKWREnoutputs folder is a

function �le which allows for the calculation of spectra. It takes as inputsthe solution matrices �;M;G and an assumed innovation matrix Vee and itproduces the diagonals of matrix power spectrum FY (!) at each of a rangeof values of !: these are the spectra of the Y series.The program rbcspec.m calculates these spectra, using SPECKW, for

a pure technology shock model and plots the results, as shown below.

Page 51: Linear Rational Expectations Models: Construction, Solution

48 CHAPTER 5 USING THE RE SOLUTION

5.3 Spectra of �ltered series

If the states are stationary, the spectrum of a �ltered time series

Zt =1Xj=1

hjYt�j

with hj being a scalar and with1Xj=0

h2j <1 is determined as follows. First,

we compute the frequency response function of the linear �lter as

eh(!) = 1Xj=1

hje�i!j

and the associated transfer function as jeh(!)j2. Then, it follows that thematrix power spectrum of the �ltered series is

FZ(!) = jeh(!)j2FY (!)The program FILTTF.m, included in nKWREnoutputs, calculates the trans-fer function, jeh(!)j2, for a variety of �lters that have been studied in macro-economic research. One can calculate the spectra of �ltered series using

Page 52: Linear Rational Expectations Models: Construction, Solution

5.4 POPULATION SECOND MOMENTS 49

SPECKW.m as well: it optionally calls FILTTF.m to construct the appropriate�lter.

5.4 Population Second Moments

The KWRE approach is to undertake a frequency domain approach to thecomputation of second moments for �ltered series, which requires some ex-planation.

5.4.1 Frequency domain computation of moments

De�ne �x(�) to be the �th order autocovariance matrix of the vector timeseries xt, i.e.,

Extx0t��

if there is a zero mean. In computing the moments of a �ltered model, weare interested in the autocovariances of

Zt =1Xj=1

hjYt�j

but, evidently, this is a complicated object involving a double sum of theautocovariances of Y . That is,

E(ZtZ0t�� ) = E([

1Xj=1

hjYt�j][1Xl=1

hlY0

t�l�� ])

=1Xj=1

hj

1Xl=1

hlE(Yt�jY0

t�l�� )

Technically, the computation of the autocovariances of �ltered series involvesthe convolution of the �lter weight series.However, the Fourier integral provides the basis for a method of readily

calculating population moments of �ltered series.

�Z(�) =

�Z��

FZ(!)ei�!d! =

�Z��

jeh(!)j2FY (!)ei�!d!The desirability of this approach is sometimes summarized in the two phrases:"convolution in the time domain is multiplication in the frequency domain"and "multiplication is a lot easier than convolution."

Page 53: Linear Rational Expectations Models: Construction, Solution

50 CHAPTER 5 USING THE RE SOLUTION

Computation of population autocovariances

The integral must be approximated and a simple method of doing so is usedin the basic moment computation program, FDFKW.m, which is contained inthe c:nKWREnoutputs directory. Essentially, the since it is easy to calculatejeh(!)j2 and FY (!) at any point, the interval �� to � is discretized into aneven number (n) of subintervals of equal length �. Then, jeh(!)j2FY (!) isevaluated at the midpoint of each interval (!j for j = 1; 2; :::n). Then, theapproximate autocovariance is given by

�Z(�) =

�Z��

[jeh(!)j2FY (!)ei�!]d!'

nXj=d

[jeh(!d)j2FY (!d)ei�!d ]�One speci�c feature of this procedure is that the evaluation points do notinclude ! = 0, so as to allow situations in which Y is nonstationary but Z isstationary. As a basic example, suppose that

Yt � Yt�1 = �[Yt�1 � Yt�2] + et

and the �lter ish(L) = (1� L)

We would like the moments of Zt to be those of the �rst order autoregression,

Zt = �Zt�1 + et

but there is the di¢ culty that the "generalized spectrum" of Y is in�nite atzero, while the transfer function of h is zero at zero. By ignoring ! = 0 inour approximation to the Fourier integral, we get the desired answer.The program FDFKW takes a state space system and speci�ed lags [� 1

... � p] as input, producing the matrices

[�Z(0) �Z(� 1) ::: �Z(� p)]

as outputs. Since EZtZt�p = (EZtZt+p)0, it follows that this output allowsus to determine autocovariances at both lags and leads.

Page 54: Linear Rational Expectations Models: Construction, Solution

5.4 POPULATION SECOND MOMENTS 51

Using the information on population autocovariances

The program FACVSKW.m illustrates how one can use the information onautocovariances generated by by FDFKW.m. There are three types of output.

Tabular information The program produces some standard business cy-cle information, allowing the user to select a reference variable (which couldbe output, employment, etc.)(a) standard deviation of each variable(b) standard deviation as a ratio to the standard deviation of the

reference variable;(c) autocorrelation of each variable at speci�ed lags;(d) cross-correlation with the reference variable at the same leads and

lags.

The user can select a subset of variables to be included in the tables,using the variable list. A sample listing, for the RBC model and focusing on[n; c; i; a] is as follows.

1 Standard deviations and relative standard deviations2 n 0.17056 13 c 0.18582 1.08954 i 0.87668 5.14025

6

7 Autocorrelations8 1 2 49 n 0.88962 0.60631 -0.02194910 c 0.92386 0.72374 0.2281611 i 0.89003 0.60772 -0.01895612

13

14 Crosscorrelations with n15 -4 -2 -1 0 1 2 416 n -0.021949 0.60631 0.88962 1 0.88962 0.60631 -0.02194917 c 0.46111 0.77562 0.81051 0.6821 0.39958 0.039446 -0.5167418 i 0.056123 0.66121 0.91656 0.99281 0.84931 0.54073 -0.10391

Page 55: Linear Rational Expectations Models: Construction, Solution

52 CHAPTER 5 USING THE RE SOLUTION

Tabular information to text �le The programTABPRINT.m producesthe same information in an ascii table; tabprint.m also serves as an exampleof output formatting in MATLAB. The output from this program for theRBC model is in c:nkwrenexamplesnEX3_rbcnacvstab.out

Selected moments One can also select a subset of the moments to exam-ine using the second option in facvskw.m.

5.5 Simulations

5.5.1 Arti�cial shock inputs

5.5.2 VAR shock inputs

5.5.3 Filtering simuluation results

Page 56: Linear Rational Expectations Models: Construction, Solution

Chapter 6

Timing Models

53

Page 57: Linear Rational Expectations Models: Construction, Solution

Chapter 7

Strategies for Larger Models

7.1 Pre-Reduction

Suppose that the dynamic system can be written in the following form

24 0 0

A11 A22

3524 ft+1dt+1

35 =24 B11 B12B21 B22

3524 ftdt

35+24 C1(F)C2(F)

35xt (7.1)

with B11 being invertible because its structure is known by the researcher.We can then write undertake a conventional system reduction, which wewrite in two steps. First, we solve the �rst block of equations as

h0 0

i24 ft+1dt+1

35 = h I Ki24 ft

dt

35+ [J(F)]xt (7.2)

with K = B�111 B22 and J(F) = B�1

11 C(F). We save the system ordering atthis stage and the matrices K and J(F).We calculate that there is a reduced system of the form

[A22 � A21K] � [dt+1] = [B22 �B21K] � [dt] + [C2(F)�B21J(F) + A21FJ(F)] � xt(7.3)

a � [dt+1] = b � [dt] + [c(F)] � xt (7.4)

This system may require further reduction, but it is typically much smallerthan the other system.

55

Page 58: Linear Rational Expectations Models: Construction, Solution

56 CHAPTER 7 STRATEGIES FOR LARGER MODELS

After the smaller system is solved, one can then solve for ft. RESOLKW.mcontains a solution option along these lines. The researcher is required toorder the ft �rst and to specify whether each model equation belongs to the�rst block: for the jth equation the researcher speci�es etype(j,:)=1 if theequation belongs to the �rst block or not (etype(j,:)=2).