About LQControl.m
------------------

LQcontrol.m is a MATLAB routine to compute optimal control policy
rules in possibly large linear forward-looking models. It is designed
to work in conjunction with AIM, an algorithm to compute the VAR
representations of linear rational expectations models. 

LQcontrol.m is provided by its developers, Fred Finan and Robert
Tetlow, as a public service. We welcome comments from users about
how it could be improved or how these instructions could be made
clearer. And we entertain enquiries. We do not, however, provide 
product support and we offer no guarantees of performance. Lastly,
we ask for acknowledgement when LQcontrol.m or any derivatives from 
which it may be based, are used in research. 

Including in this download...	
-----------------------------
	
	README				this file
	LQcontrol.m			a program to compute optimal 
					control rules
	numericSelectLargeISOPT.m	an alternative MATLAB program 
					(see below)
	example				an example file with the Clarida, 
					Gali & Gertler (1998) model 
					in the proper syntax.
	setexample.m			parameter settings for the CGG model.	

System requirements
-------------------

Users of LGQcontrol.m should first download AIM and get it up and 
running for a generic forward-looking model. You can use the model
of Clarida, Gali and Gertler (1998) included here if you like. 

Note: to run LQcontrol, it is best to have MATLAB version 5.0 
or higher. It *probably* works for version 4.0 and higher, but
we don't have that around any longer for testing.

To compute control rules for large models, it is also advisable 
to have a lot of memory. Should you run out of memory, a version
of AIM that does not use the fast, but memory intensive Kronecker
product calculation might be for you. Contact Gary Anderson through
the page in which you download AIM to get this version of AIM.

Preprocessing the Model
-------------------------------

The file 'example' is an example of the syntax in which a model
must be written in order for AIM's parser to understand it and
rewrite it in matrix notation. From that, AIM can compute the
VAR representation of the model. (See Anderson (1999) for details.)

In this section, we provide a few words of advice on how the model
should be written for the parser.

  1) make sure the order in which the variables appear in
     the list ENDOG_ is the same as in the body of equations 

  2) Specify the variable to be used as the control variable and 
     write the rule equation as the last behavioral equation.
     The rule should be 'set to zero' by having zero multiply some
     endogenous variable as shown. This is just a place keeper.

  3) Follow the rule equation by the ONE equation (always include
     this) and then the listing of stochastic shocks.

  4) For advice on the syntax of the parser, including what '_DATA'
     '_NOTD' and '_DTRM' mean, consult the AIM documentation.

To run LQcontrol, first parse the model, meaning get AIM to
compute the VAR representation of the model. Then type 'LQcontrol'
at the prompt. AIM returns matrices 'b' (among other things) which
is the reduced form coefficient matrix for the model with the 
optimized policy rule embedded within. To examine the numerical 
values of the rule, consult the appropriate row of 'b' counting
down the same number of rows as the order of the rule equation in
the original model. The next equations are the costate equations.
The output also includes 'sinv' the matrix that premultiplies
the vector of shocks to rescale them appropriately. 

With these, one can conduct impulse reponses with the model and
compare to the data or to impulses with ad hoc rules. One can
also compute the asymptotic moments of the model and hence an
"efficient policy frontier".

A problem to look out for regarding unit roots
----------------------------------------------

AIM, like any numerical tool, computes only approximate 
solutions--albeit to high levels of precision. On rare
occasions, however, problems have arisen associated with the
difficulties in numerically distinguishing a unit root 
from a root slightly different from unity. Recall that according
to the Blanchard-Kahn conditions, the number of roots greater
than unity must equal the number of non-predetermined variables
for there to be a unique saddlepoint solution. AIM requires
this condition to hold. 

Large-scale models will often have unit roots in them, most
of which are associated with either adding-up constraints or
accumulation identities.  In just running AIM alone, 
distinguishing between unit roots and near unit roots has
never been a problem.  In running LQcontrol, however, an 
extra layer of complication arises because costate equations
are added for every equation in the model, doubling the number 
of equations (plus one equation for the control variable). 
Each original equation in the model has a costate equation 
added the root for which should be the inverse of the root 
for the original equation. This means that if there are no
equations with unit roots, and no redundant equations, then 
a model with N equations originally, will always have N roots
greater than unity and N+1 equations with roots less after
costate equations have been computed. Equations associated with 
unit roots should have costates with unit roots as well. However, 
AIM will sometimes be unable to distinguish (within precision) 
the unit root of the costate equation with a root less than unity. 
When this happens, an error message stating 'too few big roots' 
is generated that may be false and AIM halts. 

When we have run into this difficulty, we have simply overridden
the error message in AIM and continued. This is perfectly correct
in any model that satisfies the rank condition for controllability.
And, in general, our experiments combined with the logic of the 
exercise suggest that if there exists one policy rule written as 
a function of any subset of model state variables that makes the 
model stable, then the AIM error message can be safely overridden. 
To put the issue in a slightly different way: any model for which 
the AIM error message cannot be ignored is a model that is ill posed
not just for optimal control, but for any monetary policy exercise.

How to override the AIM error flag:
----------------------------------

The override mentioned above has been written into an alternative 
version of the MATLAB file numericSelectLargeISOPT.m, which you should
have found with this download, instead of numericSelectLargeISOPT.m 
which you should have found in this download. Should you run into the 
forementioned problem, simply call this alternative version instead 
of the one provided with the AIM download. You can do this by editing
the file numericAsymptoticConstraint.m (from the AIM download) by
commenting out the line:

[vm,lm]=numericSelectLargeIS(lila,max(nrows,(hcols-hrows)...
-frows-nlag*hrows+2));

and typing in the lines:

numLargeRoots=hrows-frows;
[vm,lm]=numericSelectLargeISOPT(lila,max(nrows,(hcols-hrows)...
-frows-nlag*hrows+2),numLargeRoots);
