Solving a LRE model in King-Watson form using alternative algorithms I have a linear rational expectation model that is in the King-Watson form: 

AE_{t}y{t+1} = By_{t} + C_{0}x_{t} + C_{1}x{t+1}  (1)


with the driving process 

x_{t}     = Q \delta_{t}                          (2)
delta_{t} = \rho \delta_{t-1} + G \espilson_{t}   (3)


I have a fairly large system and would like to solve it using a different algorithm than the King-Watson one, such as the Anderson-Moore algorithm (but am completely open to anything fast). However, I have so far failed in implementing the KW in Anderson-Moore. Any ideas on (i) how to solve the problem using the Anderson-Moore algo, or (ii) a different algorithm that can be used? 

Note, my system of equations in (1) is about 1000 lines.

Here is a toy example for parameterization

A  = [1,0,0,0;0,1,0,0;0,0,-1,-1;0,0,0,0];
B  = [0,0,1,0;0,0,0,1;0,0,-1.1,0;0,-0.7,0,1];
C  = [0,0;0,0;4,1;3,-2];
Q  = [1,0;0,1];
RHO= [0.9,0.1;0.05,0.2];
G  = [1,0;0,1];


which should yield

\Pi = [1,0,0,0; 0,1,0,0;0,1.225, -21.0857, 3.15714; 0, 0.7, -3, 2];
M   = [0,1.225, -21.0857, 3.15714; 0, 0.7, -3, 2; 0,0,0.9,0.1; 0,0,0.05,0.2];
The two approaches specify the linear rational expectations problem somewhat differently, but one can reconcile the solutions they produce.  In addition to the difference in the equation system specification, KW use the "predetermined variables" concept while AM does not.

King and Watson (KW) address a model of the form

$$
  A E_t y_{t+1} = B y_t + C_0E_t x_t +C_1 x_{t+1}\\
  x_t=Q \delta_t +G \epsilon_t\\
  \delta_t=\rho \delta_{t-1}\\
  y_t=
  \begin{bmatrix}
    \Lambda_t\\k_t
  \end{bmatrix}
$$

the $k_t$ are predetermined variables.

The algorithm produces solutions of the form
$$
 y_t=\Pi s_t\\
  s_t=M s_{t-1} + \bar{G} \epsilon_t\\
  s_t=
  \begin{bmatrix}
    k_t\\ \delta_t
  \end{bmatrix}
$$

Anderson Moore (AM) cast the problem as

$$
  H_{-1} w_{t-1} + H_0 w_t + H_{+1} E_t{w_{t+1}} = \psi_{\epsilon} \epsilon_t + \psi_c
$$

and produce solutions of the form

$$
  w_t=R w_{t-1}+ \phi \psi_\epsilon \epsilon_t + (I-F)^{-1}\phi\psi_c
$$

where 
$$  \phi=(H_0+H_{+1}R)^{-1}\,\, \text{and} \,\, F=-\phi H_{+1}
$$

In the AM setup, the $w_{t-1} $ are given as data and cannot be affected by the $\epsilon_t$ or
the  current or future values of $w_{t+i}\in, \{w_t,w_{t+1},\ldots\}$.
  In KW,  the ``predetermined'' variables at time t depend only on the already realized shocks.  So the
$\epsilon_t$ only influences future $k_{t+i} \in \{k_{t+1},k_{t+2},\ldots\}$  Consequently, to square AM and KW, the dating of some of the model variables
and their time subscripts  will differ.

Set

$$
 w_t=
  \begin{bmatrix}
\Lambda_{t}\\    k_{t+1}\\x_t\\  \delta_t
  \end{bmatrix}
$$

We will need to partition the KW $A=
\begin{bmatrix}
  A_1&amp;A_2
\end{bmatrix}
$ and $B=\begin{bmatrix}
  B_1&amp;B_2
\end{bmatrix}$
 matrices to accomodate  these differences.

Construct the AMA $H$ as

$$
H_{-1}=\begin{bmatrix}
  0&amp;-B_1&amp;0&amp;0  \\
  0&amp;0&amp;0&amp;-Q\\
  0&amp;0&amp;0&amp;-\rho
\end{bmatrix}\\
H_{0}=\begin{bmatrix}
  -B_2&amp;A_1&amp;-C_0&amp;0  \\
  0&amp;0&amp;I&amp;0\\
  0&amp;0&amp;0&amp;I
\end{bmatrix}\\
H_{+1}=\begin{bmatrix}
  A_2&amp;0&amp;-C_1&amp;0  \\
  0&amp;0&amp;0&amp;0\\
  0&amp;0&amp;0&amp;0
\end{bmatrix}$$ and 
$$\psi_c=0 \,\, \psi_\epsilon=
\begin{bmatrix}
0\\  0\\G\\0
\end{bmatrix}
$$

Then, we will find that
$$
  R=
  \begin{bmatrix}
    0&amp;M_{\Lambda,k}&amp;0&amp;M_{\Lambda,\delta}\\
    0&amp;M_{k,k}&amp;0&amp;M_{k,\delta}\\
    0&amp;0&amp;0&amp;M_{x,\delta}\\
    0&amp;0&amp;0&amp;M_{\delta,\delta}\\
  \end{bmatrix}
$$

So that for KW
$$
  M=
  \begin{bmatrix}
    M_{k,k}&amp;M_{k,\delta}\\
    0&amp;M_{\delta,\delta}\\
  \end{bmatrix}
$$

$$
\phi \psi_\epsilon=
\begin{bmatrix}
\bar{\bar{G}}\\
  \bar{G}
\end{bmatrix}
$$

The KW solution for $\Lambda_t$, $\Pi_\Lambda$ can be found by expressing the first few rows of R as a linear combination of the next few rows of R.

$$
  \begin{bmatrix}
      M_{\Lambda,k}&amp;M_{\Lambda,\delta} 
  \end{bmatrix}= \Pi_\Lambda
\begin{bmatrix}
      M_{k,k}&amp;M_{k,\delta}\\
\end{bmatrix}
$$

See also
Gary Anderson. Solving linear rational expections models: A horse race. Computational Economics, 31:95–113, March 2008.