% ----------------------------------------------------------------
% AMS-LaTeX Paper ************************************************
% **** -----------------------------------------------------------
\documentclass[12pt,reqno,oneside]{amsart}
\usepackage{srcltx} % SRC Specials: DVI [Inverse] Search
\usepackage[left=1.25in,top=1.2in]{geometry}
\usepackage{harvard}
\usepackage{graphicx,longtable}
\allowdisplaybreaks[3]
\usepackage{calc}
\renewcommand{\baselinestretch}{1.1}
% ----------------------------------------------------------------
\vfuzz2pt % Don't report over-full v-boxes if over-edge is small
\hfuzz2pt % Don't report over-full h-boxes if over-edge is small
% THEOREMS -------------------------------------------------------
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\theoremstyle{remark}
\newtheorem{rem}[thm]{Remark}
%\numberwithin{equation}{section}
% MATH -----------------------------------------------------------
% \divby command defined below produces nice-looking, right-sized "a/b" template.
\newcommand{\divby}[2]{#1 \mathord{\left/ \vphantom{#1 #2} \right.}
    \kern-\nulldelimiterspace #2}
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
\newcommand{\abs}[1]{\left\vert#1\right\vert}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\Real}{\mathbb R}
\newcommand{\eps}{\varepsilon}
\newcommand{\To}{\xrightarrow}
%e.g.: \[X_t \To[t\to \infty]{q.m.} Z\]
%\newcommand{\BX}{\mathbf{B}(X)}
\newcommand{\A}{\mathcal{A}}
\renewcommand{\thesection}{\Roman{section}}
\newenvironment{fulltable}[1]{\noindent\begin{tabular*}{\textwidth}
   {@{}@{\extracolsep{\fill}}#1@{}}}{\end{tabular*}}
\DeclareMathOperator{\Var}{Var}
% ----------------------------------------------------------------
\begin{document}
%\setlength{\parskip}{.5\baselineskip plus 20pt - .5\baselineskip}
\title[\texttt{gensys2}]{Notes on the \texttt{gensys2} package}%
\author{Christopher A. Sims}%
\address{Department of Economics, Princeton University}%
\email{sims@princeton.edu}%

\thanks{\copyright 2000 by Christopher A. Sims.  This material may be reproduced for
educational and research purposes so long as the copies are not sold, even to
recover costs, the document is not altered, and this copyright notice is
included in the copies.}

\maketitle
% ----------------------------------------------------------------
This package assumes the user has a model in the form
\begin{equation}\label{eq:nlmodel}
  K(w_t,w_{t-1},\eps_t)+\Pi\eta_t=c\:,
\end{equation}
where $E_t\eta_{t+1}=0$ and $E_t\eps_{t+1}=0$.  The disturbances $\eps_t$ are
exogenously given, while $\eta_t$ is determined as a function of $\eps$ when
the model is solved.  There are $n$ equations and $n$ elements in $w$.

We assume the model has a deterministic steady state $\bar w$ satisfying
\begin{equation}\label{eq:ss}
  K(\bar w, \bar w,0)=C\:.
\end{equation}
We assume that the solution will imply that $w_t$ remains always on a stable
manifold, defined by   $H(w_t)=0$ and satisfying
\begin{equation}\label{eq:stabman}
   \{H(w_t)=\gamma\quad\text{and}\quad K(w_{t+1},w_t,\eps_{t+1})+\eta_{t+1} =C\}
   \;\Rightarrow \; H(w_{t+1})=\gamma\:,
\end{equation}
when $\eta_{t+1}$ depends on $\eps_{t+1}$ and $w_t$ appropriately.  The
``stability" of this manifold means either that $w_t\to \bar w$ along it, or
that in the neighborhood of $\bar w$ $w_t$ diverges from $\bar w$ at a rate no
faster than some known bound. It is this condition that allows us to solve
for $\eta$.

The system \eqref{eq:nlmodel} has the second-order Taylor expansion about
$\bar w$
\begin{multline}\label{eq:order2}
  K_{1ij}dw_{jt} =K_{2ij}dw_{j,t-1}+K_{3ij}\eps_{jt}+\\
   \tfrac{1}{2}(K_{11ijk}dw_{jt}dw_{kt}+2K_{12ijk}dw_{jt}dw_{k,t-1}+2K_{13ijk}dw_{jt}\eps_{kt}\\
   +K_{22ijk}dw_{j,t-1}dw_{k,t-1}+2K_{23ijk}dw_{j,t-1}\eps_{kt}+K_{33ijk}\eps_{jt}\eps_{kt})\:,
\end{multline}
where we have resorted to tensor notation.  That is, we are using the notation
that
\begin{equation}\label{eq:tensdef}
  A_{ijk}B_{mnjq}=C_{ikmnq}\quad\Leftrightarrow\quad c_{ikmnq}=\sum_{j}a_{ijk}b_{mnjq}\:.
\end{equation}
where $a,b,c$ in this expression refer to individual elements of
multidimensional arrays, while $A,B,C$ refer to the arrays themselves.  As
special case, for example, ordinary matrix multiplication is
$AB=A_{ij}B_{jk}$ and the usual matrix expression $A'BA$ becomes
$A_{ji}B_{jk}A_{km}$.  Note that we are distinguishing the array $K_{mij}$ of
first derivatives from the array $K_{mnijk}$ of second derivatives only by
the number of indexing subscripts the two arrays have.

The solution will take the form
\begin{align}
   y_t &= F(y_{t-1},\eps_t) \label{eq:state}\\
   x_t &= M(y_t) \label{eq:control}\:,
\end{align}
where $[y_t'\; x_t']'=Z'w_t$, with $Z$ a square, non-singular matrix.  Equation
\eqref{eq:control} is just \eqref{eq:stabman} solved for some particular
linear combination of $w$'s (i.e. $x$).  If the original system has a standard
``state-control" form, $y$ can be taken as the state variable and $x$ as the
control variable.  However the \texttt{gensys2} program does not require that
the system be put in this form to start with.  If it will aid interpretation
to specify the state vector in advance, the program will use the prespecified
$y$ vector; but it can also generate a $y$ on its own.

The second-order expansion of the solution is
\begin{align}\label{eq:dyord2}
   \begin{split}
      dy_{it} = &F_{1ij}dy_{j,t-1}+F_{2ij}\eps_{jt}+F_{3i}\sigma^2\\
              &
              +\tfrac{1}{2}(F_{11ijk}dy_{j,t-1}dy_{k,t-1}+2F_{12ijk}dy_{j,t-1}\eps_{kt}
              +F_{22ijk}\eps_{jt}\eps_{kt})
   \end{split}\\ \label{eq:dxord2}
   dx_{it}= &M_{11ijk}dy_{jt}dy_{kt}+M_{2i}\sigma^2\:.
\end{align}

The program's calling sequence is
\begin{multline*}
   \mathtt{[FD,FDD,M11,M2,C,q,zs,zu,v,gev,eu]}\\ \mathtt{= gensys2(KD,KDD,c,Pi,omega,pick,div)}  .
\end{multline*}
\begin{longtable}{r@{:\hspace{.4in}}p{5in}}
   \texttt{KD}&A 1$\times$3 cell array with \texttt{KD\{j\}}$=K_{j\cdot\cdot}$
       from \eqref{eq:order2}.\\
   \texttt{KDD}& A 3$\times$3 cell array with
      \texttt{KDD\{jkm\}}$=K_{jk\cdot\cdot\cdot}$ from \eqref{eq:order2}.\\
   \texttt{c}& The right-hand side of \eqref{eq:nlmodel}.\\
   \texttt{Pi}& The coefficient on $\eta$ from \eqref{eq:nlmodel}.\\
   \texttt{omega} & The normalized covariance matrix of $\eps$, i.e. $\Omega$
      from $\Var(\eps(t))=\sigma^2\Omega$.\\
   \texttt{pick}& Candidate weights to form $y$. This is a matrix $\Psi$ such
      that $y_t=\Psi w_t$.  This argument is optional. If it is missing, or
      implies an incorrect selection of the state, the program will supply its
      own $\Psi$.\\
   \texttt{div}& Dividing line between unstable and ``stable" roots.  This
      argument is optional.  If it is missing, absolute values of 1 or less are
      assumed stable and anything larger than 1 is assumed unstable.\\
   \texttt{FD}& A 1$\times$3 cell array with \texttt{FD\{j\}}$=F_{j\cdot\cdot}$
      from \eqref{eq:dyord2}.\\
   \texttt{FDD}& A 2$\times$2 cell array with
      \texttt{FDD\{j,k\}}$=F_{jk\cdot\cdot\cdot}$ from \eqref{eq:dyord2}.\\
   \texttt{C}& The vector [$\bar y - F_1\bar y$ ; $\bar x$] .\\
   \texttt{q,v}& The matrices returned as \texttt{q,v} from
      \texttt{[a,b,q,z,v]=qz(KD\{1\},KD\{2\})}, after sorting to put unstable
      generalized eigenvalues at the bottom .\\
   \texttt{zs,zu}& \texttt{[zs;zu]'} is the matrix returned as \texttt{z} by the
      \texttt{qz} call above.  If \texttt{pick} was not present or was
      overridden, $y_t=\mathtt{zs}\,w_t$.  Always $x_t = \mathtt{zu}\,w_t$ .\\
   \texttt{gev}& The generalized eigenvalues of $K1,K2$, sorted.\\
   \texttt{eu}& Existence and uniqueness indicator.  See the program's help
      notes for details.
\end{longtable}

% ----------------------------------------------------------------
\end{document}
% ----------------------------------------------------------------
