Occasional Staff StudiesThe Anderson-Moore Algorithm (AMA)

gensysToAMA:

Users of the SCFs are strongly encouraged to examine the information provided in the technical codebooks and summary articles. These documents contain essential information about the surveys and have the answers to many of the most commonly asked questions about the SCFs.

A Matlab Implementation of the Anderson-Moore Algorithm
Using gensys Input and Output Matrices
Gary S. Anderson
April 24, 2007

Abstract

This note describes a Matlab program for solving linear rational expectation problems. The gensysToAMA program provides a version of the Anderson-Moore algorithm (AMA) that has a matrix interface exactly the same as the gensys program. The code allows the user to invoke the AMA solution code, a copy of their own version of gensys, or a copy of gensys that was available in early 2007. The code can also verify that the solutions obtained using gensys and AMA are equivalent. Timing tests reveal that, except for problems of small dimension, gensysToAMA computes solutions much more quickly than gensys.

1 Introduction and Summary

This note describes a Matlab program for solving linear rational expectation problems. The gensysToAMA program provides a version of the Anderson-Moore algorithm (AMA) that has a matrix interface exactly the same as the gensys program. The code allows the user to invoke the AMA solution code, a copy of their own version of gensys, or a copy of gensys that was available in early 2007. The code can also verify that the solutions obtained using gensys and AMA are equivalent. Timing tests reveal that, except for problems of small dimension, gensysToAMA computes solutions much more quickly than gensys.

2 Usage

2.1 Installation

1. unzip the files into a directory (someDir) accessible by Matlab. This will create a directory, gen- sysToAMADist, containing the gensysToAMA programs and some example .mat input matrix files.

2. start matlab

3. place the gensysToAMA directory on the Matlab path using

addpath someDir/gensysToAMADist

4. during a matlab session, you can run a quick test of the installation:

type
>>isGensysToAMAOK
to verify the gensysToAMA program functions correctly. After a few seconds, you should get a
“SUCCESS” message.

2.2 Examples using gensysToAMA

The installation directory provides a number of “.mat” files that contain input matrices for the gensys (or gensysToAMA) program. These models vary in size and required computation time. For example, the two canada “.mat” files characterize the largest models and require the most computation time. Typing “help gensysToAMA provides information on the gensysToAMA inputs and outputs.

>> help gensysToAMA
function [G1,CC,impact,fmat,fwt,ywt,gev,eu]=gensysToAMA(g0,g1,cc,psi,pi,div,
optionalArg)
gensys interface to both gensys and the Anderson-Moore algorithm.
Just as with gensys, system given as
g0*y(t)=g1*y(t-1)+c+psi*z(t)+pi*eta(t),
with z an exogenous variable process and eta being endogenously determined
one-step-ahead expectational errors. Returned system is
y(t)=G1*y(t-1)+C+impact*z(t)+ywt*inv(I-fmat*inv(L))*fwt*z(t+1) .
If z(t) is i.i.d., the last term drops out.
If div is omitted from argument list, a div>1 is calculated.
eu(1)=1 for existence, eu(2)=1 for uniqueness. eu(1)=-1 for
existence only with not-s.c. z; eu=[-2,-2] for coincident zeros.
By Christopher A. Sims
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
when called with no optional args,
program first tries to find gensys on the matlab path
if that fails, the program runs gensys2007 in the gensysToAMA directory
an optional string argument may follow the original gensys arguments
’gensys’ run gensys
program first tries to find gensys on the matlab path
if that fails, the program runs gensys2007 in the gensysToAMA directory
’gensys2007’ run gensys
the program runs gensys2007 in the gensysToAMA directory
’ama’ run the anderson-moore algorithm with gensys inputs and outputs
’both’ run the anderson-moore algorithm and the gensys program
verify that solutions are equivalent print out execution times

3 Problem Statement and Notation

where both tau and theta are non-negative, and xt is an L dimensional vector of endogenous variables with

Formula 3:

and zt is a k dimensional vector of exogenous variables.

Solutions can be cast in the form

Formula 5:

Given any algorithm that computes the Bi, one can easily compute other quantities useful for character- izing the impact of exogenous variables. For models with tau = theta = 1 the formulae are especially simple. Let

Users can obtain code for the algorithm and the preprocessor from the author (at http://www.bog.frb.fed.us/pubs/oss/oss4/aimindex.html, July, 1999.)

4.2 Sims

Formula 21:

Model Variable

Description

Dimensions

y sub(t)

State Variables

L x 1

z sub(t)

Exogenous Variables

M sub(1) x 1

Eta sub(t)

Expectational Error

M sub(2) x 1

Gamma sub(0)

Structural Coefficients Matrix

L x L

Gamma sub(1)

Structural Coefficients Matrix

L x L

C

Constants

L x 1

Psi

Structural Exogenous Variables Coefficients Matrix

L x M sub(1)

Pi

Structural Exogenous Variables Coefficients Matrix

L x M sub(2)

Outputs

Formula 23:

Model Variable

Description

Dimensions

Theta sub(1)

L x L

Theta sub(c)

L x 1

Theta sub(0)

L x M sub(1)

Theta sub(y)

L x M sub(2)

Theta sub(f)

M sub(2) x M sub(2)

Theta sub(z)

M sub(2) x M sub(1)

Example Input/Output:

Sims input:

produces output:

5 Comparing Output and Computation Time

Anderson and Moore describe their algorithm in Anderson and Moore [1983]. Sims describes his algorithm in Sims [1996], Although they attack a the same class of problems their notation is different. Their computer codes reflect these notational differences. Section A.2 presents the code for converting gensys style input into the form expected by the Anderson-Moore algorithm. style input Section A.3 presents the code for converting Anderson-Moore style output into the form generated by the gensys program. When running the code using the 'both' option, the code computes the two-norm of the difference between the gensys style output of the two programs. (The code does not compare the outputs when the rational expectations model does not have a unique saddle point solution.) In particular, the code verifies that the following two-norms are smaller than 1E-8.

Comparing fmat, fwt, ywt must account for that fact that applying any similarity transformation to fmat and correspondingly adjusting ywt and fwt produces an equivalent solution. Consequently, the code verifies that

References

Gary Anderson. A reliable and computationally efficient algorithm for imposing the saddle point property in dynamic models. URL http://www.federalreserve.gov/pubs/oss/oss4/aimindex.html. Unpublished Manuscript, Board of Governors of the Federal Reserve System., 1997.

Gary Anderson and George Moore. An efficient procedure for solving linear perfect foresight models. Un- published Manuscript, Board of Governors of the Federal Reserve System., 1983.