Julia implementation of the anderson moore algorithm for solving linear rational expectations models
Author es335mathwiz
0 Stars
Updated Last
1 Year Ago
Started In
March 2018

AMA - Anderson Moore Algorithm

Release verison:

Build status:

Build Status Build status Coverage Status


To install AMA, use the package manager by typing:



This algorithm solves linear rational expectations models. There is a fast and slightly faster method to execute the algorithm which is outlined below. AndersonMooreAlg calls a julia language implementation and callSparseAim executes a C/Fortran implementation. Lastly, gensysToAMA is a function for users who are accustomed to gensys style inputs and outputs but wish to use AMA. It can be shown that AMA is faster than gensys. To begin,

Load the module:

using AndersonMoore

Declare the linear models to solve such as:

h = [0.  0.  0.  0.  -1.1  0.  0.  0.  1.  1.  0.  0.;
     0.  -0.4  0.  0.  0.  1.  -1.  0.  0.  0.  0.  0.;
     0.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.;
     0.  0.  0.  -1.  0.  0.  0.  1.  0.  0.  0.  0.]::Array{Float64,2}

Set number of equations:

neq = 4

Set number of lags and leads:

nlags = 1
nleads = 1

Set a tolerance to calculate numeric shift and reduced form:

condn = 0.0000000001

Finally, give an inclusive upper bound for modulus of roots allowed in reduced form:

upperbnd = 1 + condn

To execute the algorithm with julia:

(b, rts, ia, nexact, nnumeric, lgroots, AMAcode) =
     AndersonMooreAlg(h, neq, nlag, nlead, condn, upperbnd)

Note - the above returns the tuple (b, rts, ia, nexact, nnumeric, lgroots, AMAcode)

  • b - Reduced form coefficient matrix.
  • rts - Roots returned by eig.
  • ia - Dimension of companion matrix.
  • nexact - Number of exact shift rights.
  • nnumeric - Number of numeric shift rights.
  • lgroots - Number of roots greater in modulus than upper bound.
  • AMAcode - Return code.

To execute the algorithm with C/Fortran:

(h, b, q, AMAcode) = 
     callSparseAim(h, nleads, nlags)

Note - the above returns the tuple (h, b, q, AMAcode)

  • h - The original h matrix after computations.
  • b - Reduced form coefficient matrix.
  • q - Asymptotic constraints.
  • AMAcode - Return code.

For those accustomed to gensys:

(G1, CC, impact, fmat, fwt, ywt, gev, eu) = 
     gensysToAMA(g0, g1, cc, psi, pi, div, varargin = "" ) 

To run AMA, subsitute the gensys style inputs into the above command but substitute "ama" for the argument varargin.


For more information and an indepth analysis of the algorithm, please read the full paper written by Gary S. Anderson.

The authors would appreciate acknowledgement by citation of any of the following papers:

Anderson, G. and Moore, G. "A Linear Algebraic Procedure For Solving Linear Perfect Foresight Models." Economics Letters, 17, 1985.

Anderson, G. "Solving Linear Rational Expectations Models: A Horse Race." Computational Economics, 2008, vol. 31, issue 2, pp. 95-113

Anderson, G. "A Reliable and Computationally Efficient Algorithm for Imposing the Saddle Point Property in Dynamic Models." Journal of Economic Dynamics and Control, 2010, vol 34, issue 3, pp. 472-489.

Developer: Gregory Tunell e-mail available at

Required Packages

Used By Packages

No packages found.