diff --git a/doc/DynareKalman.TeX b/doc/DynareKalman.TeX
new file mode 100644
index 0000000000000000000000000000000000000000..82729c4c65801089425b5b05d2ec11ab460acf08
--- /dev/null
+++ b/doc/DynareKalman.TeX
@@ -0,0 +1,196 @@
+% ----------------------------------------------------------------
+% AMS-LaTeX Paper ************************************************
+% **** -----------------------------------------------------------
+\documentclass{amsart}
+\usepackage{graphicx}
+% ----------------------------------------------------------------
+\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 -----------------------------------------------------------
+\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}{\longrightarrow}
+\newcommand{\BX}{\mathbf{B}(X)}
+\newcommand{\A}{\mathcal{A}}
+% ----------------------------------------------------------------
+\begin{document}
+
+\title{Kalman filtering and smoothing in Dynare}%
+% ----------------------------------------------------------------
+\maketitle
+% ----------------------------------------------------------------
+
+\section*{Introduction}
+
+\noindent \textbf{``Filtering and Smoothing of State Vector for
+Diffuse State Space Models''}, S.J. Koopman and J. Durbin (2003,
+in \textit{Journal of Time Series Analysis}, vol. 24(1), pp.
+85-98).\newline
+
+\noindent \textbf{``Fast Filtering and Smoothing for Multivariate
+State Space Models''}, S.J. Koopman and J. Durbin (2000, in
+\textit{Journal of Time Series Analysis}, vol. 21(3), pp.
+282-296).\newline
+
+
+\bigskip
+
+\noindent \textsc{The State-Space Model}\footnote{Note that in
+Dynare, matrices $T$, $Z$, $R$, $H$ and $Q$ are assumed to be time
+invariant.}:
+
+\[y_t =   Z\alpha_t + \varepsilon_t\]
+\[\alpha_{t+1} = T \alpha_t + R\eta_t\]
+with:
+\[\alpha_1 = a + A\delta + R_0\eta_0\]
+
+\noindent $m\times q$ matrix $A$ and $m\times(m-q)$ matrix $R_0$
+are selection matrices (their columns constitue all the columns of
+the $m\times m$ identity matrix) so that $A'R_0 = 0$ and
+$A'\alpha_1 = \delta$. We assume that the vector $\delta$ is
+distributed as a $\mathcal{N}(0,\kappa I_q)$ for a given  $\kappa
+> 0$. So that the expectation of $\alpha_1$ is a and its variance
+is $P$, with
+
+\[ P = \kappa P_{\infty} + P_{\star}\]
+\[           P_{\infty} = A A'\]
+\[ P_{\star}  = R_0 Q_0 R_0'\]
+
+\noindent $P_{\infty}$ is a $m\times m$ diagonal matrix with $q$
+ones and $m-q$ zeros. and where: $y_t$ is a $pp\times 1$ vector,
+$\alpha_t$ is a $mm\times 1$ vector, $\varepsilon_t$ is a
+$pp\times 1$ multivariate random variable (iid
+$\mathcal{N}(0,H)$), $\eta_t$ is a $rr\times 1$ multivariate
+random variable (iid $\mathcal{N}(0,Q)$), $a_1$ is a $mm\times 1$
+vector, $Z_t$ is a $pp\times mm$ matrix, $T$ is a $mm \times mm$
+matrix, $H$ is a $pp\times pp$ matrix, $R$ is a $mm\times rr$
+matrix, $Q$ is a $rr\times rr$ matrix and $P_1$ is a $mm\times mm$
+matrix. \newline
+
+\section{Filtering}
+
+\noindent The filtering equations are given by:
+\begin{equation}
+\begin{split}
+v_t &= y_t - Z  a_t\\
+F_t &= Z P_t Z' + H\\
+K_t &= P_t Z' F_t^{-1}\\
+a_{t+1} &= T (a_t + K_t v_t)\\
+P_{t+1} &= T (P_t - P_tZ'K') T' + R Q R'\\
+\end{split}
+\end{equation}
+$\{F_t\}$ and $\{v_t\}$ are used to evaluate the likelihood. A
+potentially faster algorithm (unfortunately not with matlab) is to
+consider a univariate approach to the multivariate Kalman filter
+(the covariance matrix associated to the measurement errors has to
+be diagonal: $H=diag(\sigma_1^2,\dots,\sigma_{pp}^2)$). Let $Z_i$
+be line $i$ of the selection matrix $Z$. The univariate algorithm
+is as follows :
+\begin{equation}
+\begin{split}
+v_{t,i} &= y_{t,i} - Z_i  a_t^{(i)}\\
+F_t^{(i)} &= Z_i P_t^{(i)} Z_i' + \sigma_{i}^2\\
+K_t^{(i)} &= P_t^{(i)} Z_i'\\
+a_{t}^{(i+1)} &= a_t^{(i)} + K_t^{(i)} v_{t,i} / F_t^{(i)}\\
+P_{t}^{(i+1)} &= P_{t}^{(i)} - K_{t}^{(i)} \left.K_t^{(i)}\right.' / F_t^{(i)}\\
+a_{t+1}^{(1)} &= T a_t^{(pp)}\\
+P_{t+1}^{(1)} &= T P_t^{(pp)} T' + R Q R'\\
+\end{split}
+\end{equation}
+when $F_t^{(i)}$ is equal to zero we simply have
+$a_{t}^{(i+1)}=a_{t}^{(i)}$ and $P_{t}^{(i+1)}=P_{t}^{(i)}$. The
+log-likelihood is evaluated as follows:
+\begin{equation}
+\mathcal{L}_T = const -\frac{1}{2}\sum_{i=1}^{pp}\sum_{t=1}^n \log
+F_{t}^{(i)} + v_{t,i}^2 / F_{t}^{(i)}
+\end{equation}
+
+\bigskip
+
+\noindent The diffuse filtering equations are given by:
+\begin{equation}
+\begin{split}
+v_t &= y_t - Z  a_t\\
+F_{\infty,t} &= Z P_{\infty,t} Z' + H\\
+K_{\infty,t} &= P_{\infty,t} Z' F_{\infty,t}^{-1}\\
+F_{\ast,t} &= Z P_{\ast,t} Z' + H\\
+K_{\ast,t} &= \left(P_{\ast,t} Z' - K_{\infty,t}F_{\ast,t}\right)F_{\infty,t}^{-1}\\
+P_{\ast,t+1} &= T (P_{\ast,t}-P_{\ast,t}Z'K_{\infty,t}' - P_{\infty,t}Z'K_{\ast,t}') T' + R Q R'\\
+P_{\infty,t+1} &= T(P_{\infty,t}-P_{\infty,t}Z'K_{\infty,t}')T'\\
+a_{t+1} &= T (a_t + K_{\infty,t} v_t)\\
+\end{split}
+\end{equation}
+When the condition $rank(P_{\infty,t+1})=0$ is satisfied we set
+$d=t$ and go back to the standard Kalman filtering equations. Here
+$F_{\infty,t}$ is assumed to be a full rank matrix. If this is not
+the case we switch to another algorithm. If $F_{\infty,t}=0$:
+\begin{equation}
+\begin{split}
+v_t &= y_t - Z  a_t\\
+F_{\ast,t} &= Z P_{\ast,t} Z' + H\\
+K_{\ast,t} &= P_{\ast,t} Z'F_{\infty,t}^{-1}\\
+P_{\ast,t+1} &= T (P_{\ast,t}-P_{\ast,t}Z'K_{\ast,t}') T' + R Q R'\\
+P_{\infty,t+1} &= TP_{\infty,t}T'\\
+a_{t+1} &= T (a_t + K_{\ast,t} v_t)\\
+L_t &= T(I - K_t Z)\\
+\end{split}
+\end{equation}
+otherwise, we consider a diffuse version of the univariate
+approach described above.
+
+\section{Smoothing}
+
+\noindent The smoothing equations are given by:
+\begin{equation}
+\begin{split}
+r_{t-1} &= Z' F_t^{-1}v_t + L_t' r_t\\
+\widehat{\alpha}_t &= a_t + P_t r_{t-1} \\
+\widehat{\eta}_t &= Q R r_t\\
+\widehat{\varepsilon}_t &= H \left(F_t^{-1}v_t-K_t'r_t\right)\\
+\end{split}
+\end{equation}
+initializing with $r_n = 0$ and with $L_t = T-K_tZ$. The diffuse
+smoothing equations are given by :
+\begin{equation}
+\begin{split}
+r_{t-1}^{(0)} &= L_{\infty,t}r_{t}^{(0)}\\
+r_{t-1}^{(1)} &= Z' F_{\infty,t}^{-1}v_t - K_{\ast,t}'r_{t}^{(0)}+ L_{\infty,t}' r_t^{(1)}\\
+\widehat{\alpha}_t &= a_t + P_{\ast,t} r_{t-1}^{(0)} + P_{\infty,t}r_{t-1}^{(1)}\\
+\widehat{\eta}_t &= Q R r_t^{(0)}\\
+\widehat{\varepsilon}_t &= -H K_{\infty,t}'r_t^{(0)}\\
+\end{split}
+\end{equation}
+for $t = d,d-1,...,1$, where $d$ is such that $P_{\infty,d+1}=0$.
+This backward recurrence is initialized with $r_{d}^{(0)}=r_{d}$,
+obtained from the non diffuse Kalman smoother, and
+$r_{d}^{(1)}=0$. $L_{\infty,t} = T-K_{\infty,t}Z$.\newline
+
+
+\noindent A univariate smoothing algorithm has to be coded... In
+the smoothing part the matrix $F_t$ (or $F_{\infty,t}$) is assumed
+to be full rank...
+
+
+
+
+
+% ----------------------------------------------------------------
+%\bibliographystyle{amsplain}
+%\bibliography{}
+\end{document}
+% ----------------------------------------------------------------
+
+
diff --git a/doc/bibmad.sty b/doc/bibmad.sty
new file mode 100644
index 0000000000000000000000000000000000000000..d25236e0691a56a7a750565c83dd26edcb0e8c8a
--- /dev/null
+++ b/doc/bibmad.sty
@@ -0,0 +1,105 @@
+\message{harvard bibliography,}
+
+\def\@hiteml[#1]#2#3#4{\item[]\if@filesw%
+      { \def\protect##1{\string ##1\space}\immediate%
+\write\@auxout{\string\harvardcite{#4}{#2}{#1}{#3}}}\fi%
+\protect\hspace*{-\labelwidth}\protect\hspace*{-\labelsep}\ignorespaces}
+
+\def\@hitem#1#2#3{\item[]\if@filesw%
+      { \def\protect##1{\string ##1\space}\immediate%
+\write\@auxout{\string\harvardcite{#3}{#1}{#1}{#2}}}\fi%
+\protect\hspace*{-\labelwidth}\protect\hspace*{-\labelsep}\ignorespaces}
+
+\def\harvarditem{\@ifnextchar [{\@hiteml}{\@hitem}}
+
+\def\harvardcite#1#2#3#4{
+  \global\@namedef{bhf@#1}{#2}
+  \global\@namedef{bha@#1}{#3}
+  \global\@namedef{bhy@#1}{#4}\global\@namedef{b@#1}{\csname bhf@#1\endcsname}
+}
+
+\def\citeasnoun{\@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}
+\def\cite{\@ifnextchar [{\@tempswatrue\@citexasnoun}
+                           {\@tempswafalse\@citexasnoun[]}
+}
+\def\citeyear{\@ifnextchar [{\@tempswatrue\@citexyear}
+                           {\@tempswafalse\@citexyear[]}
+}
+\def\citename{\@ifnextchar [{\@tempswatrue\@citexname}
+                           {\@tempswafalse\@citexname[]}
+}
+
+% \def\@enamedef#1{\expandafter\edef\csname #1\endcsname}
+% Previous line should be replaced by the following to prevent
+% problems with the NFSS. Solution by Bernd Raichle.
+\def\@enamedef#1{\expandafter\def\csname #1\expandafter\endcsname\expandafter}
+
+\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
+  \def\@citea{}\@cite{\@for\@citeb:=#2\do
+    {\@citea\def\@citea{\@hisep\penalty\@m\ }\@ifundefined
+       {b@\@citeb}{{\bf ?}\@warning
+       {Citation `\@citeb' on page \thepage \space undefined}}%
+{{\csname b@\@citeb\endcsname\@hysep\csname bhy@\@citeb\endcsname}%
+\global\@enamedef{b@\@citeb}{\csname bha@\@citeb\endcsname}}%
+}}{#1}}
+
+\def\@citexasnoun[#1]#2{%
+\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi%
+\@citeasnoun{{\@ifundefined%
+{b@#2}%
+{[{\bf ?}\@warning{Citation `#2' on page \thepage \space undefined}}%
+{{\csname b@#2\endcsname\ [\csname bhy@#2\endcsname}%
+\global\@namedef{b@#2}{\csname bha@#2\endcsname}}%
+}}{#1}}
+
+\def\@citexname[#1]#2{%
+\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi%
+\@citename{{\@ifundefined%
+{b@#2}%
+{{\bf ?}\@warning{Citation `#2' on page \thepage \space undefined}}%
+{{\csname bhf@#2\endcsname}}%
+}}{#1}}
+
+\def\@citexyear[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
+  \def\@citeayear{}\@cite{\@for\@citebyear:=#2\do
+    {\@citeayear\def\@citeayear{\@hisep\penalty\@m\ }\@ifundefined
+       {b@\@citebyear}{{\bf ?}\@warning
+       {Citation `\@citebyear' on page \thepage \space undefined}}%
+{{\csname bhy@\@citebyear\endcsname}%
+}%
+}}{#1}}
+
+\gdef\hysep@agsm{\ }\gdef\hisep@agsm{,}%
+\gdef\hysep@dcu{, }\gdef\hisep@dcu{;}%
+\let\@hysep\hysep@agsm \let\@hisep\hisep@agsm
+\def\citationstyle#1{%
+\global\@namedef{@hysep}{\csname hysep@#1\endcsname}%
+\global\@namedef{@hisep}{\csname hisep@#1\endcsname}}
+ 
+%DEFAULT DEFINITIONS
+\def\@cite#1#2{({#1\if@tempswa , #2\fi})}
+\def\@citeasnoun#1#2{{#1\if@tempswa , #2\fi]}}
+\def\@citename#1#2{{#1\if@tempswa \ (#2)\fi}}
+
+% CHANGE \end{document} - to handle double definitions
+\def\enddocument{\@checkend{document}\clearpage\begingroup
+\if@filesw \immediate\closeout\@mainaux
+\def\global\@namedef##1##2{}\def\newlabel{\@testdef r}%
+\def\bibcite{\@testdef b}%
+\def\harvardcite{\@testbibh}\@tempswafalse \makeatletter\input \jobname.aux
+\if@tempswa \@warning{Label(s) may have changed.  Rerun to get
+cross-references right}\fi\fi\endgroup\deadcycles\z@\@@end}
+ 
+\def\@testbibh #1#2#3{
+  \def\@tempa{#2}\expandafter
+  \ifx \csname bhf@#1\endcsname \@tempa 
+     \def\@tempa{#3}\expandafter
+     \ifx \csname bha@#1\endcsname \@tempa
+     \else \@tempswatrue
+     \fi
+  \else
+     \@tempswatrue
+  \fi
+}
+ 
+%
\ No newline at end of file
diff --git a/doc/dynare.xsl b/doc/dynare.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..337666d1dfd694c53e48d124caa0bb9ad528420d
--- /dev/null
+++ b/doc/dynare.xsl
@@ -0,0 +1,23 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
+                exclude-result-prefixes="doc"
+                version='1.0'>
+
+<!-- It is important to use indent="no" here, otherwise verbatim -->
+<!-- environments get broken by indented tags...at least when the -->
+<!-- callout extension is used...at least with some processors -->
+
+<xsl:param name="generate.index">1</xsl:param>
+<xsl:param name="refentry.generate.name">0</xsl:param>
+<xsl:param name="refentry.generate.title">1</xsl:param>
+<xsl:param name="section.autolabel" select="1"></xsl:param>
+<xsl:param name="biblioentry.item.separator">, </xsl:param>
+
+<xsl:attribute-set name="section.level1.properties">
+  <xsl:attribute name="break-before">page</xsl:attribute>
+</xsl:attribute-set>
+
+
+</xsl:stylesheet>
diff --git a/doc/dynare_fo.xsl b/doc/dynare_fo.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..ce5e367b50b357f7ef363b6a1f6604fbabfd96d4
--- /dev/null
+++ b/doc/dynare_fo.xsl
@@ -0,0 +1,28 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
+                exclude-result-prefixes="doc"
+                version='1.0'>
+
+<!-- It is important to use indent="no" here, otherwise verbatim -->
+<!-- environments get broken by indented tags...at least when the -->
+<!-- callout extension is used...at least with some processors -->
+<xsl:import href="e:/docbook-xsl-1.66.1/fo/docbook.xsl"/>
+<xsl:import href="dynare.xsl"/>
+
+<xsl:import href="dynare_lists.xsl"/>
+
+<xsl:param name="passivetex.extensions">1</xsl:param>
+<xsl:attribute-set name="list.item.spacing">
+  <xsl:attribute name="line-height">0em</xsl:attribute>
+</xsl:attribute-set>
+<xsl:attribute-set name="compact.list.item.spacing">
+  <xsl:attribute name="space-before.optimum">0em</xsl:attribute>
+  <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
+  <xsl:attribute name="space-before.maximum">0em</xsl:attribute>
+  <xsl:attribute name="line-height">0em</xsl:attribute>
+</xsl:attribute-set>
+ 
+
+</xsl:stylesheet>
diff --git a/doc/dynare_fo_fop.xsl b/doc/dynare_fo_fop.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..b99170fe54e5a274fcb7bdf3c5ff1b8489f84eb3
--- /dev/null
+++ b/doc/dynare_fo_fop.xsl
@@ -0,0 +1,115 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
+                exclude-result-prefixes="doc"
+                version='1.0'>
+
+<!-- It is important to use indent="no" here, otherwise verbatim -->
+<!-- environments get broken by indented tags...at least when the -->
+<!-- callout extension is used...at least with some processors -->
+<!-- <xsl:import href="c:/cygwin/usr/share/docbook-xsl/fo/docbook.xsl"/> -->
+<xsl:import href="e:/docbook-xsl-1.65.1/fo/docbook.xsl"/>
+
+<xsl:param name="use.extensions">1</xsl:param>
+<xsl:param name="fop.extensions">1</xsl:param>
+<xsl:param name="refentry.generate.name">0</xsl:param>
+<xsl:param name="refentry.generate.title">1</xsl:param>
+<xsl:template match="refsynopsisdiv">
+  <fo:block font-weight="bold" font-size="16pt" font-family="sans-serif">
+    <xsl:call-template name="gentext">
+                  <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
+    </xsl:call-template>
+  </fo:block>
+    <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="refnamediv">
+  <xsl:variable name="section.level">
+    <xsl:call-template name="refentry.level">
+      <xsl:with-param name="node" select="ancestor::refentry"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="reftitle">
+    <xsl:choose>
+      <xsl:when test="$refentry.generate.name != 0">
+        <xsl:call-template name="gentext">
+          <xsl:with-param name="key" select="'RefName'"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:when test="$refentry.generate.title != 0">
+        <xsl:choose>
+          <xsl:when test="../refmeta/refentrytitle">
+            <xsl:apply-templates select="../refmeta/refentrytitle"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select="refname[1]"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:variable>
+
+  <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
+  <fo:block>
+    <xsl:choose>
+      <xsl:when test="$section.level = 1">
+        <fo:block xsl:use-attribute-sets="refentry.title.properties">
+          <fo:block xsl:use-attribute-sets="section.title.level1.properties">
+            <xsl:value-of select="$reftitle"/>
+          </fo:block>
+        </fo:block>
+      </xsl:when>
+      <xsl:when test="$section.level = 2">
+        <fo:block xsl:use-attribute-sets="refentry.title.properties">
+          <fo:block xsl:use-attribute-sets="section.title.level2.properties">
+            <xsl:value-of select="$reftitle"/>
+          </fo:block>
+        </fo:block>
+      </xsl:when>
+      <xsl:when test="$section.level = 3">
+        <fo:block xsl:use-attribute-sets="refentry.title.properties">
+          <fo:block xsl:use-attribute-sets="section.title.level3.properties">
+            <xsl:value-of select="$reftitle"/>
+          </fo:block>
+        </fo:block>
+      </xsl:when>
+      <xsl:when test="$section.level = 4">
+        <fo:block xsl:use-attribute-sets="refentry.title.properties">
+          <fo:block xsl:use-attribute-sets="section.title.level4.properties">
+            <xsl:value-of select="$reftitle"/>
+          </fo:block>
+        </fo:block>
+      </xsl:when>
+      <xsl:when test="$section.level = 5">
+        <fo:block xsl:use-attribute-sets="refentry.title.properties">
+          <fo:block xsl:use-attribute-sets="section.title.level5.properties">
+            <xsl:value-of select="$reftitle"/>
+          </fo:block>
+        </fo:block>
+      </xsl:when>
+      <xsl:otherwise>
+        <fo:block xsl:use-attribute-sets="refentry.title.properties">
+          <fo:block xsl:use-attribute-sets="section.title.level6.properties">
+            <xsl:value-of select="$reftitle"/>
+          </fo:block>
+        </fo:block>
+      </xsl:otherwise>
+    </xsl:choose>
+
+    <fo:block space-after="1em">
+      <xsl:choose>
+        <xsl:when test="../refmeta/refentrytitle">
+          <xsl:apply-templates select="../refmeta/refentrytitle"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="refname[1]"/>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:apply-templates select="refpurpose"/>
+    </fo:block>
+  </fo:block>
+  
+</xsl:template>
+</xsl:stylesheet>
diff --git a/doc/dynare_html.xsl b/doc/dynare_html.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..ef41a4c7c0b9283ec0771f08159d7b26f18836b8
--- /dev/null
+++ b/doc/dynare_html.xsl
@@ -0,0 +1,15 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
+                exclude-result-prefixes="doc"
+                version='1.0'>
+
+<!-- It is important to use indent="no" here, otherwise verbatim -->
+<!-- environments get broken by indented tags...at least when the -->
+<!-- callout extension is used...at least with some processors -->
+<xsl:import href="c:/cygwin/usr/share/docbook-xsl/html/chunk.xsl"/>
+
+<xsl:import href="dynare.xsl"/>
+
+</xsl:stylesheet>
diff --git a/doc/dynare_lists.xsl b/doc/dynare_lists.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..99f421b4e9c9e7bc9672d2ca42a97f8bd7dff9cd
--- /dev/null
+++ b/doc/dynare_lists.xsl
@@ -0,0 +1,1169 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                version='1.0'>
+
+<!-- ********************************************************************
+     $Id: dynare_lists.xsl,v 1.1 2005/01/09 13:00:17 michel Exp $
+     ********************************************************************
+
+     This file is part of the XSL DocBook Stylesheet distribution.
+     See ../README or http://nwalsh.com/docbook/xsl/ for copyright
+     and other information.
+
+     ******************************************************************** -->
+
+<!-- ==================================================================== -->
+
+<xsl:template match="itemizedlist">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="label-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'label-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="title">
+    <xsl:apply-templates select="title" mode="list.title.mode"/>
+  </xsl:if>
+
+  <!-- Preserve order of PIs and comments -->
+  <xsl:apply-templates 
+      select="*[not(self::listitem
+                or self::title
+                or self::titleabbrev)]
+              |comment()[not(preceding-sibling::listitem)]
+              |processing-instruction()[not(preceding-sibling::listitem)]"/>
+
+  <xsl:variable name="content">
+    <xsl:apply-templates 
+          select="listitem
+                  |comment()[preceding-sibling::listitem]
+                  |processing-instruction()[preceding-sibling::listitem]"/>
+  </xsl:variable>
+
+  <!-- nested lists don't add extra list-block spacing -->
+  <xsl:choose>
+    <xsl:when test="ancestor::listitem">
+      <fo:list-block id="{$id}" 
+                     provisional-label-separation="0.2em">
+        <xsl:attribute name="provisional-distance-between-starts">
+          <xsl:choose>
+            <xsl:when test="$label-width != ''">
+              <xsl:value-of select="$label-width"/>
+            </xsl:when>
+            <xsl:otherwise>1.5em</xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+        <xsl:copy-of select="$content"/>
+      </fo:list-block>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing"
+                     provisional-label-separation="0.2em">
+        <xsl:attribute name="provisional-distance-between-starts">
+          <xsl:choose>
+            <xsl:when test="$label-width != ''">
+              <xsl:value-of select="$label-width"/>
+            </xsl:when>
+            <xsl:otherwise>1.5em</xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+        <xsl:copy-of select="$content"/>
+      </fo:list-block>
+    </xsl:otherwise>
+  </xsl:choose>
+
+</xsl:template>
+
+<xsl:template match="itemizedlist/title|orderedlist/title">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="variablelist/title" mode="vl.as.list">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="variablelist/title" mode="vl.as.blocks">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="itemizedlist/titleabbrev|orderedlist/titleabbrev">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="procedure/titleabbrev">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="variablelist/titleabbrev" mode="vl.as.list">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="variablelist/titleabbrev" mode="vl.as.blocks">
+  <!--nop-->
+</xsl:template>
+
+<xsl:template match="itemizedlist/listitem">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+  <xsl:variable name="itemsymbol">
+    <xsl:call-template name="list.itemsymbol">
+      <xsl:with-param name="node" select="parent::itemizedlist"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="item.contents">
+    <fo:list-item-label end-indent="label-end()">
+      <fo:block>
+        <xsl:choose>
+          <xsl:when test="$itemsymbol='disc'">&#x2022;</xsl:when>
+          <xsl:when test="$itemsymbol='bullet'">&#x2022;</xsl:when>
+          <!-- why do these symbols not work? -->
+          <!--
+          <xsl:when test="$itemsymbol='circle'">&#x2218;</xsl:when>
+          <xsl:when test="$itemsymbol='round'">&#x2218;</xsl:when>
+          <xsl:when test="$itemsymbol='square'">&#x2610;</xsl:when>
+          <xsl:when test="$itemsymbol='box'">&#x2610;</xsl:when>
+          -->
+          <xsl:otherwise>&#x2022;</xsl:otherwise>
+        </xsl:choose>
+      </fo:block>
+    </fo:list-item-label>
+    <fo:list-item-body start-indent="body-start()">
+      <!-- fo:block -->
+	<xsl:apply-templates/>
+      <!-- /fo:block -->
+    </fo:list-item-body>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="parent::*/@spacing = 'compact'">
+      <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
+        <xsl:copy-of select="$item.contents"/>
+      </fo:list-item>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
+        <xsl:copy-of select="$item.contents"/>
+      </fo:list-item>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="orderedlist">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="label-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'label-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="title">
+    <xsl:apply-templates select="title" mode="list.title.mode"/>
+  </xsl:if>
+
+  <!-- Preserve order of PIs and comments -->
+  <xsl:apply-templates 
+      select="*[not(self::listitem
+                or self::title
+                or self::titleabbrev)]
+              |comment()[not(preceding-sibling::listitem)]
+              |processing-instruction()[not(preceding-sibling::listitem)]"/>
+
+  <xsl:variable name="content">
+    <xsl:apply-templates 
+          select="listitem
+                  |comment()[preceding-sibling::listitem]
+                  |processing-instruction()[preceding-sibling::listitem]"/>
+  </xsl:variable>
+
+  <!-- nested lists don't add extra list-block spacing -->
+  <xsl:choose>
+    <xsl:when test="ancestor::listitem">
+      <fo:list-block id="{$id}" 
+                     provisional-label-separation="0.2em">
+        <xsl:attribute name="provisional-distance-between-starts">
+          <xsl:choose>
+            <xsl:when test="$label-width != ''">
+              <xsl:value-of select="$label-width"/>
+            </xsl:when>
+            <xsl:otherwise>2em</xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+        <xsl:copy-of select="$content"/>
+      </fo:list-block>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing"
+                     provisional-label-separation="0.2em">
+        <xsl:attribute name="provisional-distance-between-starts">
+          <xsl:choose>
+            <xsl:when test="$label-width != ''">
+              <xsl:value-of select="$label-width"/>
+            </xsl:when>
+            <xsl:otherwise>2em</xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+        <xsl:copy-of select="$content"/>
+      </fo:list-block>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="orderedlist/listitem" mode="item-number">
+  <xsl:variable name="numeration">
+    <xsl:call-template name="list.numeration">
+      <xsl:with-param name="node" select="parent::orderedlist"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="$numeration='arabic'">1.</xsl:when>
+      <xsl:when test="$numeration='loweralpha'">a.</xsl:when>
+      <xsl:when test="$numeration='lowerroman'">i.</xsl:when>
+      <xsl:when test="$numeration='upperalpha'">A.</xsl:when>
+      <xsl:when test="$numeration='upperroman'">I.</xsl:when>
+      <!-- What!? This should never happen -->
+      <xsl:otherwise>
+        <xsl:message>
+          <xsl:text>Unexpected numeration: </xsl:text>
+          <xsl:value-of select="$numeration"/>
+        </xsl:message>
+        <xsl:value-of select="1."/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:variable name="item-number">
+    <xsl:call-template name="orderedlist-item-number"/>
+  </xsl:variable>
+
+  <xsl:if test="parent::orderedlist/@inheritnum='inherit'
+                and ancestor::listitem[parent::orderedlist]">
+    <xsl:apply-templates select="ancestor::listitem[parent::orderedlist][1]"
+                         mode="item-number"/>
+  </xsl:if>
+
+  <xsl:number value="$item-number" format="{$type}"/>
+</xsl:template>
+
+<xsl:template match="orderedlist/listitem">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+  <xsl:variable name="item.contents">
+    <fo:list-item-label end-indent="label-end()">
+      <fo:block>
+        <xsl:apply-templates select="." mode="item-number"/>
+      </fo:block>
+    </fo:list-item-label>
+    <fo:list-item-body start-indent="body-start()">
+      <fo:block>
+	<xsl:apply-templates/>
+      </fo:block>
+    </fo:list-item-body>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="parent::*/@spacing = 'compact'">
+      <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
+        <xsl:copy-of select="$item.contents"/>
+      </fo:list-item>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
+        <xsl:copy-of select="$item.contents"/>
+      </fo:list-item>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="listitem/*[1][local-name()='para' or 
+                                   local-name()='simpara' or 
+                                   local-name()='formalpara']
+                     |step/*[1][local-name()='para' or 
+                                   local-name()='simpara' or 
+                                   local-name()='formalpara']
+                     |callout/*[1][local-name()='para' or 
+                                   local-name()='simpara' or 
+                                   local-name()='formalpara']"
+              priority="2">
+  <fo:block>
+    <xsl:call-template name="anchor"/>
+    <xsl:apply-templates/>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="variablelist">
+  <xsl:variable name="presentation">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'list-presentation'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$presentation = 'list'">
+      <xsl:apply-templates select="." mode="vl.as.list"/>
+    </xsl:when>
+    <xsl:when test="$presentation = 'blocks'">
+      <xsl:apply-templates select="." mode="vl.as.blocks"/>
+    </xsl:when>
+    <xsl:when test="$variablelist.as.blocks != 0">
+      <xsl:apply-templates select="." mode="vl.as.blocks"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates select="." mode="vl.as.list"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="variablelist" mode="vl.as.list">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="term-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'term-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="termlength">
+    <xsl:choose>
+      <xsl:when test="$term-width != ''">
+        <xsl:value-of select="$term-width"/>
+      </xsl:when>
+      <xsl:when test="@termlength">
+        <xsl:variable name="termlength.is.number">
+          <xsl:value-of select="@termlength + 0"/>
+        </xsl:variable>
+        <xsl:choose>
+          <xsl:when test="$termlength.is.number = 'NaN'">
+            <!-- if the term length isn't just a number, assume it's a measurement -->
+            <xsl:value-of select="@termlength"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="@termlength"/>
+            <xsl:text>em * 0.60</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="longest.term">
+          <xsl:with-param name="terms" select="varlistentry/term"/>
+          <xsl:with-param name="maxlength" select="$variablelist.max.termlength"/>
+        </xsl:call-template>
+        <xsl:text>em * 0.60</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+<!--
+  <xsl:message>
+    <xsl:text>term width: </xsl:text>
+    <xsl:value-of select="$termlength"/>
+  </xsl:message>
+-->
+
+  <xsl:variable name="label-separation">1em</xsl:variable>
+
+  <xsl:if test="title">
+    <xsl:apply-templates select="title" mode="list.title.mode"/>
+  </xsl:if>
+
+  <!-- Preserve order of PIs and comments -->
+  <xsl:apply-templates 
+    select="*[not(self::varlistentry
+              or self::title
+              or self::titleabbrev)]
+            |comment()[not(preceding-sibling::varlistentry)]
+            |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
+
+  <xsl:variable name="content">
+    <xsl:apply-templates mode="vl.as.list"
+      select="varlistentry
+              |comment()[preceding-sibling::varlistentry]
+              |processing-instruction()[preceding-sibling::varlistentry]"/>
+  </xsl:variable>
+
+  <!-- nested lists don't add extra list-block spacing -->
+  <xsl:choose>
+    <xsl:when test="ancestor::listitem">
+      <fo:list-block id="{$id}"
+                     provisional-distance-between-starts=
+                        "{$termlength}+{$label-separation}"
+                     provisional-label-separation="{$label-separation}">
+        <xsl:copy-of select="$content"/>
+      </fo:list-block>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:list-block id="{$id}"
+                     provisional-distance-between-starts=
+                        "{$termlength}+{$label-separation}"
+                     provisional-label-separation="{$label-separation}"
+                     xsl:use-attribute-sets="list.block.spacing">
+        <xsl:copy-of select="$content"/>
+      </fo:list-block>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="longest.term">
+  <xsl:param name="longest" select="0"/>
+  <xsl:param name="terms" select="."/>
+  <xsl:param name="maxlength" select="-1"/>
+
+  <xsl:choose>
+    <xsl:when test="$longest &gt; $maxlength and $maxlength &gt; 0">
+      <xsl:value-of select="$maxlength"/>
+    </xsl:when>
+    <xsl:when test="not($terms)">
+      <xsl:value-of select="$longest"/>
+    </xsl:when>
+    <xsl:when test="string-length($terms[1]/node()[not(indexterm)]) &gt; $longest">
+      <xsl:call-template name="longest.term">
+        <xsl:with-param name="longest" 
+	    select="string-length($terms[1]/node()[not(indexterm)])"/>
+        <xsl:with-param name="maxlength" select="$maxlength"/>
+        <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="longest.term">
+        <xsl:with-param name="longest" select="$longest"/>
+        <xsl:with-param name="maxlength" select="$maxlength"/>
+        <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="varlistentry" mode="vl.as.list">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
+    <fo:list-item-label end-indent="label-end()" text-align="start">
+      <fo:block>
+        <xsl:apply-templates select="term"/>
+      </fo:block>
+    </fo:list-item-label>
+    <fo:list-item-body start-indent="body-start()">
+      <fo:block>
+	<xsl:apply-templates select="listitem"/>
+      </fo:block>
+    </fo:list-item-body>
+  </fo:list-item>
+</xsl:template>
+
+<xsl:template match="variablelist" mode="vl.as.blocks">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <!-- termlength is irrelevant -->
+
+  <xsl:if test="title">
+    <xsl:apply-templates select="title" mode="list.title.mode"/>
+  </xsl:if>
+
+  <!-- Preserve order of PIs and comments -->
+  <xsl:apply-templates 
+    select="*[not(self::varlistentry
+              or self::title
+              or self::titleabbrev)]
+            |comment()[not(preceding-sibling::varlistentry)]
+            |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
+
+  <xsl:variable name="content">
+    <xsl:apply-templates mode="vl.as.blocks"
+      select="varlistentry
+              |comment()[preceding-sibling::varlistentry]
+              |processing-instruction()[preceding-sibling::varlistentry]"/>
+  </xsl:variable>
+
+  <!-- nested lists don't add extra list-block spacing -->
+  <xsl:choose>
+    <xsl:when test="ancestor::listitem">
+      <fo:block id="{$id}">
+        <xsl:copy-of select="$content"/>
+      </fo:block>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
+        <xsl:copy-of select="$content"/>
+      </fo:block>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="varlistentry" mode="vl.as.blocks">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+  <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"  
+      keep-together.within-column="always" 
+      keep-with-next.within-column="always">
+    <xsl:apply-templates select="term"/>
+  </fo:block>
+
+  <fo:block margin-left="0.25in">
+    <xsl:apply-templates select="listitem"/>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="varlistentry/term">
+  <fo:inline><xsl:apply-templates/>, </fo:inline>
+</xsl:template>
+
+<xsl:template match="varlistentry/term[position()=last()]" priority="2">
+  <fo:inline><xsl:apply-templates/></fo:inline>
+</xsl:template>
+
+<xsl:template match="varlistentry/listitem">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="title" mode="list.title.mode">
+  <xsl:call-template name="formal.object.heading">
+    <xsl:with-param name="object" select=".."/>
+  </xsl:call-template>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="simplelist">
+  <!-- with no type specified, the default is 'vert' -->
+  <fo:table xsl:use-attribute-sets="normal.para.spacing">
+    <xsl:call-template name="simplelist.table.columns">
+      <xsl:with-param name="cols">
+        <xsl:choose>
+          <xsl:when test="@columns">
+            <xsl:value-of select="@columns"/>
+          </xsl:when>
+          <xsl:otherwise>1</xsl:otherwise>
+        </xsl:choose>
+      </xsl:with-param>
+    </xsl:call-template>
+    <fo:table-body>
+      <xsl:call-template name="simplelist.vert">
+        <xsl:with-param name="cols">
+          <xsl:choose>
+            <xsl:when test="@columns">
+              <xsl:value-of select="@columns"/>
+            </xsl:when>
+            <xsl:otherwise>1</xsl:otherwise>
+          </xsl:choose>
+        </xsl:with-param>
+      </xsl:call-template>
+    </fo:table-body>
+  </fo:table>
+</xsl:template>
+
+<xsl:template match="simplelist[@type='inline']">
+  <fo:inline><xsl:apply-templates/></fo:inline>
+</xsl:template>
+
+<xsl:template match="simplelist[@type='horiz']">
+
+  <xsl:variable name="explicit.table.width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'list-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="table.width">
+    <xsl:choose>
+      <xsl:when test="$explicit.table.width != ''">
+        <xsl:value-of select="$explicit.table.width"/>
+      </xsl:when>
+      <xsl:when test="$default.table.width = ''">
+        <xsl:text>100%</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$default.table.width"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <fo:table xsl:use-attribute-sets="normal.para.spacing">
+    <xsl:choose>
+      <xsl:when test="$axf.extensions != 0">
+        <xsl:attribute name="table-layout">auto</xsl:attribute>
+	<xsl:if test="$explicit.table.width != ''">
+          <xsl:attribute name="width"><xsl:value-of 
+	                     select="$explicit.table.width"/></xsl:attribute>
+        </xsl:if>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="table-layout">fixed</xsl:attribute>
+        <xsl:attribute name="width"><xsl:value-of 
+	                              select="$table.width"/></xsl:attribute>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:call-template name="simplelist.table.columns">
+      <xsl:with-param name="cols">
+        <xsl:choose>
+          <xsl:when test="@columns">
+            <xsl:value-of select="@columns"/>
+          </xsl:when>
+          <xsl:otherwise>1</xsl:otherwise>
+        </xsl:choose>
+      </xsl:with-param>
+    </xsl:call-template>
+    <fo:table-body>
+      <xsl:call-template name="simplelist.horiz">
+        <xsl:with-param name="cols">
+          <xsl:choose>
+            <xsl:when test="@columns">
+              <xsl:value-of select="@columns"/>
+            </xsl:when>
+            <xsl:otherwise>1</xsl:otherwise>
+          </xsl:choose>
+        </xsl:with-param>
+      </xsl:call-template>
+    </fo:table-body>
+  </fo:table>
+</xsl:template>
+
+<xsl:template match="simplelist[@type='vert']">
+  <fo:table xsl:use-attribute-sets="normal.para.spacing">
+    <xsl:call-template name="simplelist.table.columns">
+      <xsl:with-param name="cols">
+        <xsl:choose>
+          <xsl:when test="@columns">
+            <xsl:value-of select="@columns"/>
+          </xsl:when>
+          <xsl:otherwise>1</xsl:otherwise>
+        </xsl:choose>
+      </xsl:with-param>
+    </xsl:call-template>
+    <fo:table-body>
+      <xsl:call-template name="simplelist.vert">
+        <xsl:with-param name="cols">
+          <xsl:choose>
+            <xsl:when test="@columns">
+              <xsl:value-of select="@columns"/>
+            </xsl:when>
+            <xsl:otherwise>1</xsl:otherwise>
+          </xsl:choose>
+        </xsl:with-param>
+      </xsl:call-template>
+    </fo:table-body>
+  </fo:table>
+</xsl:template>
+
+<xsl:template name="simplelist.table.columns">
+  <xsl:param name="cols" select="1"/>
+  <xsl:param name="curcol" select="1"/>
+  <fo:table-column column-number="{$curcol}"
+                   column-width="proportional-column-width(1)"/>
+  <xsl:if test="$curcol &lt; $cols">
+    <xsl:call-template name="simplelist.table.columns">
+      <xsl:with-param name="cols" select="$cols"/>
+      <xsl:with-param name="curcol" select="$curcol + 1"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="simplelist.horiz">
+  <xsl:param name="cols">1</xsl:param>
+  <xsl:param name="cell">1</xsl:param>
+  <xsl:param name="members" select="./member"/>
+
+  <xsl:if test="$cell &lt;= count($members)">
+    <fo:table-row>
+      <xsl:call-template name="simplelist.horiz.row">
+        <xsl:with-param name="cols" select="$cols"/>
+        <xsl:with-param name="cell" select="$cell"/>
+        <xsl:with-param name="members" select="$members"/>
+      </xsl:call-template>
+   </fo:table-row>
+    <xsl:call-template name="simplelist.horiz">
+      <xsl:with-param name="cols" select="$cols"/>
+      <xsl:with-param name="cell" select="$cell + $cols"/>
+      <xsl:with-param name="members" select="$members"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="simplelist.horiz.row">
+  <xsl:param name="cols">1</xsl:param>
+  <xsl:param name="cell">1</xsl:param>
+  <xsl:param name="members" select="./member"/>
+  <xsl:param name="curcol">1</xsl:param>
+
+  <xsl:if test="$curcol &lt;= $cols">
+    <fo:table-cell>
+      <fo:block>
+        <xsl:if test="$members[position()=$cell]">
+          <xsl:apply-templates select="$members[position()=$cell]"/>
+        </xsl:if>
+      </fo:block>
+    </fo:table-cell>
+    <xsl:call-template name="simplelist.horiz.row">
+      <xsl:with-param name="cols" select="$cols"/>
+      <xsl:with-param name="cell" select="$cell+1"/>
+      <xsl:with-param name="members" select="$members"/>
+      <xsl:with-param name="curcol" select="$curcol+1"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="simplelist.vert">
+  <xsl:param name="cols">1</xsl:param>
+  <xsl:param name="cell">1</xsl:param>
+  <xsl:param name="members" select="./member"/>
+  <xsl:param name="rows"
+             select="floor((count($members)+$cols - 1) div $cols)"/>
+
+  <xsl:if test="$cell &lt;= $rows">
+    <fo:table-row>
+      <xsl:call-template name="simplelist.vert.row">
+        <xsl:with-param name="cols" select="$cols"/>
+        <xsl:with-param name="rows" select="$rows"/>
+        <xsl:with-param name="cell" select="$cell"/>
+        <xsl:with-param name="members" select="$members"/>
+      </xsl:call-template>
+   </fo:table-row>
+    <xsl:call-template name="simplelist.vert">
+      <xsl:with-param name="cols" select="$cols"/>
+      <xsl:with-param name="cell" select="$cell+1"/>
+      <xsl:with-param name="members" select="$members"/>
+      <xsl:with-param name="rows" select="$rows"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="simplelist.vert.row">
+  <xsl:param name="cols">1</xsl:param>
+  <xsl:param name="rows">1</xsl:param>
+  <xsl:param name="cell">1</xsl:param>
+  <xsl:param name="members" select="./member"/>
+  <xsl:param name="curcol">1</xsl:param>
+
+  <xsl:if test="$curcol &lt;= $cols">
+    <fo:table-cell>
+      <fo:block>
+        <xsl:if test="$members[position()=$cell]">
+          <xsl:apply-templates select="$members[position()=$cell]"/>
+        </xsl:if>
+      </fo:block>
+    </fo:table-cell>
+    <xsl:call-template name="simplelist.vert.row">
+      <xsl:with-param name="cols" select="$cols"/>
+      <xsl:with-param name="rows" select="$rows"/>
+      <xsl:with-param name="cell" select="$cell+$rows"/>
+      <xsl:with-param name="members" select="$members"/>
+      <xsl:with-param name="curcol" select="$curcol+1"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="member">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="simplelist[@type='inline']/member">
+  <xsl:apply-templates/>
+  <xsl:text>, </xsl:text>
+</xsl:template>
+
+<xsl:template match="simplelist[@type='inline']/member[position()=last()]"
+              priority="2">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="procedure">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <!-- Preserve order of PIs and comments -->
+  <xsl:variable name="preamble"
+        select="*[not(self::step
+                  or self::title
+                  or self::titleabbrev)]
+                |comment()[not(preceding-sibling::step)]
+                |processing-instruction()[not(preceding-sibling::step)]"/>
+
+  <xsl:variable name="steps" 
+                select="step
+                        |comment()[preceding-sibling::step]
+                        |processing-instruction()[preceding-sibling::step]"/>
+
+  <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
+    <xsl:if test="./title and $placement = 'before'">
+      <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
+      <!-- heading even though we called formal.object.heading. odd but true. -->
+      <xsl:call-template name="formal.object.heading"/>
+    </xsl:if>
+
+    <xsl:apply-templates select="$preamble"/>
+
+    <fo:list-block xsl:use-attribute-sets="list.block.spacing"
+                   provisional-distance-between-starts="2em"
+                   provisional-label-separation="0.2em">
+      <xsl:apply-templates select="$steps"/>
+    </fo:list-block>
+
+    <xsl:if test="./title and $placement != 'before'">
+      <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
+      <!-- heading even though we called formal.object.heading. odd but true. -->
+      <xsl:call-template name="formal.object.heading"/>
+    </xsl:if>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="procedure/title">
+</xsl:template>
+
+<xsl:template match="substeps">
+  <fo:list-block xsl:use-attribute-sets="list.block.spacing"
+                 provisional-distance-between-starts="2em"
+                 provisional-label-separation="0.2em">
+    <xsl:apply-templates/>
+  </fo:list-block>
+</xsl:template>
+
+<xsl:template match="procedure/step|substeps/step">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <fo:list-item xsl:use-attribute-sets="list.item.spacing">
+    <fo:list-item-label end-indent="label-end()">
+      <fo:block id="{$id}">
+        <!-- dwc: fix for one step procedures. Use a bullet if there's no step 2 -->
+        <xsl:choose>
+          <xsl:when test="count(../step) = 1">
+            <xsl:text>&#x2022;</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select="." mode="number">
+              <xsl:with-param name="recursive" select="0"/>
+            </xsl:apply-templates>.
+          </xsl:otherwise>
+        </xsl:choose>
+      </fo:block>
+    </fo:list-item-label>
+    <fo:list-item-body start-indent="body-start()">
+      <fo:block>
+	<xsl:apply-templates/>
+      </fo:block>
+    </fo:list-item-body>
+  </fo:list-item>
+</xsl:template>
+
+<xsl:template match="stepalternatives">
+  <fo:list-block provisional-distance-between-starts="2em"
+		 provisional-label-separation="0.2em">
+    <xsl:apply-templates select="step"/>
+  </fo:list-block>
+</xsl:template>
+
+<xsl:template match="stepalternatives/step">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <fo:list-item xsl:use-attribute-sets="list.item.spacing">
+    <fo:list-item-label end-indent="label-end()">
+      <fo:block id="{$id}">
+	<xsl:text>&#x2022;</xsl:text>
+      </fo:block>
+    </fo:list-item-label>
+    <fo:list-item-body start-indent="body-start()">
+      <fo:block>
+	<xsl:apply-templates/>
+      </fo:block>
+    </fo:list-item-body>
+  </fo:list-item>
+</xsl:template>
+
+<xsl:template match="step/title">
+  <fo:block font-weight="bold"
+            keep-together.within-column="always" 
+            keep-with-next.within-column="always">
+    <xsl:apply-templates/>
+  </fo:block>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="segmentedlist">
+  <xsl:variable name="presentation">
+    <xsl:call-template name="pi-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'list-presentation'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$presentation = 'table'">
+      <fo:block id="{$id}">
+        <xsl:apply-templates select="." mode="seglist-table"/>
+      </fo:block>
+    </xsl:when>
+    <xsl:when test="$presentation = 'list'">
+      <fo:block id="{$id}">
+        <xsl:apply-templates/>
+      </fo:block>
+    </xsl:when>
+    <xsl:when test="$segmentedlist.as.table != 0">
+      <fo:block id="{$id}">
+        <xsl:apply-templates select="." mode="seglist-table"/>
+      </fo:block>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:block id="{$id}">
+        <xsl:apply-templates/>
+      </fo:block>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="segmentedlist/title">
+  <xsl:apply-templates select="." mode="list.title.mode" />
+</xsl:template>
+
+<xsl:template match="segtitle">
+</xsl:template>
+
+<xsl:template match="segtitle" mode="segtitle-in-seg">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="seglistitem">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+  <fo:block id="{$id}">
+    <xsl:apply-templates/>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="seg">
+  <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
+  <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
+  <xsl:variable name="segtitles" select="$seglist/segtitle"/>
+
+  <!--
+     Note: segtitle is only going to be the right thing in a well formed
+     SegmentedList.  If there are too many Segs or too few SegTitles,
+     you'll get something odd...maybe an error
+  -->
+
+  <fo:block>
+    <fo:inline font-weight="bold">
+      <xsl:apply-templates select="$segtitles[$segnum=position()]"
+                           mode="segtitle-in-seg"/>
+      <xsl:text>: </xsl:text>
+    </fo:inline>
+    <xsl:apply-templates/>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="segmentedlist" mode="seglist-table">
+  <xsl:apply-templates select="title" mode="list.title.mode" />
+  <fo:table>
+    <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
+    <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
+    <fo:table-header>
+      <fo:table-row>
+        <xsl:apply-templates select="segtitle" mode="seglist-table"/>
+      </fo:table-row>
+    </fo:table-header>
+    <fo:table-body>
+      <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
+    </fo:table-body>
+  </fo:table>
+</xsl:template>
+
+<xsl:template match="segtitle" mode="seglist-table">
+  <fo:table-cell>
+    <fo:block>
+      <xsl:apply-templates/>
+    </fo:block>
+  </fo:table-cell>
+</xsl:template>
+
+<xsl:template match="seglistitem" mode="seglist-table">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+  <fo:table-row id="{$id}">
+    <xsl:apply-templates mode="seglist-table"/>
+  </fo:table-row>
+</xsl:template>
+
+<xsl:template match="seg" mode="seglist-table">
+  <fo:table-cell>
+    <fo:block>
+      <xsl:apply-templates/>
+    </fo:block>
+  </fo:table-cell>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="calloutlist">
+  <xsl:variable name="id">
+  <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <fo:block id="{$id}">
+    <xsl:if test="title">
+      <xsl:apply-templates select="title" mode="list.title.mode"/>
+    </xsl:if>
+
+    <!-- Preserve order of PIs and comments -->
+    <xsl:apply-templates 
+         select="*[not(self::callout or self::title or self::titleabbrev)]
+                   |comment()[not(preceding-sibling::callout)]
+		   |processing-instruction()[not(preceding-sibling::callout)]"/>
+
+    <fo:list-block space-before.optimum="1em"
+                   space-before.minimum="0.8em"
+                   space-before.maximum="1.2em"
+                   provisional-distance-between-starts="2.2em"
+                   provisional-label-separation="0.2em">
+      <xsl:apply-templates select="callout
+			        |comment()[preceding-sibling::calllout]
+				|processing-instruction()[preceding-sibling::callout]"/>
+    </fo:list-block>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="calloutlist/title">
+</xsl:template>
+
+<xsl:template match="callout">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <fo:list-item id="{$id}">
+    <fo:list-item-label end-indent="label-end()">
+      <fo:block>
+        <xsl:call-template name="callout.arearefs">
+          <xsl:with-param name="arearefs" select="@arearefs"/>
+        </xsl:call-template>
+      </fo:block>
+    </fo:list-item-label>
+    <fo:list-item-body start-indent="body-start()">
+      <fo:block>
+	<xsl:apply-templates/>
+      </fo:block>
+    </fo:list-item-body>
+  </fo:list-item>
+</xsl:template>
+
+<xsl:template name="callout.arearefs">
+  <xsl:param name="arearefs"></xsl:param>
+  <xsl:if test="$arearefs!=''">
+    <xsl:choose>
+      <xsl:when test="substring-before($arearefs,' ')=''">
+        <xsl:call-template name="callout.arearef">
+          <xsl:with-param name="arearef" select="$arearefs"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="callout.arearef">
+          <xsl:with-param name="arearef"
+                          select="substring-before($arearefs,' ')"/>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:call-template name="callout.arearefs">
+      <xsl:with-param name="arearefs"
+                      select="substring-after($arearefs,' ')"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="callout.arearef">
+  <xsl:param name="arearef"></xsl:param>
+  <xsl:variable name="targets" select="key('id',$arearef)"/>
+  <xsl:variable name="target" select="$targets[1]"/>
+
+  <xsl:choose>
+    <xsl:when test="count($target)=0">
+      <xsl:value-of select="$arearef"/>
+      <xsl:text>: ???</xsl:text>
+    </xsl:when>
+    <xsl:when test="local-name($target)='co'">
+      <xsl:apply-templates select="$target" mode="callout-bug"/>
+    </xsl:when>
+    <xsl:when test="local-name($target)='areaset'">
+      <xsl:call-template name="callout-bug">
+        <xsl:with-param name="conum">
+          <xsl:apply-templates select="$target" mode="conumber"/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="local-name($target)='area'">
+      <xsl:choose>
+        <xsl:when test="$target/parent::areaset">
+          <xsl:call-template name="callout-bug">
+            <xsl:with-param name="conum">
+              <xsl:apply-templates select="$target/parent::areaset"
+                                   mode="conumber"/>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="callout-bug">
+            <xsl:with-param name="conum">
+              <xsl:apply-templates select="$target" mode="conumber"/>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:text>???</xsl:text>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+</xsl:stylesheet>
+
diff --git a/doc/guide.bbl b/doc/guide.bbl
new file mode 100644
index 0000000000000000000000000000000000000000..cdfc64ca0ae0ad4776726bef85c5615c06639996
--- /dev/null
+++ b/doc/guide.bbl
@@ -0,0 +1,16 @@
+\ifx\undefined\bysame
+\newcommand{\bysame}{\leavevmode\hbox to\leftmargin{\hrulefill\,\,}}
+\fi
+\begin{thebibliography}{xx}
+
+\harvarditem[Collard and Juillard]{Collard and Juillard}{2001}{COLL/JUIL/01a}
+{ Collard, F. and M.~Juillard}, Accuracy of stochastic perturbation methods:
+  The case of asset pricing models, {\it Journal of Economic Dynamics and
+  Control}, 2001, {\it 25}, 979--999.
+
+\harvarditem[Schmitt-Grohe and Uribe]{Schmitt-Grohe and Uribe}{2002}{SGU/02}
+{ Schmitt-Grohe, S. and M.~Uribe}, {\it Solving Dynamic General Equilibrium
+  Models Using a Second-Order Approximation to the Policy Function}, technical
+  working paper, Rutgers Univsersity 2002.
+
+\end{thebibliography}
diff --git a/doc/guide.blg b/doc/guide.blg
new file mode 100644
index 0000000000000000000000000000000000000000..54ae1ee8a253a7d597bb57b70049f5ab738e83a6
--- /dev/null
+++ b/doc/guide.blg
@@ -0,0 +1,9 @@
+This is BibTeX, Version 0.99cThe top-level auxiliary file: guide.aux
+The style file: Usmad.bst
+Database file #1: michel.bib
+I was expecting a `,' or a `}'---line 248 of file michel.bib
+ : 
+ : journal = "Computational Economics",
+(Error may have been on previous line)
+I'm skipping whatever remains of this entry
+(There was 1 error message)
diff --git a/doc/guide.tex b/doc/guide.tex
new file mode 100644
index 0000000000000000000000000000000000000000..4aa2c09f54bb044cd533db729afdb49e889a3f43
--- /dev/null
+++ b/doc/guide.tex
@@ -0,0 +1,346 @@
+\documentclass[11pt,a4paper]{article}
+\usepackage{bibmad,graphicx,latexsym,amssymb,times}
+\usepackage[cp850]{inputenc}
+
+\begin{document}
+\title{Stochastic simulations with {\sc Dynare}. A practical guide.}
+\author{Fabrice Collard (GREMAQ, University of Toulouse)\\Adapted for Dynare 2.5.2\\ by Michel Juillard (CEPREMAP and University Paris 8)}
+\date{First draft: February 2001\hspace{10mm}This draft: January 2003.}
+\maketitle
+This document describes a model involving both endogenous and exogenous state variable. We first describe the theoretical model, before showing how the perturbation method is implemented in {\sc Dynare} (MATLAB version). 
+
+\section{A theoretical model} 
+We consider an economy that consists of a large number of dynastic households and a large number of firms. Firms are producing a homogeneous final product that can be either consumed or invested by means of capital and labor services. Firms own their capital stock and hire labor supplied by the households. Households own the firms. In each and every period three perfectly competitive markets open --- the markets for consumption goods, labor services, and financial capital in the form of firms' shares. 
+Household preferences are characterized by the lifetime utility function:
+\begin{equation}
+  E_t\sum_{\tau=t}^{\infty}{\beta^\star}^{\tau-t} \left(\log(c_t)-\theta\frac{h_t^{1+\psi}}{1+\psi}\right)
+  \label{eq:ut}
+\end{equation}
+\noindent where $0<\beta^\star<1$ is a constant discount factor, $c_t$ is consumption in period
+$t$, $h_t$ is the fraction of total available time devoted to productive activity in period $t$, $\theta>0$ and $\psi\geqslant 0$. We assume that there exists a central planner that determines hours, consumption and capital accumulation maximizing the household's utility function subject to the following budget constraint 
+\begin{equation}
+  c_t+i_t=y_t
+  \label{eq:bud}
+\end{equation}
+\noindent where $i_t$ is investment and $y_t$ is output. Investment is used to form physical capital, which accumulates in the standard form as:
+\begin{equation}
+k_{t+1}=\exp(b_t) i_t+(1-\delta)k_t \mbox{ with } 0<\delta<1
+\label{eq:acc}
+\end{equation}
+where $\delta$ is the constant physical depreciation rate. $b_t$ is a shock affecting incorporated technological progress, which properties will be defined later.
+
+Output is produced by means of capital and labor services, relying on a constant returns to scale technology represented by the following Cobb--Douglas production function:
+\begin{equation}
+ y_t=\exp(a_t) k_t^\alpha h_t^{1-\alpha} \mbox{ with }0<\alpha<1 \label{eq:prod}
+\end{equation}
+$a_t$ represents a stochastic shock to technology or Solow residual. We assume that the shocks to technology are distributed with zero mean, but display both persistence across time and correlation in the current period.
+Let us consider the joint process $(a_t,b_t)$ defined as
+\begin{equation}
+\left(
+\begin{array}{c}
+a_t\\b_t
+\end{array}
+\right)=
+\left(
+\begin{array}{cc}
+\rho&\tau\\
+\tau&\rho\\ 
+\end{array}
+\right)\left(
+\begin{array}{c}
+a_{t-1}\\b_{t-1}
+\end{array}
+\right)
++\left(
+\begin{array}{c}
+\varepsilon_t\\ \nu_t
+\end{array}
+\right)  \label{eq:process}
+\end{equation}
+where $|\rho+\tau|<1$ and $|\rho-\tau|<1 $ for sake of stationarity and 
+\begin{eqnarray*}
+E(\varepsilon_t)&=& 0,\\
+E(\nu_t)&=& 0,\\
+E(\varepsilon_t\varepsilon_s)&=&\left\{
+\begin{array}{lcl}
+\sigma^2_\varepsilon & \mbox{ if } & t=s \\
+0 & \mbox{ if } & t\neq s \\
+\end{array}\right. \mbox{, }\\ 
+E(\nu_t\nu_s)&=&\left\{
+\begin{array}{lcl}
+\sigma^2_\nu & \mbox{ if } & t=s \\
+0 & \mbox{ if } & t\neq s \\
+\end{array}\right. \mbox{, } \\
+E(\varepsilon_t\nu_s)&=&\left\{
+\begin{array}{lcl}
+\varphi\sigma_\varepsilon\sigma_\nu & \mbox{ if } & t=s \\
+0 & \mbox{ if } & t\neq s \\
+\end{array}\right. \mbox{. } 
+\end{eqnarray*}
+
+ 
+\section{Dynamic Equilibrium}
+The dynamic equilibrium of this economy follows from the first order conditions for optimality: 
+\begin{eqnarray*}
+&&c_t \theta h_t^{1+\psi}=(1-\alpha) y_t \\
+&&\beta E_t\left[\left(\frac{\exp(b_t) c_t}{\exp(b_{t+1})c_{t+1}}\right)\left(\exp(b_{t+1})\alpha \frac{y_{t+1}}{k_{t+1}}+1-\delta\right)\right]=1\\
+&&y_t=\exp(a_t) k_t^\alpha h_t^{1-\alpha} \\
+&&k_{t+1}=\exp(b_t)(y_t-c_t)+(1-\delta)k_t \\
+&&a_t=\rho a_{t-1}+\tau b_{t-1}+\varepsilon_t \\
+&&b_t=\tau a_{t-1}+\rho b_{t-1}+\nu_t 
+\end{eqnarray*}
+\section{The {\sc dynare} code}
+The dynare code is straightforward to write, as the equilibrium is written in the natural way. The whole code is reported at the end of the section. Before that we proceed step by step.
+\paragraph{Preamble}
+The preamble consists of the some declarations to setup the number of periods the model should be simulated, the endogenous and exogenous variables, the parameters and assign values to these parameters. 
+\begin{enumerate}
+\item {\tt periods 20100}; specifies that the model will be simulated over 20100 periods in order to compute the moments of the simulated variables.
+\item {\tt var y, c, k, h, a, b;} specifies the endogenous variables in the model since we have output ({\tt y}), consumption ({\tt c}), capital ({\tt k}), hours ({\tt h}) and the two shocks ({\tt a, b}).
+\item {\tt varexo e, u}; specifies the exogenous variables in the model --- namely the innovations of the shocks, since we have the innovation of the non--incorporated shock ({\tt e}), and the innovation of the incorporated shock ({\tt u}).
+\item {\tt parameters list;} specifies the list of parameters of the model. In the case we are studying:
+
+{\tt parameters beta, alpha, delta, theta, psi, rho, tau}
+
+\begin{tabular}{ll}
+\hline
+\hline
+{\tt beta}  & discount factor                               \\
+{\tt alpha} & capital elasticity in the production function \\
+{\tt delta} & depreciation rate                             \\
+{\tt theta} & disutility of labor parameter                 \\
+{\tt psi}   & labor supply elasticity                       \\
+{\tt rho}   & persistence                                   \\
+{\tt tau}   & cross--persistence                            \\
+\hline
+\hline
+\end{tabular}
+\item Assignment of parameter values. This is done the standard way in MATLAB. For example, we write
+
+\begin{verbatim}
+alpha = 0.36;
+rho   = 0.95;
+tau   = 0.025;
+beta  = 0.99;
+delta = 0.025;
+psi   = 0;
+theta = 2.95;
+\end{verbatim}
+
+
+\item Note that $\varphi$, the conditional correlation of the shocks, is not, strickly speaking, a parameter of the recursive equations and doesn't need to be listed in the {\tt parameters} instruction. It may however be convenient to express it as a parameter in the expression of the variance--covariance matrix of the shocks (see below) and one may simply write:
+
+{\tt phi = 0.1; }
+
+\end{enumerate}
+
+\paragraph{Declaration of the model:}
+This step is done in a straightforward way. It starts with the instruction {\tt model;} and ends with {\tt end;}, in between all equilibrium conditions are written exactly the way we write it ``by hand''. However, there is a simple rule that should be kept in mind when the model is written. Let us consider a variable $x$: 
+\begin{itemize}
+\item If $x$ is decided in period $t$ then we simply write ${\tt x}$. 
+\item When the variable is decided in $t-1$, such as the capital stock in our simple model, we write $x(-1)$. \item Finally, when a variable is decided in the next period, $t+1$, such as consumption in the Euler equation, we write $x(+1)$. 
+\end{itemize}
+Hence the required code to declare our model in {\sc Dynare} will be:
+\begin{verbatim}
+model;
+c*theta*h^(1+psi)=(1-alpha)*y;
+k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))*
+    (exp(b(+1))*alpha*y(+1)+(1-delta)*k));
+y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
+k = exp(b)*(y-c)+(1-delta)*k(-1);
+a = rho*a(-1)+tau*b(-1) + e;
+b = tau*a(-1)+rho*b(-1) + u;
+end;
+\end{verbatim}
+Assume now that we want to take a Taylor series expansion in logs rather than in level, we just rewrite the model as
+\begin{verbatim}
+model;
+exp(c)*theta*exp(h)^(1+psi)=(1-alpha)*exp(y);
+exp(k) = beta*(((exp(b)*exp(c))/(exp(b(+1))*exp(c(+1))))
+         *(exp(b(+1))*alpha*exp(y(+1))+(1-delta)*exp(k)));
+exp(y) = exp(a)*(exp(k(-1))^alpha)*(exp(h)^(1-alpha));
+exp(k) = exp(b)*(exp(y)-exp(c))+(1-delta)*exp(k(-1));
+a = rho*a(-1)+tau*b(-1) + e;
+b = tau*a(-1)+rho*b(-1) + u;
+end;
+\end{verbatim}
+so that the level of consumption is actually given by ${\tt exp(c)}$.
+\paragraph{Solving the model}
+\begin{enumerate} 
+\item Now we need to provide numerical initial conditions for the computation of the deterministic steady state. This is done with the sequence between {\tt initval;} and {\tt end;}. Each variable, endogenous or exogenous, should be initialized. In our example, we give the exact values of the deterministic equilibrium in absence of shocks. This takes the form
+\begin{verbatim}
+initval;
+y = 1.08068253095672;
+c = 0.80359242014163;
+h = 0.29175631001732;
+k = 11.08360443260358;
+a = 0;
+b = 0;
+e = 0;
+u = 0;
+end;
+\end{verbatim}
+
+Alternatively, we could provide only approximated values. {\sc Dynare} would then automatically compute the exact values.
+
+\item We then specify the innovations and their matrix of variance--covariance. This is done using the {\tt Sigma\_e} command. As the matrix is symmetrical, one enters onlys the upper (or lower) triangular part:
+\begin{verbatim}
+Sigma_e = [ 0.000081, (phi*0.009*0.009); ...
+             0.000081];
+\end{verbatim}
+where the variance of both innovations is set to {\tt 0.000081} and the correlation between them is equal to $\varphi$. Note that if an element is computed as an expression, this expression must be put in parenthese. In the {\tt Sigma\_e} command, the shock variables are ordered as in the {\tt varexo} declaration.
+ 
+Alternatively, it is possible to use a {\tt shock;} and {\tt end;} block and declare only the nonzero elements of the covariance matrix:
+\begin{verbatim}
+shocks;
+var e = 0.009^2;
+var u = 0.009^2;
+var e,u =  phi*0.009*0.009;
+end; 
+\end{verbatim}
+Note that in the current version of {\sc Dynare}, it isn't possible to shut down of shock by assigning it a zero variance. To shut down a shock the variable must be removed from the {\tt varexo} and {\tt initval} list, added to the {\tt parameters} list and assigned a value of zero.
+
+\item The model is then solved and simulated using the {\tt stoch\_simul;} command. By default, the coefficients of the approximated decision rules are reported as well as the moments of the simulated variables and impulse response functions for each exogenous shocks are ploted. In addition, the following options are aavailable:
+\begin{itemize}
+\item {\tt DR\_ALG0 = [0,1]}: Specify the algorithm used to compute the quadratic approximation of the decision rules. [0] (default) uses a ``pure'' perturbation method as in \cite{SGU/02}; [1] moves the point around which the Taylor approximation is computed toward the mean of the distribution as in  \cite{COLL/JUIL/01a}.  
+\item AR = Integer
+Order of autocorrelation coefficients to compute and to print (default = 5)
+\item NOCORR
+Doesn't print the correlation matrix (default = PRINT)
+\item DROP = Integer
+Number of points dropped at the beginning of simulation before computing the summary statistics (default = 100)
+\item IRF = Integer
+Number of periods on which to compute the IRFs (default = 40)
+\item NOFUNCTIONS
+Doesn't print the coefficients of the approximated solution
+\item LINEAR
+Indicates that the original model is linear
+\item NOMOMENTS
+Doesn't print moments of the endogenous variables 
+\item ORDER = [1,2]
+Order of Taylor approximation (default = 2)
+\item REPLIC = Integer
+Number of simulated series used to compute the IRFs (default = 1, if order = 1, and 50 otherwise)
+\end{itemize} 
+The simulated trajectories are returned in MATLAB vectors named as the variables (be careful not to use MATLAB reserved names such as INV for your variables \ldots). Note that the specification of the variance--covariance matrix of the shocks is enough to compute a second order approximation of the policy function. In addition, for the simulation and the computation of moments, {\sc Dynare} assumes that the shocks follow a normal distribution.
+
+In our example, we use simply 
+\begin{verbatim}
+stoch_simul;
+\end{verbatim}
+
+If one wants to use the algorithm in \cite{COLL/JUIL/01a} and to drop 200 initial values instead of 100, one would write
+\begin{verbatim}
+simul_stoch(dr_algo=1,drop=200);
+\end{verbatim}
+\end{enumerate}
+
+\clearpage
+
+\begin{center}
+{\sc Dynare code for the model in level}
+\end{center}
+Here is the model file for the model in level. The last instructions are regular MATLAB commands for graphics. It can be found in file {\tt example1.mod}.
+
+\begin{verbatim}
+periods 20100;
+
+var y, c, k, a, h, b;
+varexo e,u;
+
+parameters beta, rho, beta, alpha, delta, theta, psi, tau;
+
+alpha = 0.36;
+rho   = 0.95;
+tau   = 0.025;
+beta  = 0.99;
+delta = 0.025;
+psi   = 0;
+theta = 2.95;
+phi   = 0.1;
+
+model;
+c*theta*h^(1+psi)=(1-alpha)*y;
+k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
+    *(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
+y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
+k = exp(b)*(y-c)+(1-delta)*k(-1);
+a = rho*a(-1)+tau*b(-1) + e;
+b = tau*a(-1)+rho*b(-1) + u;
+end;
+
+initval;
+y = 1.08068253095672;
+c = 0.80359242014163;
+h = 0.29175631001732;
+k = 11.08360443260358;
+a = 0;
+b = 0;
+e = 0;
+u = 0;
+end;
+
+Sigma_e = [ 0.000081, phi*0.009*0.009; 0.000081 ];
+stoch_simul;
+\end{verbatim}
+\newpage
+
+\begin{center}
+{\sc Dynare code for the model in logs}
+\end{center}
+Here is the model file for the model in logs. In this case, {\tt initval} only contains guessed values and {\tt steady} is used to compute and display the exact value of the deterministic equilibrium. The shocks are supposed to be uncorrelated. Also, Collard \& Juillard (2001) algorithm is used. The model file can be found in {\tt example2.mod}.
+
+\begin{verbatim}
+periods 20100;
+
+var y, c, k, a, h, b;
+varexo e,u;
+
+parameters beta, rho, beta, alpha, delta, theta, psi, tau;
+
+alpha = 0.36;
+rho   = 0.95;
+tau   = 0.025;
+beta  = 0.99;
+delta = 0.025;
+psi   = 0;
+theta = 2.95;
+
+model;
+exp(c)*theta*exp(h)^(1+psi)=(1-alpha)*exp(y);
+exp(k) = beta*(((exp(b)*exp(c))/(exp(b(+1))*exp(c(+1))))
+         *(exp(b(+1))*alpha*exp(y(+1))+(1-delta)*exp(k)));
+exp(y) = exp(a)*(exp(k(-1))^alpha)*(exp(h)^(1-alpha));
+exp(k) = exp(b)*(exp(y)-exp(c))+(1-delta)*exp(k(-1));
+a = rho*a(-1)+tau*b(-1) + e;
+b = tau*a(-1)+rho*b(-1) + u;
+end;
+
+initval;
+y = 0.1;
+c = -0.2;
+h = -1.2;
+k =  2.4;
+a = 0;
+b = 0;
+e = 0;
+u = 0;
+end;
+
+steady;
+
+shocks;
+var e = 0.009^2;
+var u = 0.009^2;
+end;
+
+stoch_simul(dr_algo=1,drop=200);
+\end{verbatim}
+\bibliographystyle{Usmad}
+\bibliography{/papers/biblio/michel}
+
+\end{document}
+
+
+
+
+
diff --git a/doc/makefile b/doc/makefile
new file mode 100644
index 0000000000000000000000000000000000000000..f4e9efa3c05cfc79def736c24c99f569025d8e48
--- /dev/null
+++ b/doc/makefile
@@ -0,0 +1,17 @@
+all: guide.pdf manual/index.html #manual.pdf
+
+guide.pdf: guide.tex
+	pdflatex guide
+
+manual/index.html: manual.xml
+	xsltproc -stringparam base.dir ./manual/ dynare_html.xsl manual.xml 
+
+
+manual.pdf: manual.xml
+	xsltproc dynare_fo.xsl manual.xml >manual.fo
+	pdfxmltex manual.fo	
+	pdfxmltex manual.fo	
+
+install: manual.pdf manual/index.html
+	scp manual.pdf pythie.cepremap.cnrs.fr:public_html/mambo/download/manual/
+	scp manual/* pythie.cepremap.cnrs.fr:public_html/mambo/download/manual/
diff --git a/doc/manual.xml b/doc/manual.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5074fe14d8d6996294c4e546772c45b19be90f6b
--- /dev/null
+++ b/doc/manual.xml
@@ -0,0 +1,2919 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<book>
+  <bookinfo>
+    <title>DYNARE MANUAL</title>
+    <subtitle>Version 3.0</subtitle>
+    <titleabbrev>DYNARE</titleabbrev>
+    <author><firstname>Michel</firstname><surname>Juillard</surname>
+<affiliation><orgname>CEPREMAP and University Paris 8</orgname></affiliation>
+<email>michel.juillard@cepremap.cnrs.fr</email>
+<address>
+<street>142 rue du Chevaleret</street>
+<postcode>75013</postcode><city>Paris</city><country>France</country>
+</address>
+</author>
+
+<copyright><year>1996, 2005</year><holder> Michel Juillard</holder>
+
+</copyright>
+<legalnotice>
+<para>
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+</para>
+
+<para>
+Permission is granted to copy and distribute modified versions of
+this manual under the conditions for verbatim copying, provided that
+the entire resulting derived work is distributed under the terms of
+a permission notice identical to this one.
+</para>
+<para>
+Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for
+modified versions.
+</para>
+</legalnotice>
+<indexterm zone="Dynare"><primary>Dynare</primary></indexterm>
+<indexterm zone="var"><primary>var</primary></indexterm>
+<indexterm zone="varexo"><primary>varexo</primary></indexterm>
+<indexterm zone="varexo_det"><primary>varexo_det</primary></indexterm>
+<indexterm zone="parameters"><primary>parameters</primary></indexterm>
+<indexterm zone="model"><primary>model</primary></indexterm>
+<indexterm zone="initval"><primary>initval</primary></indexterm>
+<indexterm zone="endval"><primary>endval</primary></indexterm>
+<indexterm zone="histval"><primary>histval</primary></indexterm>
+<indexterm zone="shocks"><primary>shocks</primary></indexterm>
+<indexterm zone="periods"><primary>periods</primary></indexterm>
+<indexterm zone="simul"><primary>simul</primary></indexterm>
+<indexterm zone="check"><primary>check</primary></indexterm>
+<indexterm zone="stoch_simul"><primary>stoch_simul</primary></indexterm>
+<indexterm zone="estimated_params"><primary>estimated_params</primary></indexterm>
+<indexterm zone="estimated_params_init"><primary>estimated_params_init</primary></indexterm>
+<indexterm zone="estimated_params_bounds"><primary>estimated_params_bounds</primary></indexterm>
+<indexterm zone="varobs"><primary>varobs</primary></indexterm>
+<indexterm zone="observation_trends"><primary>observation_trends</primary></indexterm>
+<indexterm zone="estimation"><primary>estimation</primary></indexterm>
+<indexterm zone="rplot"><primary>rplot</primary></indexterm>
+<indexterm zone="dynasave"><primary>dynasave</primary></indexterm>
+<indexterm zone="dynatype"><primary>dynatype</primary></indexterm>
+<indexterm zone="unit_root_vars"><primary>unit_root_vars</primary></indexterm>
+<indexterm zone="olr"><primary>olr</primary></indexterm>
+<indexterm zone="olr_inst"><primary>olr_inst</primary></indexterm>
+<indexterm zone="optim_weights"><primary>optim_weights</primary></indexterm>
+<indexterm zone="osr"><primary>osr</primary></indexterm>
+<indexterm zone="osr_params"><primary>osr_params</primary></indexterm>
+<indexterm zone="define"><primary>@define</primary></indexterm>
+<indexterm zone="forecast"><primary>forecast</primary></indexterm>
+<indexterm zone="if_elseif_else_end"><primary>@if...@elseif...@else...@end</primary></indexterm>
+  </bookinfo>
+
+<preface><title>Preface</title><para>
+Dynare is a pre-processor and a collection of Matlab, Scilab or Gauss routines which solve, simulate and estimate non-linear
+models with forward looking variables. It is the result of research carried at
+CEPREMAP by several people (see Laffargue, 1990, Boucekkine, 1995, and
+Juillard, 1996, Collard and Juillard 2001a and 2001b).
+</para>
+<para>
+When the framework is deterministic, Dynare can be used for models with the assumption of perfect
+foresight. Typically, the system is supposed to be in a state of
+equilibrium before a period ``1'' when the news of a contemporaneous
+or of a future shock is learned by the agents in the model. The
+purpose of the simulation is to describe the reaction in anticipation of,
+then in reaction to the shock, until the system returns to the old or
+to a new state of equilibrium. In most models, this return to
+equilibrium is only an asymptotic phenomenon, which one must
+approximate by an horizon of simulation far enough in the future.
+Another exercise for which Dynare is well suited is to study the
+transition path to a new equilibrium following a permanent shock.
+</para>
+<para>
+For deterministic simulations, Dynare uses a Newton-type algorithm, first
+proposed by Laffargue (1990), instead of a first order technique like
+the one proposed by Fair and Taylor (1983), and used in earlier generation simulation programs. We believe
+this approach to be in general both faster and more robust. The
+details of the algorithm used in Dynare can be found in Juillard (1996).
+</para>
+<para>
+In a stochastic context, Dynare computes one or several simulations corresponding to a random draw of the shocks. Starting with version 2.3 (not available for Gauss), Dynare uses a second order Taylor approximation of the expectation functions (see Judd, 1996, Collard and Juillard, 2001a, 2001b, and Schmitt-Grohe and Uribe, 2002).
+</para>
+<para>
+Starting with version 3.0, it is possible to use Dynare to estimate model parameters either by maximum likelihood as in Ireland (2004) or using a Bayesian approach as in Rabanal and Rubio-Ramirez (2002), Schorfheide (2000) or Smets and Wouters (2002).
+</para>
+
+<para>
+Currently the development team of Dynare is composed of S. Adjemian, M. Juillard and O. Kamenik. Several parts of Dynare use or have strongly benefited from publicly available programs by F. Collard, L. Ingber, P. Klein, S. Sakata, F. Schorfheide, C. Sims, P. Soederlind and R. Wouters.  
+</para>
+
+<section><title>Changes</title>
+<para>December 30, 2005</para>
+<itemizedlist>
+<listitem><para>added details about parameter transformation in <xref linkend="model"/> and in <xref linkend="estimated_params"/></para></listitem>
+<listitem><para>added conditional compilation commands <xref linkend="define"/> and <xref linkend="if_elseif_else_end"/></para></listitem>
+<listitem><para>enhanced output section of command <xref linkend="estimation"/></para></listitem>
+<listitem><para>added exogenous deterministic shocks in stochastic models. See <xref linkend="varexo_det"/>, <xref linkend="forecast"/>, <xref linkend="shocks"/>, <xref linkend="stoch_simul"/></para></listitem>
+<listitem><para>added a forecast command for calibrated models. See <xref linkend="forecast"/>.</para></listitem>
+</itemizedlist>
+<para>October 14, 2005</para>
+<itemizedlist>
+<listitem><para>added syntax for computing optimal policy. See <xref linkend='olr'/>, <xref linkend='olr_inst'/>, <xref linkend='optim_weights'/>, <xref linkend='osr'/>, <xref linkend='osr_params'/>.</para></listitem>
+<listitem><para>added syntax for estimating correlation between two shocks or two measurment errors in <xref linkend="estimated_params"/>, <xref linkend="estimated_params_bounds"/> and <xref linkend="estimated_params_init"/>
+</para></listitem>
+</itemizedlist>
+<para>July 20, 2005</para>
+<itemizedlist>
+<listitem><para>Expanded description of <xref linkend="unit_root_vars"/> statement</para></listitem>
+<listitem><para>changed the default for nonlinear solver in <xref linkend="steady"/></para></listitem>
+<listitem><para>added a mention of the possibility to write explicitly a steady state function in <xref linkend="steady"/>, <xref linkend="stoch_simul"/>, <xref linkend="estimation"/> and <xref linkend="unit_root_vars"/></para></listitem>
+<listitem><para>added a brief <emphasis>Ouput</emphasis> section in <xref linkend="estimation"/></para></listitem>
+<listitem><para>corrected misleading description of option <command>prefilter</command> in <xref linkend="estimation"/></para></listitem>
+<listitem><para>added variance decomposition among the statistics computed with option <command>moments_varendo</command> in <xref linkend="estimation"/></para></listitem>
+<listitem><para>tex option in <xref linkend="estimation"/> isn't yet implemented</para></listitem>
+</itemizedlist>
+<para>May 3, 2005</para>
+<itemizedlist>
+<listitem><para>added option <command>noprint</command> in <xref linkend="stoch_simul"/></para></listitem>
+<listitem><para>modified option <command>irf</command> in <xref linkend="stoch_simul"/></para></listitem>
+<listitem><para>modified option <command>simul_seed</command> in <xref linkend="stoch_simul"/></para></listitem>
+</itemizedlist>
+<para>March 6, 2005</para>
+<itemizedlist>
+<listitem><para>corrected typos in equations for 1st and 2nd order approximation formulas in <xref linkend="stoch_simul"/>.</para></listitem>
+<listitem><para>temporarily removed description of output variables in <xref linkend="estimation"/> as old content was outdated and the new one isn't ready yet.</para></listitem>
+<listitem><para>added cross-references</para></listitem>
+</itemizedlist>
+</section>
+</preface>
+
+<chapter><title>Introduction</title>
+
+<para>
+In order to give instructions to Dynare, the user has to write a <emphasis>model file</emphasis> whose file name must terminate by ".mod". This file contains the description of the model and the computing tasks required by the user.
+</para>
+<para>
+In practice, the handling of your model file is done in two
+steps: in the first one, the model and the processing instructions
+written by the user in a <emphasis>model file</emphasis> are
+interpreted and the proper Gauss, Matlab or Scilab instructions are generated; in the
+second step, the program actually runs the computations. Both steps
+are triggered by a single keyword: <command>Dynare</command>.
+</para>
+
+<sect1><title>Software requirements</title>
+<para>
+This version of Dynare works only under Windows 98/NT/2000/XP. For a Unix version, please, write me.
+</para>
+<para>
+The Matlab version has been written with Matlab 6.5.1.
+</para>
+<para>
+The Scilab version has been tested with Scilab 3.0.
+</para>
+<para>
+The Gauss version of Dynare has been written with Gauss version 3.2. It most likely doesn't work with previous versions.
+</para>
+</sect1>
+
+<sect1><title>Installation</title>
+<para>
+In case of update from a previous version, it is a good idea to copy
+the old version in a backup directory so as to be able to revert to it
+in case of problems. None of the previous files are usefull anymore, so you are strongly encouraged to remove them from directory <filename>c:\dynare</filename>. The Matlab version of Dynare lets you now easily have different versions of Dynare on your computer.
+</para>
+
+<para>
+After installation, Dynare can be used in any directory on your computer. It is best practive to keep your model files in directories different from the one containing the Dynare toolbox. That way you can upgrade Dynare and discard the previous version without having to worry about your own files.
+</para>
+ 
+<sect2><title>Installing the Matlab version</title>
+<para>
+Starting with version 3.0, by default, Dynare is installed in a directory whose name contains the version number. For example
+<informalexample><programlisting>
+Dynare_v3.0
+</programlisting>
+</informalexample>
+This directory contains several sub-directories, among which <filename>matlab</filename>, <filename>doc</filename> and <filename>examples</filename>.
+</para>
+<para>
+After unpacking the archive, start the Matlab program and use the menu <command>File/Set path</command> to add the path to Dynare <filename>matlab</filename> subdirectory. For example
+<informalexample>
+<programlisting>
+c:\dynare_v3.0\matlab
+</programlisting>
+</informalexample>
+</para>
+</sect2>
+
+
+<sect2><title>Installing the Scilab version</title>
+<para>
+Unpack the zip file in the directory <filename>c:\</filename> (If you want to use another
+directory, see below). The Scilab version in automatically installed in <filename>c:\dynare\scilab</filename>.
+</para>
+<para>
+Then, find the <filename>scilab.star</filename> file, in the top directory of your Scilab distribution. Edit this file and add the following line after similar statements:
+<informalexample>
+<programlisting>
+load('c:/dynare/scilab/lib');
+</programlisting>
+</informalexample>
+</para>
+<para>
+If you installed Dynare for Scilab in a directory different from <filename>c:\dynare\scilab</filename>, change the above instructions accordingly and edit the following line in <filename>Dynare.sci</filename>
+<informalexample>
+<programlisting>
+command = 'c:\dynare\scilab\dynare_s '+fname;
+</programlisting>
+</informalexample>
+Then, restart Scilab and run the command <command>uplib()</command>.
+</para>
+</sect2>
+
+<sect2><title>Installing the Gauss version</title>
+<para>
+Unpack the zip file in the directory <filename>c:\</filename> (If you want to use another
+directory, see below). The Gauss version in automatically installed in <filename>c:\dynare\gauss</filename>.
+</para>
+<para>
+If you had any previous version of Dynare, use the Gauss editor or any text editor to remove all references to it from the library file <filename>user.lcg</filename>.
+</para>
+<para>
+After unpacking the archive, start the Gauss program and type the following:
+<informalexample>
+<programlisting>
+   library pgraph
+   lib user c:\dynare\gauss\dynare.src
+   lib user c:\dynare\gauss\dynare1.src
+   lib user c:\dynare\gauss\dynare2.src
+   lib user c:\dynare\gauss\dynare3.src
+</programlisting>
+</informalexample>
+</para>
+<para>
+If you installed Dynare for Gauss in a directory different from <filename>c:\dynare\gauss</filename>, change the above instructions accordingly and edit the following line in <filename>Dynare.src</filename>
+<informalexample>
+  <programlisting>
+declare string PARSER = "c:\\dynare\\gauss\\dynare_g ";
+  </programlisting>
+</informalexample>
+</para>
+</sect2>
+
+</sect1>
+</chapter>
+
+<chapter><title>Commands</title>
+<para>
+Dynare commands are either single instructions or a block of instructions. Each single instructions or block elements are terminated by <command>;</command>. Block of instructions are terminated by <command>end;</command>.
+</para>
+
+<para>
+Most Dynare commands have arguments and several accept options, indicated in parentheses after the command keyword.
+</para>
+<para>
+In the description of Dynare commands, the following conventions are observed:
+<itemizedlist>
+<listitem><para>optional arguments or options are indicated between square brackets <command>[]</command></para></listitem>
+<listitem><para>repreated arguments are indicated by ellipses <command>...</command></para></listitem>
+<listitem><para><command><replaceable>INTEGER</replaceable></command> indicates an integer number</para></listitem>
+<listitem><para><command><replaceable>DOUBLE</replaceable></command> indicates a double precision number. The following syntaxes are valid: 1.1e3, 1.1E3, 1.1d3, 1.1D3.</para></listitem>
+<listitem><para><command><replaceable>EXPRESSION</replaceable></command> indicates a mathematical expression valid in the underlying language (Matlab, Scilab or Gauss)</para></listitem>
+<listitem><para><command><replaceable>VARIABLE_NAME</replaceable></command> indicates a variable name starting with an alphabetical character and can't contain ()+-*/^=!;:@#. or accentuated characters</para></listitem>
+<listitem><para><command><replaceable>PARAMETER_NAME</replaceable></command> indicates a parameter name starting with an alphabetical charcater and can't contain ()+-*/^=!;:@#. or accentuated characters</para></listitem>
+<listitem><para><command><replaceable>FILENAME</replaceable></command> indicates a file name valid under your operating system (Windows, Linux or Unix)</para></listitem>
+</itemizedlist>
+</para>
+
+<sect1><title>Executing Dynare</title>
+
+<refentry id="Dynare">
+  <refmeta>
+    <refentrytitle>dynare</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>dynare</refname>
+    <refpurpose>executes Dynare</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>dynare</command>
+      <arg choice="plain">
+      <replaceable>FILENAME</replaceable>[.mod]
+      </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<command>dynare</command> executes instruction included in <filename>filename.mod</filename>.
+<filename>filename.mod</filename> is the name of the model file containing the
+model and the processing instructions.
+</para>
+</refsect1>
+
+<refsect1><title>Details</title>
+<para>
+In Matlab, <command>dynare</command> creates three intermediary files:
+<itemizedlist spacing='compact'>
+<listitem><para> <filename>filename.m</filename> with the instructions for the simulations</para></listitem>
+<listitem><para> <filename>filename_ff.m</filename> with the dynamic model equations</para></listitem>
+<listitem><para> <filename>filename_fff.m</filename> with the long run static model equations</para></listitem>
+</itemizedlist>
+</para>
+<para>
+In Scilab, <command>dynare</command> creates three intermediary files:
+<itemizedlist spacing='compact'>
+<listitem><para> <filename>filename.sci</filename> with the instructions for the simulations</para></listitem>
+<listitem><para> <filename>filename_ff.sci</filename> with the dynamic model equations</para></listitem>
+<listitem><para> <filename>filename_fff.sci</filename> with the long run static model equations</para></listitem>
+</itemizedlist>
+</para>
+<para>
+In Gauss, <command>dynare</command> creates an intermediary file <filename>filename.gau</filename> with the instructions for the simulations. The Gauss version still accepts the former <filename>.mdl</filename> extension, but it is now deprecated.
+</para>
+<para>
+These files may be looked at to understand errors reported at the simulation stage.
+</para>
+</refsect1>
+
+<refsect1><title>Output</title>
+<para>
+Depending on the computing tasks requested in the *.mod file, executing command <command>dynare</command> will leave in the workspace variables containing results available for further processing. More details are given under the relevant computing tasks.
+</para>
+
+<para>
+Under Matlab, some results are also saved in a file called <replaceable>FILENAME</replaceable><filename>_results.mat</filename>. Currently, this file contains when available the structures <varname>dr_</varname> and <varname>oo_</varname>.
+</para>
+</refsect1>
+
+<refsect1><title>Examples</title>
+<programlisting>
+dynare ramst
+</programlisting>
+<para>or</para>
+<programlisting>
+dynare ramst.mod
+</programlisting>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>General declarations</title>
+
+<para>General declarations of variables and parameters are made with the following commands:</para>
+<itemizedlist>
+<listitem><para><xref linkend='periods'/> (deprecated)</para></listitem>
+<listitem><para><xref linkend='var'/></para></listitem>
+<listitem><para><xref linkend='varexo'/></para></listitem>
+<listitem><para><xref linkend='varexo_det'/></para></listitem>
+<listitem><para><xref linkend='parameters'/></para></listitem>
+</itemizedlist>
+
+<refentry id="periods">
+  <refmeta>
+    <refentrytitle>periods</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>periods</refname>
+    <refpurpose>specifies the number of simulation periods</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>periods</command> <arg choice="plain">
+      <replaceable>INTEGER</replaceable>;
+      </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+This command is now deprecated (but will still work for older model files). It is not necessary when no simulation is performed and is replaced by an option PERIODS in SIMUL and STOCH_SIMUL.
+</para>
+<para>
+Set the number of periods in the simulation. The periods are numbered from 1 to <replaceable>INTEGER</replaceable>. In perfect foresight simulations, it is assumed that all future events are perfectly known at the beginning of period 1.
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+periods 100;
+</programlisting>
+</refsect1>
+</refentry>
+
+<refentry id="var">
+  <refmeta>
+    <refentrytitle>var</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>var</refname>
+    <refpurpose>declares endogenous variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>var</command>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg>
+	,
+      </arg>
+      <arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+    <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+This required command declares the endogenous variables in the model. The variable names must start with a letter and can't contain the following characters : ()+-*/^=!;:@#. or accentuated characters.
+</para>
+<para>
+In Gauss, setting <varname>_longname = 1</varname> allows the use of more than 8 characters in the variable names and makes a distinction between lower and upper case letters.
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+var c gnp q1 q2;
+</programlisting>
+</refsect1>
+</refentry>
+
+<refentry id="varexo">
+  <refmeta>
+    <refentrytitle>varexo</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>varexo</refname>
+    <refpurpose>declares exogenous variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>varexo</command>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg>
+	,
+      </arg>
+      <arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+    <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+This optional command declares the exogenous variables in the model. See command <xref linkend="var"/> for the syntax of <replaceable>VARIABLE_NAME</replaceable>.
+</para>
+<para>
+Exogenous variables are required if the user wants to be able to apply shocks to her model. 
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+varexo m gov;
+</programlisting>
+</refsect1>
+</refentry>
+
+<refentry id="varexo_det">
+  <refmeta>
+    <refentrytitle>varexo_det</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>varexo_det</refname>
+    <refpurpose>declares exogenous deterministic variables in a stochastic  model</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>varexo_det</command>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg>
+	,
+      </arg>
+      <arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+    <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+This optional command declares exogenous deterministic variables in a stochastic model. See command <xref linkend="var"/> for the syntax of <replaceable>VARIABLE_NAME</replaceable>.
+</para>
+<para>It is possible to mix deterministic and stochastic shocks to build models where agents know from the start of the simulation about future exogenous changes. In that case <xref linkend="stoch_simul"/> will compute the rational expectation solution adding future information to the state space (nothing is shown in the output of <xref linkend="stoch_simul"/>) and <xref linkend="forecast"/> will compute a simulation conditional on initial  conditions and future information.
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+varexo m gov;
+varexo_det tau;
+</programlisting>
+</refsect1>
+</refentry>
+
+<refentry id="parameters">
+  <refmeta>
+    <refentrytitle>parameters</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>parameters</refname>
+    <refpurpose>declares parameters</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>parameters</command>
+      <arg choice="plain">
+	<replaceable>PARAMETER_NAME</replaceable>
+      </arg>
+      <arg>
+	,
+      </arg>
+      <arg rep="repeat">
+	<replaceable>PARAMETER_NAME</replaceable>
+      </arg>
+    <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+This optional command declares parameters used in the model, in variable initialization or in shock declarations. The parameters must then be assigned values using standard syntax of underlying matrix programming language. Be carefull not to use names reserved by Dynare or the underlying language (Matlab, Scilab or Gauss).
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+parameters alpha, bet;
+
+alpha = 0.3;
+bet = sqrt(2);
+</programlisting>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>Model declaration</title>
+
+<para>The model is declared inside a <xref linkend="model"/> block.</para>
+
+<refentry id="model">
+  <refmeta>
+    <refentrytitle>model</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>model</refname>
+    <refpurpose>declares the model equations</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>model</command>
+      <arg>
+	(linear)
+      </arg>
+      <arg choice="plain">
+      ;
+      </arg><sbr/>
+      <arg choice="plain">
+	<synopfragmentref linkend="pound_exp">MATLAB EXPRESSION</synopfragmentref>;
+      </arg><sbr/>
+      <arg rep="repeat">
+	<synopfragmentref linkend="pound_exp">MATLAB EXPRESSION</synopfragmentref>;
+      </arg><sbr/>
+      <arg choice="plain">
+	end;
+      </arg>
+
+      <arg choice="plain">
+	<synopfragmentref linkend="eq">EQUATION</synopfragmentref>;
+      </arg><sbr/>
+      <arg rep="repeat">
+	<synopfragmentref linkend="eq">EQUATION</synopfragmentref>;
+      </arg><sbr/>
+      <arg choice="plain">
+	end;
+      </arg>
+
+      <synopfragment id="pound_exp">
+	<arg choice="plain">#<replaceable>EXPRESSION</replaceable></arg>
+	<arg>= #<replaceable>EXPRESSION</replaceable></arg>
+	<arg choice="plain">;</arg>
+      </synopfragment>
+
+      <synopfragment id="eq">
+	<arg choice="plain"><replaceable>EXPRESSION</replaceable></arg>
+	<arg>= <replaceable>EXPRESSION</replaceable></arg>
+	<arg choice="plain">;</arg>
+      </synopfragment>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+The equations of the model are written in a block delimited by <command>model;</command> and <command>end;</command>.
+</para>
+<para>
+There must be as many equations as there are endogenous variables in the model, except when used to compute the unconstrained optimal policy with <command>olr</command>. The lead and lag of the variables are written in parenthesis immediately after the variable name. Leads or lags of more than one period are allowed. All the functions available in Matlab, Scilab or Gauss, respectively, are recognized. Each equation must be terminated by a semicolon (;).
+</para>
+<para>
+When the equations are written in homogenous form, it is possible to omit the "= 0" part and write only the left hand side of the equation.
+</para>
+<para>
+It is possible to include arbitrary Matlab expressions in a model. It must be preceeded by a pound sign (#) as the first character of the line. This is particularily usefull to declare tansformation of parameters for estimation purpose (see <xref linkend="estimated_params"/>).
+</para>
+
+<para>
+The option <command>linear</command> declares the model as being linear. It avoids to have to declare initial values for computing the steady state and it sets automatically <command>order=1</command> in <command>stoch_simul</command>.
+</para>
+</refsect1>
+
+<refsect1><title>Example 1</title>
+<programlisting>
+model;
+c =  - k + aa*x*k(-1)^alph + (1-delt)*k(-1);
+c^(-gam) = (aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam)/(1+bet);
+end;
+</programlisting>
+</refsect1>
+
+<refsect1><title>Example 2</title>
+<programlisting>
+model;
+c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
+c^(-gam) - (aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam)/(1+bet);
+end;
+</programlisting>
+</refsect1>
+
+<refsect1><title>Example 3</title>
+<programlisting>
+model(linear);
+# b = 1/c;
+x = a*x(-1)+b*y(+1)+e_x;
+y = d*y(-1)+e_y;
+end;
+</programlisting>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>Initial and terminal conditions</title>
+<para>
+In many contexts, it is necessary to compute the steady state of a non-linear model <xref linkend='initval'/> specifies then numerical initial values for the non-linear solver.
+</para>
+<para>
+Used in perfect foresight mode, the types of forward-loking models for which Dynare was designed require both initial and terminal conditions. Most often these initial and terminal conditions are static equilibria, but not necessarily. 
+</para>
+<para>
+One typical application is to consider an economy at the equilibrium, trigger a shock in first period, and study the trajectory of return at the initial equilbrium. To do that, one needs <xref linkend='initval'/> and <xref linkend='shocks'/>(see next section). 
+</para>
+<para>
+Another one is to study, how an economy, starting from arbitrary initial conditions converges toward equilibrium. To do that, one needs <xref linkend='initval'/> and <xref linkend='endval'/>; 
+</para>
+<para>
+For models with lags on more than one period, the command <xref linkend='histval'/> permits to specify different historical initial values in different periods. 
+</para>
+<itemizedlist>
+<listitem><para><xref linkend='initval'/></para></listitem>
+<listitem><para><xref linkend='endval'/></para></listitem>
+<listitem><para><xref linkend='histval'/></para></listitem>
+</itemizedlist>
+
+<refentry id="initval">
+  <refmeta>
+    <refentrytitle>initval</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>initval</refname>
+    <refpurpose>specifies numerical starting values for finding the steady state and/or initial values for simulations</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>initval;</command><sbr/>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	</arg><sbr/>
+	<arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	  </arg><sbr/>
+	  <arg choice="plain">
+	    end;
+	  </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<replaceable>EXPRESSION</replaceable> is any valid expression returning a numerical value and can contain already initialized variable names.
+</para>
+<para>
+The <command>initval;</command> ... <command>end;</command> block serves two purposes. It set the initial and, possibly, terminal conditions for the simulation and provides numerical initialization for various computation tasks (<xref linkend='steady'/>, <xref linkend='simul'/>, <xref linkend='stoch_simul'/>).  
+</para>
+<para>
+Theoreticaly, initial conditions are only necessary for lagged variables. However, as <command>initval</command> provides also numerical initialization, it is necessary to provide values for all variables in the model, except if the model is declared as linear.
+</para>
+<para>
+For stochastic models, it isn't necessary to delcare 0 as initial values for exogneous stochastic variables as it is the only possible value.
+</para>
+<para>
+When the <command>initval</command> block is followed by the command <xref linkend='steady'/>, it is not necessary to provide exact initialization values for the endogenous variables. <xref linkend='steady'/> will use the values provided in the <command>initval</command> block as initial guess in the non-linear equation solver and computes exact values for the endogenous variables at the steady state. The steady state is defined by keeping constant the value of the exogenous variables.  
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+initval;
+c = 1.2;
+k = 12;
+x = 1;
+end;
+
+steady;
+</programlisting>
+</refsect1>
+</refentry>
+
+<refentry id="endval">
+  <refmeta>
+    <refentrytitle>endval</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>endval</refname>
+    <refpurpose>specifies terminal values for deterministic simulations</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>endval;</command><sbr/>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	</arg><sbr/>
+	<arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	  </arg><sbr/>
+	  <arg choice="plain">
+	    end;
+	  </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<replaceable>EXPRESSION</replaceable> is any valid expression returning a numerical value and can contain already initialized variable names.
+</para>
+<para>
+The optional <command>endval;</command> ... <command>end;</command> block serves two purposes. It set the terminal conditions for the simulation with the LBJ alogrithm, when those differ from the initial conditions. When it is the case, the <command>endval</command> block also provides the numerical initialization for various computation tasks (<xref linkend='steady'/>, <xref linkend='simul'/>), starting in period 1.  
+</para>
+<para>
+Theoreticaly, terminal conditions are required in the LBJ algorithm only for forward variables. However, as <command>endval</command> provides also numerical initialization, it is necessary to provide values for all variables in the model.
+</para>
+<para>
+When the <command>endval</command> block is followed by the command <xref linkend='steady'/>, it is not necessary to provide exact values for the endogenous variables. <xref linkend='steady'/> will use the values provided in the <command>endval</command> block as initial guess in the non-linear equation solver and computes exact values for the endogenous variables at the steady state. The steady state is defined by keeping constant the value of the exogenous variables.  
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+var c k;
+varexo x;
+...
+initval;
+c = 1.2;
+k = 12;
+x = 1;
+end;
+
+steady;
+
+endval;
+c = 2;
+k = 20;
+x = 2;
+end;
+
+steady;
+</programlisting>
+<para>
+The initial equilibrium is comptuted by <xref linkend='steady'/> for x=1, and the terminal one, for x=2.
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="histval">
+  <refmeta>
+    <refentrytitle>histval</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>histval</refname>
+    <refpurpose>specifies historical values before the start of a simulation</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>histval;</command><sbr/>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable> (<replaceable>INTEGER</replaceable>) = <replaceable>EXPRESSION</replaceable>;
+	</arg><sbr/>
+	<arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable> (<replaceable>INTEGER</replaceable>) = <replaceable>EXPRESSION</replaceable>;
+	  </arg><sbr/>
+	  <arg choice="plain">
+	    end;
+	  </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<replaceable>EXPRESSION</replaceable> is any valid expression returning a numerical value and can contain already initialized variable names.
+</para>
+<para>
+In models with lags on more than one period, the optional <command>histval;</command> ... <command>end;</command> block permits to specify different historical initial values for different periods.
+</para>
+<para>
+By convention in Dynare, period 1 is the first period of the simulation. Going backward in time, the first period before the start of the simulation is period 0, then period -1, and so on.
+</para>
+<para>
+If your lagged variables are linked by identities, be careful to satisfy these identities when you set historical initial values.
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+var x y;
+varexo e;
+
+model;
+x = y(-1)^alpha*y(-2)^(1-alpha)+e;
+...
+end;
+
+initval;
+x = 1;
+y = 1;
+e = 0.5;
+end;
+
+steady;
+
+histval;
+y(0) = 1.1;
+y(-1) = 0.9;
+end;
+</programlisting>
+</refsect1>
+
+</refentry>
+</sect1>
+
+<sect1><title>Shocks on exogenous variables</title>
+<para>
+In a deterministic context, when one wants to study the transition of one equilibrium position to another, it is equivalent to analyze the consequences of a permanent shock and this in done in Dynare through the proper use of <xref linkend='initval'/> and <xref linkend='endval'/>.
+</para>
+<para>
+Another typical experiment is to study the effects of a temporary shock after which the system goes back to the original equilibrium (if the model is stable ...). A temporary shock is a temporary change of value of one or several exogenous variables in the model. Temporary shocks are specified with the command <xref linkend='shocks'/>.
+</para>
+<para>
+In a stochastic framework, the exogenous variables take random values in each period. In Dynare, these random values follow a normal distribution with zero mean, but it belongs to the user to specify the variability of these shocks. The non-zero elements of the matrix of variance-covariance of the shocks can be entered with the <xref linkend='shocks'/> command. Or, the entire matrix can be direclty entered with <xref linkend='Sigma_e'/>. Note that, starting with version 2.5.2, the direct specification of the <emphasis>internal</emphasis> matrix <varname>Sigma_e_</varname>, prone to errors, is discouraged.
+</para>
+<para>
+If the variance of an exogenous variable is set to zero, this variable will appear in the report on policy and transition functions, but isn't used in the computation of moments and of Impulse Response Functions. Setting a variance to zero is an easy way of removing an exogenous shock.
+</para>
+<itemizedlist>
+<listitem><para><xref linkend='shocks'/></para></listitem>
+<listitem><para><xref linkend='Sigma_e'/></para></listitem>
+</itemizedlist>
+
+<refentry id="shocks">
+  <refmeta>
+    <refentrytitle>shocks</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>shocks</refname>
+    <refpurpose>specifies shocks on deterministic or stochastic exogenous variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>shocks</command>
+      <arg>(<arg rep="repeat" choice="plain"><replaceable>OPTION</replaceable>,</arg>);</arg><sbr/>
+      <group choice="plain">
+	<arg choice="plain">
+	  <synopfragmentref linkend="det_shock">DETERMINISTIC SHOCK STATEMENT</synopfragmentref>
+	</arg>
+	<arg choice="plain">
+	  <synopfragmentref linkend="st_shock">STOCHASTIC SHOCK STATEMENT</synopfragmentref>
+	</arg>
+      </group><sbr/>
+      <group rep="repeat">
+	<arg choice="plain">
+	  <synopfragmentref linkend="det_shock">DETERMINISTIC SHOCK STATEMENT</synopfragmentref>
+	</arg>
+	<arg choice="plain">
+	  <synopfragmentref linkend="st_shock">STOCHASTIC SHOCK STATEMENT</synopfragmentref>
+	</arg>
+      </group><sbr/>
+      <arg choice ="plain">end;</arg>
+      <synopfragment id="det_shock">
+	<arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable>;</arg>
+	<arg choice="plain">periods <synopfragmentref linkend="period_st">PERIOD STATEMENT</synopfragmentref>;</arg>
+	<arg choice="plain">values EXPRESSION;</arg>
+      </synopfragment>
+      <synopfragment id="period_st">
+	    <arg choice="plain"><replaceable>INTEGER</replaceable></arg>
+	    <arg>: <replaceable>INTEGER</replaceable></arg>
+	    <arg rep="repeat"><replaceable>INTEGER</replaceable>
+	    <arg>: <replaceable>INTEGER</replaceable></arg>
+	    </arg><arg choice="plain">;</arg>
+      </synopfragment>
+      <synopfragment id="st_shock">
+	<group choice="plain">
+	  <arg choice="plain">
+	    <synopfragmentref linkend="var_st">VARIANCE STATEMENT</synopfragmentref>
+	  </arg>
+	  <arg choice="plain">
+	    <synopfragmentref linkend="covar_st">COVARIANCE STATEMENT</synopfragmentref>
+	  </arg>
+	  <arg choice="plain">
+	    <synopfragmentref linkend="stderr_st">STANDARD ERROR STATEMENT</synopfragmentref>
+	  </arg>
+	</group>
+      </synopfragment>
+      <synopfragment id="var_st">
+	<arg choice="plain">
+	  var <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	</arg>
+      </synopfragment>
+      <synopfragment id="covar_st">
+	<arg choice="plain">
+	  var <replaceable>VARIABLE_NAME</replaceable> , <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	</arg>
+      </synopfragment>
+      <synopfragment id="stderr_st">
+	<arg choice="plain">
+	  var <replaceable>VARIABLE_NAME</replaceable>; stderr <replaceable>EXPRESSION</replaceable>;
+	</arg>
+      </synopfragment>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+<refsect1><title>Options</title>
+<itemizedlist spacing='compact'>
+<listitem>
+  <para><command>shocks_file</command> = FILENAME: reads sequence of deterministic shocks from FILENAME. It can be either a *.m or a *.mat file. The file must create vectors with the same names as the deterministic exogenous variables.</para>
+</listitem>
+</itemizedlist>
+</refsect1>
+
+<refsect1><title>Description</title>
+<refsect2><title>In deterministic context</title>
+<para>
+For deterministic simulations, the <command>shocks</command> block specifies temporary changes in the value of an exogenous variables. For permanent shocks, use an <xref linkend='endval'/> block.
+</para>
+
+<para>
+  When specifying shocks on several periods, the <command>values</command> <replaceable>EXPRESSION</replaceable> must return either a scalar value common to all periods with a shock or a column vector with as many elements as there are periods in the <command>periods</command> statement just before it.
+</para>
+
+<refsect3><title>Example</title> 
+<programlisting>
+shocks;
+var e;
+periods 1;
+values 0.5;
+var u;
+periods 4:5;
+values 0;
+var v;
+periods 4 5 6;
+values 0;
+var u;
+periods 4  5   6;
+values  1 1.1 0.9;
+end;
+</programlisting>
+</refsect3>
+</refsect2>
+
+<refsect2><title>In stochastic context</title>
+<para>
+For stochastic simulations (available only in the Matlab or Scilab versions), the <command>shocks</command> block specifies the non zero elements of the covariance matrix of the shocks.
+</para>
+
+<refsect3><title>Example</title> 
+<programlisting>
+shocks;
+var e = 0.000081;
+var e,u = phi*0.009*0.009;
+var u = 0.000081;
+var v; stderr 0.009;
+end;
+</programlisting>
+</refsect3>
+<refsect3><title>See also</title>
+<para>
+<command>Sigma_e</command>
+</para>
+</refsect3>
+</refsect2>
+
+<refsect2><title>Mixing determininistic and stochastic shocks</title>
+<para>It is possible to mix deterministic and stochastic shocks to build models where agents know from the start of the simulation about future exogenous changes. In that case <xref linkend="stoch_simul"/> will compute the rational expectation solution adding future information to the state space (nothing is shown in the output of <xref linkend="stoch_simul"/>) and <xref linkend="forecast"/> will compute a simulation conditional on initial  conditions and future information.
+</para>
+
+<refsect3><title>Example</title>
+<informalexample>
+  <programlisting>
+varexo_det tau;
+varexo e;
+
+...
+
+shocks;
+var e; stderr 0.01;
+var tau;
+periods 1:9;
+values -0.15;
+end;
+
+stoch_simul(irf=0);
+
+forecast;
+  </programlisting>
+</informalexample>
+</refsect3>
+</refsect2>
+
+</refsect1>
+</refentry>
+
+<refentry id="Sigma_e">
+  <refmeta>
+    <refentrytitle>Sigma_e</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>Sigma_e</refname>
+    <refpurpose>specifies directly the covariance matrix of the stochastic shocks</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>Sigma_e</command>
+      <arg choice="plain">
+	= [<synopfragmentref linkend="matrix_el">MATRIX ELEMENT</synopfragmentref>
+	<arg rep="repeat"><arg>,</arg><synopfragmentref linkend="matrix_el">MATRIX ELEMENT</synopfragmentref></arg>
+	<arg rep="repeat"><arg choice="plain">;</arg><synopfragmentref linkend="matrix_el">MATRIX ELEMENT</synopfragmentref></arg>];
+      </arg>
+
+      <synopfragment id="matrix_el">
+	<group choice="plain">
+	  <arg choice="plain">
+	    <replaceable>INTEGER</replaceable>
+	  </arg>
+	  <arg choice="plain">
+	    <replaceable>DOUBLE</replaceable>
+	  </arg>
+	  <arg choice="plain">
+	    (<replaceable>EXPRESSION</replaceable>)
+	  </arg>
+	</group>
+      </synopfragment>
+    </cmdsynopsis>
+    <para>
+      WARNING: the matrix elements are actually written beween square brackets ([]). Here, the initial [ and final ] don't have the meaning of "optional element" as elsewhere.
+    </para>
+  </refsynopsisdiv>
+
+
+<refsect1><title>Description</title>
+
+<para>
+The matrix of variance-covariance of the shocks can be directly specified as a upper (or lower) triangular matrix. Dynare builds the corresponding symmetrix matrix. Each row of the triangular matrix, except the last one, must be terminated by a semi-colon ';'. For a given element, an <replaceable>EXPRESSION</replaceable> using predefined parameters is allowed but must be placed between parentheses. THE ORDER OF THE COVARIANCES IN THE MATRIX IS THE SAME AS THE ONE USED IN THE VAREXO DECLARATION.
+</para>
+<note>
+<para>In previous versions, it was possible to directly set Dynare's internal covariance matrix <varname>Sigma_e_</varname>. This is still possible for compatibility with older .mod files, but STRONGLY DISCOURAGED as too prone to error. When setting <varname>Sigma_e_</varname> directly, the order of the exogenous shocks is the ALPHABETICAL order of their names.
+</para>
+</note>
+</refsect1>
+
+<refsect1><title>Example</title>
+<programlisting>
+varexo u, e;
+...
+Sigma_e = [ 0.81 (phi*0.9*0.009); 0.000081];
+</programlisting>
+<para>
+where the variance of <varname>u</varname> is 0.81, the variance of <varname>e</varname>, 0.000081, and the correlation between <varname>e</varname> and <varname>u</varname> is <varname>phi</varname>.
+</para>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>Solving and simulating</title>
+<para>
+Dynare has special commands for the computation of the static equilibrium of the model (<xref linkend='steady'/>, of the eigenvalues of the linearized model (<xref linkend='check'/>) for dynamics local analysis, of a deterministic simulation (<xref linkend='simul'/>) and for solving and/or simulating a stochastic model (<xref linkend='stoch_simul'/>).
+</para>
+<itemizedlist>
+<listitem><para><xref linkend='steady'/></para></listitem>
+<listitem><para><xref linkend='check'/></para></listitem>
+<listitem><para><xref linkend='forecast'/></para></listitem>
+<listitem><para><xref linkend='simul'/></para></listitem>
+<listitem><para><xref linkend='stoch_simul'/></para></listitem>
+</itemizedlist>
+
+<refentry id="steady">
+  <refmeta>
+    <refentrytitle>steady</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>steady</refname>
+    <refpurpose>copmutes the steady state of a model</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>steady</command>
+      <arg>
+      (solve_algo = 
+      <group choice="plain">
+	<arg choice="plain">0</arg>
+	<arg choice="plain">1</arg>
+	<arg choice="plain">2</arg>
+      </group>)
+      </arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Options</title>
+<itemizedlist spacing='compact'>
+<listitem><para><command>solve_algo = 0</command>: uses Matlab Optimization Toolbox FSOLVE</para></listitem>
+<listitem><para><command>solve_algo = 1</command>: uses Dynare's own nonlinear equation solver</para></listitem>
+<listitem><para><command>solve_algo = 2</command>: splits the model into recursive blocks and solves each block in turn. (Thanks to Manfred Gilli for showing me Matlab's function DMPERM) (this is the default since Dynare version 3.046).</para>
+</listitem>
+</itemizedlist>
+</refsect1>
+
+<refsect1><title>Description</title>
+
+<para>
+Computes the equilibrium value of the endogenous variables for the value of the exogenous variables specified in the previous <xref linkend='initval'/> or <xref linkend='endval'/> block.
+</para>
+<para>
+<command>steady</command> uses an iterative procedure and takes as initial guess the value of the endogenous variables set in the previous <xref linkend='initval'/> or <xref linkend='endval'/> block.
+</para>
+<para>
+For complicated models, finding good numerical initial values for the endogenous variables is the trickiest part of finding the equilibrium of that model. Often, it is better to start with a smaller model and add new variables one by one.
+</para>
+
+<para>If you know how to compute the steady state for your model, you can provide a Matlab function doing the computation instead of using <command>steady</command>. The function should be called with the name of the <filename>.mod</filename> file followed by <filename>_steadystate</filename>. See <filename>fs2000a_steadystate.m</filename> in <filename>examples/fs2000</filename> directory.
+</para>
+
+</refsect1>
+
+<refsect1><title>Output variables</title>
+<para>
+  The steeady state is available in <varname>ys_</varname>. Endogenous variables are ordered alphabeticaly as in <varname>lgy_</varname>.  
+</para>
+</refsect1>
+
+<refsect1><title>Examples</title>
+<para>
+See <xref linkend='initval'/> and <xref linkend='endval'/>.
+</para>
+</refsect1>
+</refentry>     
+
+<refentry id="check">
+  <refmeta>
+    <refentrytitle>check</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>check</refname>
+    <refpurpose>computes the eigenvalues of the (linearized) model</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>check</command>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+Computes the eigenvalues of the model linearized around the values specified by the last <xref linkend='initval'/>, <xref linkend='endval'/> or <xref linkend='steady'/> statement. Generally, the eigenvalues are only meaningfull if the linearization is done around a steady state of the model. It is a device for local analysis in the neighborhood of this steady state.
+</para>
+<para>
+A necessary condition for the uniqueness of a stable equilibrium in the neighborhood of the steady state is that there are as many eigenvalues larger than one in modulus as there are forward looking variables in the system. An additional rank condition requires that the square submatrix of the right Schur vectors corresponding to the forward looking variables (jumpers) and to the explosive eigenvalues must have full rank.
+</para>
+</refsect1>
+
+<refsect1><title>Output variables</title>
+<para>
+<command>check</command> returns the eigenvalues in the global variable <varname>eigenvalues_</varname>.
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="forecast">
+  <refmeta>
+    <refentrytitle>forecast</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>forecast</refname>
+    <refpurpose>computes a simulation of a stochastic model from a given state</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>forecast</command>
+      <arg>(<arg rep="repeat" choice="plain"><replaceable>OPTION</replaceable>,</arg>)</arg>
+      <arg choice="plain"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg rep="repeat"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Options</title>
+<itemizedlist spacing='compact'>
+<listitem><para><command>periods</command> = INTEGER: number of periods of the forecast (default = 40)</para></listitem>
+<listitem><para><command>conf_sig</command> = DOUBLE: level of significance for confidence interval (default = 0.90)</para></listitem>
+</itemizedlist>
+</refsect1>
+
+<refsect1><title>Description</title>
+<para><command>forecast</command> computes a simulation of a stochastic model from an arbitrary initial point.</para>
+<para>When the model also contains deterministic exogenous shocks, the simulation is computed conditionaly to the agents knowing the future values of the deterministic exogenous variables.</para>
+
+<para><command>forecast</command> must be called after <xref linkend="stoch_simul"/>.</para>
+
+<para> <command>forecast</command> plots the trajectory of endogenous variables. When a list of variable names follows the command, only those variables are ploted. A 90% confidence interval is ploted around the mean trajectory. Use option <command>conf_sig</command> to change the level of the confidence interval.</para>
+</refsect1>
+
+<refsect1><title>Output variables</title>
+<para>The following variables are set in structure <varname>oo_</varname>:
+<itemizedlist spacing="compact">
+<listitem><para><varname>oo_.forecast.Mean.</varname><replaceable>VARIABLE NAME</replaceable>: mean forecast of endogenous variables</para></listitem>
+<listitem><para><varname>oo_.forecast.HPDinf.</varname><replaceable>VARIABLE NAME</replaceable>: lower bound of a confidence interval around the forecast</para></listitem>
+<listitem><para><varname>oo_.forecast.HPDsup.</varname><replaceable>VARIABLE NAME</replaceable>: upper bound of a confidence interval around the forecast</para></listitem>
+<listitem><para><varname>oo_.forecast.Exogenous.</varname><replaceable>VARIABLE NAME</replaceable>: trajectory of the deterministic exogenous variables</para></listitem>
+</itemizedlist>
+</para>
+</refsect1>
+
+
+<refsect1><title>Example</title>
+<informalexample>
+  <programlisting>
+varexo_det tau;
+varexo e;
+
+...
+
+shocks;
+var e; stderr 0.01;
+var tau;
+periods 1:9;
+values -0.15;
+end;
+
+stoch_simul(irf=0);
+
+forecast;
+  </programlisting>
+</informalexample>
+</refsect1>
+</refentry>
+
+<refentry id="simul">
+  <refmeta>
+    <refentrytitle>simul</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>simul</refname>
+    <refpurpose>simulates a deterministic model</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>simul</command>
+      <arg>
+	(periods=<replaceable>INTEGER</replaceable>)
+      </arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1><title>Description</title>
+  <para>
+    Triggers the computation of a deterministic simulation of the model for the number of periods set in the option <command>periods=</command>. <command>simul</command> uses a Newton method to solve simultaneously all the equations for every period (see Juillard, 1996).
+  </para>
+  </refsect1>
+<refsect1><title>Output variables</title>
+<para>
+the simulated variables are available in global matrix <varname>y_</varname>. The variables are arranged row by row, in alphabetical order.
+</para>
+</refsect1>
+</refentry>
+
+
+<refentry id="stoch_simul">
+  <refmeta>
+    <refentrytitle>stoch_simul</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>stoch_simul</refname>
+    <refpurpose>computes the solution and simulates the model</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>stoch_simul</command>
+      <arg>(<arg rep="repeat" choice="plain"><replaceable>OPTION</replaceable>,</arg>)</arg>
+      <arg choice="plain"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg rep="repeat"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Options</title>
+<itemizedlist spacing='compact'>
+<listitem><para><anchor id="ar" xreflabel="ar"/> <command>ar</command> = <replaceable>INTEGER</replaceable>:
+Order of autocorrelation coefficients to compute and to print (default = 5)
+n</para></listitem>
+<listitem><para> <command>dr_algo = 0 | 1</command>: 
+specifies the algorithm used for computing the quadratic approximation of the decision rules:
+<itemizedlist spacing='compact'>
+<listitem><para> 0: uses a <emphasis>pure</emphasis> perturbation approach as in Schmitt-Grohe and Uribe (2002) (default)
+</para></listitem>
+<listitem><para> 1: moves the point around which the Taylor expansion is computed toward the means of the distribution as in Collard and Juillard (2001)
+</para></listitem>
+</itemizedlist>
+</para></listitem>
+<listitem><para> <command>drop</command> = <replaceable>INTEGER</replaceable>:
+number of points dropped at the beginning of simulation before computing the summary statistics (default = 100)
+</para></listitem>
+<listitem><para> <command>hp_filter</command> = <replaceable>INTEGER</replaceable>:
+ uses HP filter with lambda = <replaceable>INTEGER</replaceable> before computing moments (default: no filter)
+</para></listitem>
+<listitem><para> <command>hp_ngrid</command> = <replaceable>INTEGER</replaceable>:
+number of points in the grid for the discreet Inverse Fast Fourier Transform used in the HP filter computation. It may be necessary to increase it for highly autocorrelated processes (default = 512) 
+</para></listitem>
+<listitem><para> <command>irf</command> = <replaceable>INTEGER</replaceable>:
+ number of periods on which to compute the IRFs (default = 40). Setting IRF=0, suppresses the plotting of IRF's. 
+</para></listitem>
+<listitem><para><command>relative_irf</command> requests the computation of normalized IRFs in percentage of the standard error of each shock</para></listitem>
+<listitem><para> <command>linear</command>:
+ indicates that the original model is linear (put it rather in the MODEL command).
+</para></listitem>
+<listitem><para> <command>nocorr</command>: 
+doesn't print the correlation matrix (printing them is the default)
+</para></listitem>
+<listitem><para> <command>nofunctions</command>:
+ doesn't print the coefficients of the approximated solution (printing them is the default)
+</para></listitem>
+<listitem><para> <command>nomoments</command>: 
+doesn't print moments of the endogenous variables (printing them is the default)</para></listitem>
+<listitem><para> <command>noprint</command>: cancel any printing. Usefull for loops.</para></listitem>
+<listitem><para> <command>order</command> = 1 | 2 :
+order of Taylor approximation (default = 2)
+</para></listitem>
+<listitem><para> <command>periods</command> = <replaceable>INTEGER</replaceable>: specifies the number of periods to use in simulations. At order=1, no simulation is necessary to compute theoretical moments and IRFs. A number of periods larger than one triggers automatically option <command>simul</command> (default = 0).
+</para></listitem>
+<listitem><para> <command>qz_criterium</command> = <replaceable>INTEGER</replaceable> | <replaceable>DOUBLE</replaceable>:
+value used to split stable from unstable eigenvalues in reordering the Generalized Schur decomposition used for solving 1st order problems (default 1.000001)
+</para></listitem>
+<listitem><para> <command>replic</command> = <replaceable>INTEGER</replaceable>: number of simulated series used to compute the IRFs (default = 1, if order = 1, and 50 otherwise)
+</para></listitem>
+<listitem><para> <command>simul</command>: 
+computes a stochastic simulation of the model for the number of periods specified in the <command>periods</command> statement. Uses <xref linkend='initval'/> values, possibly recomputed by <xref linkend='steady'/>, as initial values for the simulation. The simulated endogenous variables are made available to the user in a vector for each variable and in the global matrix <varname>y_</varname>. The variables are ordered alphabeticaly in the <varname>y_</varname> matrix (default: no simulation)
+</para></listitem>
+<listitem><para> <command>simul_seed</command> = <replaceable>INTEGER</replaceable>|<replaceable>DOUBLE</replaceable>|<replaceable>(EXPRESSION)</replaceable>:
+ specifies a seed for the random generator so as to obtain the same random sample at each run of the program. Otherwise a different sample is used for each run (default: seed not specified). Note that if you use an EXPRESSION rather than an INTEGER or a DOUBLE, the EXPRESSION must be in parenthesis.
+</para></listitem>
+<listitem><para> all <command>steady</command> options (see <xref linkend='steady'/>)</para></listitem>
+</itemizedlist>
+<para>
+When a list of VARIABLE_NAMEs is specified, results are displayed only for these variables.
+</para>
+</refsect1>
+<refsect1><title>Description</title>
+<para>
+<command>stoch_simul</command> computes a Taylor approximation of the decision and transition functions for the model, impulse response functions and various descriptive statistics (moments, variance decomposition, correlation and autocorrelation coefficients). For correlated shocks, the variance decomposition is computed as in the VAR literature through a Cholesky decomposition of the covariance matrix of the exogenous variables. When the shocks are correlated, the variance decomposition depends upon the order of the variables in the <xref linkend='varexo'/> command.
+</para>
+
+<para>The Taylor approximation is computed around the steady state (except whith option <command>dr_algo=1</command>). If you know how to compute the steady state for your model, you can provide a Matlab function doing the computation instead of using the nonlinear solver. The function should be called with the name of the <filename>.mod</filename> file followed by <filename>_steadystate</filename>. See <filename>fs2000a_steadystate.m</filename> in <filename>examples/fs2000</filename> directory.
+</para>
+
+<para>
+Variance decomposition, correlation, autocorrelation are only displayed for variables with positive variance. Impulse response functions are only ploted for variables with response larger than 1e-10.
+</para>
+<para>
+Currently, the IRF's are only ploted for 12 variables. Select the ones you want to see, if your model contains more than 12 endogenous variables.
+</para>
+<para>Currently, the HP filter is only available when computing theoretical moments, not for for moments of simulated variables.
+</para>
+<para>
+The covariance matrix of the shocks is specified either with the <xref linkend='shocks'/> command or with the <xref linkend='Sigma_e'/> command.
+</para>
+</refsect1>
+
+<refsect1><title>Decision rules</title>
+<para>
+The approximated solution of a model takes the form of a set of decision rules or transition equations expressing the current value of the endogenous variables of the model as function of the previous state of the model and shocks oberved at the beginning of the period.
+</para>
+<refsect2><title>First order approximation</title>
+<blockquote><para>
+y<subscript>t</subscript> = ys + A yh<subscript>t-1</subscript> + B u<subscript>t</subscript>
+</para>
+<para>
+where ys is the steady state value of y and yh<subscript>t</subscript>=y<subscript>t</subscript>-ys.
+</para>
+</blockquote>
+</refsect2>
+<refsect2><title>Second order approximation</title>
+<blockquote><para>
+y<subscript>t</subscript> = ys + 0.5&Delta;<superscript>2</superscript> + A yh<subscript>t-1</subscript> + B u<subscript>t</subscript> + 0.5C(yh<subscript>t-1</subscript>&otimes;yh<subscript>t-1</subscript>) + 0.5D(u<subscript>t</subscript>&otimes;u<subscript>t</subscript>) + E(yh<subscript>t-1</subscript>&otimes;u<subscript>t</subscript>)
+</para>
+<para>
+where ys is the steady state value of y, yh<subscript>t</subscript>=y<subscript>t</subscript>-ys, and &Delta;<superscript>2</superscript> is the shift effect of the variance of future shocks.
+</para>
+</blockquote>
+</refsect2>
+</refsect1>
+
+<refsect1><title>Output variables</title>
+<para>
+<command>stoch_simul</command> sets several fields in global variable <varname>oo_</varname>. The descriptive statistics are theoretical moments when no simulation is requested and otherwise represent the moments of the simulated variables. 
+<itemizedlist>
+<listitem><para>the coefficients of the decision rules are stored in global structure<varname>dr_</varname>. Here is the correspondance with the symbols used in the above description of the decision rules:
+<itemizedlist><title>Decision rule coefficients</title>
+
+<listitem><para><varname>ys</varname>: <varname>dr_.ys</varname>. The vector rows correspond to variables in alphabetical order of the variable names.</para></listitem>
+<listitem><para>&Delta;<superscript>2</superscript>: <varname>dr_.ghs2</varname>. The vector rows correspond to re-ordered variables (see below).</para></listitem>
+<listitem><para><varname>A</varname>: <varname>dr_.ghx</varname>. The matrix rows correspond to re-ordered variables. The matrix columns correspond to state variables (see below).</para></listitem>
+<listitem><para><varname>B</varname>: <varname>dr_.ghu</varname>. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to exogenous variables in alphabetical order.</para></listitem>
+<listitem><para><varname>C</varname>: <varname>dr_.ghxx</varname>. The matrix rows correspond to re-ordered variables. The matrix columns correspond to the Kronecker product of the vector of state variables (see below).</para></listitem>
+<listitem><para><varname>D</varname>: <varname>dr_.ghuu</varname>. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to the Kronecker product of exogenous variables in alphabetical order.</para></listitem>
+<listitem><para><varname>E</varname>: <varname>dr_.ghxu</varname>. The matrix rows correspond to re-ordered variables. The matrix columns correspond to the Kronecker product of the vector of state variables (see below) by the vector of exogenous variables in alphabetical order.</para></listitem>
+</itemizedlist>
+When reordered, the variables are stored in the following order: static variables, purely predetermined variables (variables that appear only at the current and lagged periods in the model), variables that are both predetermined and forward-looking (variables that appear at the current, future and lagged periods in the model), purely forward-looking variables (variables that appear only at the current and future periods in the model). In each category, the variables are arranged alphabetically.</para>
+<para>
+The state variables of the model are purely predetermined variables and variables that are both predetermined and forward-looking. They are ordered in that order. When there are lags on more than one period, the state variables are ordered first according to their lag: first variables from the previous period, then variables from two periods before and so on. Note also that when a variable appears in the model at a lag larger than one period, it is automatically included at all inferior lags.
+</para>
+</listitem>
+<listitem><para>The mean of the endogenous variables is available in the vector <varname>oo_.mean</varname>. The variables are arranged in alphabetical order.
+</para></listitem>
+<listitem><para>The matrix of variance-covariance of the endogenous variables in the matrix <varname>oo_.var</varname>. The variables are arranged in alphabetical order.</para></listitem>
+<listitem><para>The matrix of autocorrelation of the endogenous variables are made available in cell array <varname>oo_.autocorr</varname>. The element number of the matrix in the cell array corresponds to the order of autocorrelation. The option <varname>AR</varname> (default ar=5) specifies the number of autocorrelation matrices available.
+</para></listitem>
+<listitem>
+<para>
+  Simulated variables, when they have been computed, are available in Matlab
+vectors with the same name as the endogenous variables.</para>
+</listitem>
+<listitem>
+<para>
+  Impulse responses, when they have been computed, are available in Matlab vectors witht the following naming convention <replaceable>VARIABLE_NAME</replaceable>_<replaceable>shock name</replaceable>.
+</para>
+<informalexample><para>
+  <varname>gnp_ea</varname> contains the effect on <varname>gnp</varname> of a one standard deviation shock on <varname>ea</varname>.
+</para>
+</informalexample>
+</listitem>
+</itemizedlist>
+</para>
+</refsect1>
+
+<refsect1><title>Example 1</title>
+<programlisting>
+shocks;
+var e;
+stderr 0.0348;
+end;
+
+stoch_simul;
+</programlisting>
+<para>
+performs the simulation of the 2nd order approximation of a model with a single stochastic shock, e, with a standard error of 0.0348.
+</para>
+</refsect1>
+
+<refsect1><title>Example 2</title>
+<programlisting>
+stoch_simul(linear,irf=60) y k;
+</programlisting>
+<para>
+performs the simulation of a linear model and displays impulse response functions on 60 periods for variables <varname>y</varname> and <varname>k</varname>.
+</para>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>Estimation</title>
+<para>
+Provided that you have observations on some endogenous variables, it is possible to use Dynare to estimate some or all parameters. Both maximum likelihood and Bayesian techniques are available.
+</para>
+
+<para>
+Note that in order to avoid stochastic singularity, you must have at least as many shocks or measurement errors in your model as you have observed variables. 
+</para>
+<itemizedlist>
+<listitem><para><xref linkend='varobs'/></para></listitem>
+<listitem><para><xref linkend='observation_trends'/></para></listitem>
+<listitem><para><xref linkend='estimated_params'/></para></listitem>
+<listitem><para><xref linkend='estimated_params_init'/></para></listitem>
+<listitem><para><xref linkend='estimated_params_bounds'/></para></listitem>
+<listitem><para><xref linkend='estimated_params_init'/></para></listitem>
+<listitem><para><xref linkend='estimation'/></para></listitem>
+<listitem><para><xref linkend='unit_root_vars'/></para></listitem>
+</itemizedlist>
+
+<refentry id="varobs">
+  <refmeta>
+    <refentrytitle>varobs</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>varobs</refname>
+    <refpurpose>lists the observed variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>varobs</command>
+      <arg choice="plain" rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg rep="repeat">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<command>varobs</command> lists the name of observed endogenous variables for the estimation procedure. These variables must be available in the data file (see <xref linkend='estimation'/>).
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<para>
+  <informalexample>
+    <programlisting>
+      varobs C y rr;
+    </programlisting>
+  </informalexample>
+</para>
+</refsect1>
+
+</refentry>
+
+<refentry id="observation_trends">
+  <refmeta>
+    <refentrytitle>observation_trends</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>observation_trends</refname>
+    <refpurpose>specifies linear trends for observed variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>observation_trends;</command><sbr/>
+      <arg choice="plain">
+	<replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+	(<replaceable>EXPRESSION</replaceable>);
+      </arg><sbr/>
+      <arg choice="plain">
+	end;
+      </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<command>observation_trends</command> specifies trends for observed variables as functions of model parameters. In most cases, variables shouldn't be centered when <command>observation_trends</command> is used. 
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<para>
+  <informalexample>
+    <programlisting>
+      observation_trends;
+      Y (eta);
+      P (mu/eta);
+      end;
+    </programlisting>
+  </informalexample>
+</para>
+</refsect1>
+
+</refentry>
+
+<refentry id="estimated_params">
+  <refmeta>
+    <refentrytitle>estimated_params</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>estimated_params</refname>
+    <refpurpose>specifies the estimated parameters and their prior</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <para>Syntax I (maximum likelihood estimation)</para>
+    <cmdsynopsis>
+      <command>estimated_params;</command><sbr/>
+      <group choice="req">
+      <arg choice="plain">
+	stderr <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+	corr <replaceable>VARIABLE_NAME_1, VARIABLE_NAME_2</replaceable>
+      </arg>
+      <arg choice="plain">
+	<replaceable>PARAMETER_NAME</replaceable>
+	</arg>
+      </group>
+	<arg choice="plain">
+	  <replaceable>, INITIAL_VALUE</replaceable>
+	</arg>
+	<arg choice="opt">
+	  <replaceable>, LOWER_BOUND</replaceable>
+	</arg>
+	<arg choice="opt">
+	  <replaceable>, UPPER_BOUND</replaceable>
+	</arg>
+	<arg choice="plain">;</arg><sbr/>
+	<arg choice='plain'>...</arg><sbr/>
+	  <arg choice="plain">end;</arg>
+    </cmdsynopsis>
+    <para>Syntax II (Bayesian estimation)</para>
+    <cmdsynopsis>
+      <command>estimated_params;</command><sbr/>
+      <group choice="req">
+      <arg choice="plain">
+	stderr <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+	corr <replaceable>VARIABLE_NAME_1, VARIABLE_NAME_2</replaceable>
+      </arg>
+      <arg choice="plain">
+	<replaceable>PARAMETER_NAME</replaceable>
+	</arg>
+      </group>
+      <arg choice="plain">
+	<replaceable>, PRIOR_SHAPE</replaceable>
+      </arg>
+      <arg choice="plain">
+	<replaceable>, PRIOR_MEAN</replaceable>
+      </arg>
+      <arg choice="plain">
+	<replaceable>, PRIOR_STANDARD_ERROR</replaceable>
+      </arg>
+      <arg choice="opt">
+	  <replaceable>, PRIOR_3RD_PARAMETER</replaceable>
+      </arg>
+      <arg choice="opt">
+	<replaceable>, PRIOR_4TH_PARAMETER</replaceable>
+      </arg>
+      <arg choice="opt">
+	<replaceable>, SCALE_PARAMETER</replaceable>
+      </arg>
+	<arg choice="plain">;</arg>
+	<sbr/>
+	<arg choice="plain">...</arg><sbr/>
+	<arg choice="plain">end;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+  The <command>estimated_params;....end;</command> block lists all parameters to be estimated and specifies bounds and priors as necessary.
+</para>
+</refsect1>
+
+<refsect1><title>Estimated parameter specification</title>
+<para>
+Each line corresponds to an estimated parameter and follows this syntax:
+<itemizedlist spacing='compact'> 
+  <listitem><para><command>stderr</command> is a keyword indicating that the standard error of the exogenous variable, <replaceable>VARIABLE_NAME</replaceable>, or of the observation error associated with endogenous observed variable, <replaceable>VARIABLE_NAME</replaceable>, is to be estimated</para></listitem>
+  <listitem><para><command>corr</command> is a keyword indicating that the correlation between the exogenous variables, <replaceable>VARIABLE_NAME_1</replaceable> and <replaceable>VARIABLE_NAME_2</replaceable>, or the correlation of the observation errors associated with endogenous observed variables, <replaceable>VARIABLE_NAME_1</replaceable> and <replaceable>VARIABLE_NAME_2</replaceable>, is to be estimated</para></listitem>
+  <listitem><para> <replaceable>PARAMETER_NAME</replaceable> is the name of a model parameter to be estimated</para></listitem>
+<listitem><para> <replaceable>INITIAL_VALUE</replaceable> specifies a starting value for maximum likelihood estimation</para></listitem>
+<listitem><para> <replaceable>LOWER_BOUND</replaceable> specifies a lower bound for the parameter value in maximum likelihood estimation</para></listitem>
+<listitem><para> <replaceable>UPPER_BOUND</replaceable> specifies an upper bound for the parameter value in maximum likelihood estimation</para></listitem>
+  <listitem><para> <replaceable>PRIOR_SHAPE</replaceable> is prior density among <command>beta_pdf</command>, <command>gamma_pdf</command>, <command>normal_pdf</command>, <command>inv_gamma_pdf</command>, <command>inv_gamma1_pdf</command>, <command>inv_gamma2_pdf</command>, <command>uniform_pdf</command></para></listitem>
+  <listitem><para> <replaceable>PRIOR_MEAN</replaceable> is the mean of the prior distribution</para></listitem>
+  <listitem><para> <replaceable>PRIOR_STANDARD_ERROR</replaceable> is the standard error of the prior distribution</para></listitem>
+  <listitem><para> <replaceable>PRIOR_3RD_PARAMETER</replaceable> is a third parameter of the prior used for generalized beta distribution, generalized gamma and for the uniform distribution (default 0)</para></listitem>
+  <listitem><para> <replaceable>PRIOR_4TH_PARAMETER</replaceable> is a fourth parameter of the prior used for generalized beta distribution, generalized gamma and for the uniform distribution (default 1)</para></listitem>
+  <listitem><para> <replaceable>SCALE_PARAMETER</replaceable> is the scale parameter to be used for the jump distribution of the Metropolis-Hasting algorithm</para></listitem>
+</itemizedlist>
+
+<note><para> At minimum, one must specify the name of the parameter and an initial guess. That will trigger unconstrained maximum likelihood estimation.
+</para></note>
+
+<note><para> As one uses options more towards the end of the list, all previous options must be filled: if you want to specify <replaceable>jscale</replaceable>, you must specify <replaceable>prior_p3</replaceable> and <replaceable>prior_p4</replaceable>. Use default values, if these parameters don't apply. 
+</para></note>
+</para>
+</refsect1>
+
+<refsect1><title>Parameter transformation</title>
+<para>
+Sometimes, it is desirable to estimate a transformation of a parameter appearing in the model, rather than the parameter itself. It is of course possible to replace the original parameter by a function of the estimated parameter everywhere is the model, but it is often unpractical.
+</para>
+
+<para>
+In such a case, it is possible to declare the parameter to be estimated in the <xref linkend="parameters"/> statement and to define the transformation at the top of the <xref linkend="model"/> section, as a Matlab expression. The first character of the line must be a pound  sign (#).
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<informalexample>
+    <programlisting>
+      parameters bet;
+
+      model;
+      # sig = 1/bet;
+      c = sig*c(+1)*mpk;
+      end;
+
+      estimated_params;
+      bet,normal_pdf,1,0.05;
+      end;
+    </programlisting>
+  </informalexample>
+</refsect1>
+
+
+
+</refentry>
+
+<refentry id="estimated_params_init">
+  <refmeta>
+    <refentrytitle>estimated_params_init</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>estimated_params_init</refname>
+    <refpurpose>specifies initial values for optimization</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>estimated_params_init;</command><sbr/>
+      <group choice="req">
+      <arg choice="plain">
+	stderr <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+	corr <replaceable>VARIABLE_NAME_1, VARIABLE_NAME_2</replaceable>
+      </arg>
+      <arg choice="plain">
+	<replaceable>PARAMETER_NAME</replaceable>
+	</arg>
+      </group>
+	<arg choice="plain">
+	  <replaceable>, INITIAL_VALUE</replaceable>
+	</arg> 
+	<arg choice="plain">;</arg><sbr/>
+	<arg choice='plain'>...</arg><sbr/>
+	  <arg choice="plain">end;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+  The <command>estimated_params_init;....end;</command> block declares numerical initial values for the optimizer when these ones are different from the prior mean
+</para>
+</refsect1>
+
+<refsect1><title>Estimated parameter initial value specification</title>
+<para>
+Each line corresponds to an estimated parameter and follows this syntax:
+<itemizedlist spacing='compact'> 
+  <listitem><para><command>stderr</command> is a keyword indicating that the standard error of the exogenous variable, <replaceable>VARIABLE_NAME</replaceable>, or of the observation error associated with endogenous observed variable, <replaceable>VARIABLE_NAME</replaceable>, is to be estimated</para></listitem>
+  <listitem><para><command>corr</command> is a keyword indicating that the correlation between the exogenous variables, <replaceable>VARIABLE_NAME_1</replaceable> and <replaceable>VARIABLE_NAME_2</replaceable>, or the correlation of the observation errors associated with endogenous observed variables, <replaceable>VARIABLE_NAME_1</replaceable> and <replaceable>VARIABLE_NAME_2</replaceable>, is to be estimated</para></listitem>
+  <listitem><para> <replaceable>PARAMETER_NAME</replaceable> is the name of a model parameter to be estimated</para></listitem>
+<listitem><para> <replaceable>INITIAL_VALUE</replaceable> specifies a starting value for maximum likelihood estimation</para></listitem>
+</itemizedlist>
+</para>
+</refsect1>
+
+</refentry>
+
+<refentry id="estimated_params_bounds">
+  <refmeta>
+    <refentrytitle>estimated_params_bounds</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>estimated_params_bounds</refname>
+    <refpurpose>specifies lower and upper bounds for the estimated parameters</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>estimated_params_bounds;</command><sbr/>
+      <group choice="req">
+      <arg choice="plain">
+	stderr <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+	corr <replaceable>VARIABLE_NAME_1, VARIABLE_NAME_2</replaceable>
+      </arg>
+      <arg choice="plain">
+	<replaceable>PARAMETER_NAME</replaceable>
+	</arg>
+      </group>
+	<arg choice="plain">
+	  <replaceable>, LOWER_BOUND</replaceable>
+	</arg>
+	<arg choice="plain">
+	  <replaceable>, UPPER_BOUND</replaceable>
+	</arg>
+	<arg choice="plain">;</arg><sbr/>
+	<arg choice='plain'>...</arg><sbr/>
+	  <arg choice="plain">end;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+  The <command>estimated_params;....end;</command> block lists all parameter to be estimated and specifies bounds and priors when required.
+</para>
+</refsect1>
+
+<refsect1><title>Estimated parameter specification</title>
+<para>
+Each line corresponds to an estimated parameter and follows this syntax:
+<itemizedlist spacing='compact'> 
+  <listitem><para><command>stderr</command> is a keyword indicating that the standard error of the exogenous variable, <replaceable>VARIABLE_NAME</replaceable>, or of the observation error associated with endogenous observed variable, <replaceable>VARIABLE_NAME</replaceable>, is to be estimated</para></listitem>
+  <listitem><para><command>corr</command> is a keyword indicating that the correlation between the exogenous variables, <replaceable>VARIABLE_NAME_1</replaceable> and <replaceable>VARIABLE_NAME_2</replaceable>, or the correlation of the observation errors associated with endogenous observed variables, <replaceable>VARIABLE_NAME_1</replaceable> and <replaceable>VARIABLE_NAME_2</replaceable>, is to be estimated</para></listitem>
+  <listitem><para> <replaceable>PARAMETER_NAME</replaceable> is the name of a model parameter to be estimated</para></listitem>
+<listitem><para> <replaceable>LOWER_BOUND</replaceable> specifies a lower bound for the parameter value in maximum likelihood estimation</para></listitem>
+<listitem><para> <replaceable>UPPER_BOUND</replaceable> specifies an upper bound for the parameter value in maximum likelihood estimation</para></listitem>
+</itemizedlist>
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="estimation">
+ <refmeta>
+    <refentrytitle>estimation</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>estimation</refname>
+    <refpurpose>computes estimation.</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>estimation</command>
+      <arg>(OPTIONS)</arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>OPTIONS</title>
+<itemizedlist spacing='compact'>
+<listitem><para> <command>datafile</command> =
+	  <replaceable>FILENAME</replaceable>: the datafile (a .m file or a .mat file)</para></listitem>
+<listitem><para><command>nobs</command> = <replaceable>INTEGER</replaceable>: the number of observations to be used (default: all observations in the file)</para>
+<para><command>nobs</command> = ([<replaceable>INTEGER_1</replaceable>:<replaceable>INTEGER_2</replaceable>]): runs a recursive estimation and forecast for samples of size ranging of <varname>INTEGER_1</varname> to <varname>INTEGER_2</varname>. Option <varname>FORECAST</varname> must also be specified.</para> 
+</listitem>
+<listitem><para> <command>first_obs</command> = <replaceable>INTEGER</replaceable>: the number of the first observation to be used (default = 1)</para></listitem>
+<listitem><para> <command>prefilter</command> = 1: the estimation procedure demeans the data (default=0, no prefiltering)</para></listitem>
+<listitem><para> <command>presample</command> = <replaceable>INTEGER</replaceable>: the number of observations to be skipped before evaluating the likelihood (default = 1)</para></listitem>
+<listitem><para> <command>loglinear</command>: computes a log--linear approximation of the model instead of a linear (default) approximation. The data must correspond to the definition of the variables used in the modelx.</para></listitem>
+<listitem><para> <command>nograph</command>: no graphs should be plotted</para></listitem>
+<listitem><para> <command>lik_init</command>: <replaceable>INTEGER</replaceable>: type of initialization of Kalman filter.
+<itemizedlist spacing='compact'>
+  <listitem><para>1 (default): for stationary models, the initial matrix of variance of the error of forecast is set equal to the unconditional variance of the state variables.</para></listitem>
+  <listitem><para>2: for nonstationary models: a wide prior is used with an initial matrix of variance of the error of forecast diagonal with 10 on the diagonal.</para></listitem>
+</itemizedlist>
+</para></listitem>
+<listitem><anchor id="conf_sig" xreflabel="conf_sig"/><para><command>conf_sig</command> = <replaceable>{INTEGER | DOUBLE}</replaceable>: the level for the confidence intervals reported in the results (default = 0.90)</para></listitem>
+<listitem><anchor id="mh_replic" xreflabel="mh_replic"/><para> <command>mh_replic</command> = <replaceable>INTEGER</replaceable>: number of replication for Metropolis Hasting algorithm. For the time being, mh_replic should be larger than 1200 (default = 20000.)</para></listitem>
+<listitem><para> <command>mh_nblocks</command> = <replaceable>INTEGER</replaceable>: number of paralletl chains for Metropolis Hasting algorithm (default = 2).</para></listitem>
+<listitem><para> <command>mh_drop</command> = <replaceable>DOUBLE</replaceable>: the fraction of initially generated parameter vectors to be dropped before using posterior simulations (default = 0.5)</para></listitem>
+<listitem><para> <command>mh_jscale</command> = <replaceable>DOUBLE</replaceable>: the scale to be used for the jumping distribution in MH algorithm. The default value is rarely satisfactory. This option must be tune to obtain, ideally, an accpetation rate of 25% in the Metropolis-Hastings algorithm (default = 0.2).</para></listitem>
+<listitem><para><command>mh_init_scale</command>=<replaceable>DOUBLE</replaceable>: the scale to be used for drawing the initial value of the Metropolis-Hastings chain (default=2*mh_scale).</para>
+</listitem>
+<listitem><para><command>mode_file</command>=<replaceable>FILENAME</replaceable>: name of the file containing previous value for the mode. When computing the mode, Dynare stores the mode (<varname>xparam1</varname>) and the hessian (<varname>hh</varname>) in a file called <filename><replaceable>MODEL NAME</replaceable>_mode</filename>.</para></listitem>
+<listitem><para><command>mode_compute</command>=<replaceable>INTEGER</replaceable>: specifies the optimizer for the mode computation.
+<itemizedlist spacing='compact'>
+  <listitem><para>0: the mode isn't computed. mode_file must be specified</para></listitem>
+  <listitem><para>1: uses Matlab <command>fmincon</command>.</para></listitem>
+  <listitem><para>2: uses Lester Ingber's Adaptive Simulated Annealing.</para></listitem>
+  <listitem><para>3: uses Matlab <command>fminunc</command>.</para></listitem>
+  <listitem><para>4 (default): uses Chris Sim's <command>csminwel</command>.</para></listitem>
+</itemizedlist></para></listitem>
+<listitem><para><command>mode_check</command>: when <command>mode_check</command> is set, Dynare plots the posterior density for values around the computed mode for each estimated parameter in turn. This is helpful to diagnose problems with the optimizer.</para></listitem>
+<listitem><para><command>prior_trunc</command>=<replaceable>DOUBLE</replaceable>: probability of extreme values of the prior density that is ignored when computing bounds for the parameters (default=1e-32).</para></listitem>
+<listitem><anchor id="load_mh_file" xreflabel="load_mh_file"/><para><command>load_mh_file</command>: when <command>load_mh_file</command> is declared, Dynare adds to previous Metropolis-Hastings simulations instead of starting from scratch.</para></listitem>
+<listitem><para><command>optim</command>=(<replaceable>fmincon options</replaceable>): can be used to set options for fmincon, the optimizing function of Matlab Optimizaiton toolbox. Use Matlab syntax for these options</para>
+<para> (default: ('display','iter','LargeScale','off','MaxFunEvals',100000,'TolFun',1e-8,'TolX',1e-6))</para></listitem>
+<listitem>
+  <para>
+    <command>nodiagnostic</command>: doesn't compute the convergence diagnostics for Metropolis (default: diagnostics are computed and displayed).
+  </para>
+</listitem>
+<listitem><para><anchor id="bayesian_irf" xreflabel="bayesian_irf"/><command>bayesian_irf</command> triggers the computation of the posterior distribution of IRFs. The length of the IRFs are controlled by the <command>irf</command> option</para></listitem>
+<listitem><para><anchor id="moments_varendo" xreflabel="moments_varendo"/><command>moments_varendo</command> triggers the computation of the posterior distribution of the theoretical moments of the endogenous variables</para></listitem>
+<listitem><para><anchor id="filtered_vars" xreflabel="filtered_vars"/><command>filtered_vars</command> triggers the computation of the posterior distribution of filtered endogenous variables and shocks</para></listitem>
+<listitem><anchor id="smoother" xreflabel="smoother"/><para><command>smoother</command> triggers the computation of the posterior distribution of smoothered endogenous variables and shocks</para></listitem>
+<listitem><para><anchor id="forecast_opt" xreflabel="forecast"/><command>forecast = </command><replaceable>INTEGER</replaceable> computes the posterior distribution of a forecast on <replaceable>INTEGER</replaceable> periods after the end of the sample used in estimation</para></listitem>
+<listitem><para><command>tex</command> requests the printing of results and graphs in TeX tables and graphics that can be later directly included in Latex files (not yet implemented)</para></listitem>
+<listitem><para>All options for <xref linkend="stoch_simul"/></para></listitem>
+</itemizedlist>
+
+<note><para> If no <command>mh_jscale</command> parameter is used in estimated_params, the procedure uses <command>mh_jscale</command> for all parameters. If <command>mh_jscale</command> option isn't set, the procedure uses 0.2 for all parameters.
+</para></note>
+</refsect1>
+
+<refsect1><title>Results</title>
+<itemizedlist spacing='compact'>
+<listitem><para> results from posterior optimization (also for maximum likelihood)</para></listitem>
+<listitem><para> marginal log density</para></listitem>
+<listitem><para> mean and shortest confidence interval from posterior simulation</para></listitem>
+<listitem><para>Metropolis-Hastings convergence graphs that still need to be documented</para></listitem>
+<listitem><para> graphs with prior, posterior and mode</para></listitem>
+<listitem><para> graphs of smoothed shocks, smoothed observation errors, smoothed and historical variables</para></listitem>
+</itemizedlist>
+</refsect1>
+
+<refsect1><title>Output</title>
+<para>After running <command>estimation</command>, the parameters and the variance matrix of the shocks are set to the mode for maximum likelihood estimation or posterior mode computation without Metropolis iterations.
+</para>
+<para>After <command>estimation</command> with Metropolis iterations (option <command>mh_replic</command> > 0 or option <command>load_mh_file</command> set) the parameters and the variance matrix of the shocks are set to the posterior mean.</para>
+
+<para>Depending on the options, <command>estimation</command> stores results in the following fields of structure <varname>oo_</varname>:
+<table orient="land"><title>Content of <varname>oo_</varname></title><tgroup cols='2'>
+<thead>
+<row><entry>Field 1</entry><entry>Field 2</entry><entry>Field 3</entry><entry>Field 4</entry><entry>Field 5</entry><entry>Required options</entry></row>
+</thead>
+<tbody>
+<row><entry><varname>Forecast</varname></entry><entry>See <xref linkend="ForecastsMoments"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><xref linkend="forecast_opt"/></entry></row>
+<row><entry morerows='1'><varname>MarginalDensity</varname></entry><entry><varname>LaplaceApproximation</varname></entry><entry/><entry></entry><entry></entry><entry>Always provided</entry></row>
+<row><entry><varname>ModifiedHarmonicMean</varname></entry><entry></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+<row><entry><varname>PosteriorFilteredVariables</varname></entry><entry>See <xref linkend="MomentsNames"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="filtered_vars"/></para></entry></row>
+<row><entry><varname>PosteriorIRF</varname></entry><entry><varname>Dsge</varname></entry><entry>See <xref linkend="MomentsNames"/></entry><entry><para>IRF name: name of endogenous variable '_' name of shock</para></entry><entry></entry><entry><xref linkend="bayesian_irf"/></entry></row>
+<row><entry><varname>PosteriorSmoothedObservationErrors</varname></entry><entry>See <xref linkend="MomentsNames"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="smoother"/></para></entry></row>
+<row><entry><varname>PosteriorSmoothedShocks</varname></entry><entry>See <xref linkend="MomentsNames"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="smoother"/></para></entry></row>
+<row><entry><varname>PosteriorSmoothedVariables</varname></entry><entry>See <xref linkend="MomentsNames"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="smoother"/></para></entry></row>
+<row><entry><varname>PosteriorTheoreticalMoments</varname></entry><entry>See <xref linkend="TheoreticalMoments"/></entry><entry>See <xref linkend="EstimatedObjects"/></entry><entry>See <xref linkend="MomentsNames"/></entry><entry><replaceable>Variable name</replaceable></entry><entry><xref linkend="moments_varendo"/></entry></row>
+<row><entry><varname>posterior_density</varname></entry><entry><replaceable>Parameter name</replaceable></entry><entry></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+<row><entry><varname>posterior_hpdinf</varname></entry><entry>See <xref linkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+<row><entry><varname>posterior_hpdsup</varname></entry><entry>See <xref linkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+<row><entry><varname>posterior_mean</varname></entry><entry>See <xref linkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+<row><entry><varname>posterior_mode</varname></entry><entry>See <xref linkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+<row><entry><varname>posterior_std</varname></entry><entry>See <xref linkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xref linkend="mh_replic"/>&gt; 0 or <xref linkend="load_mh_file"/></para></entry></row>
+</tbody>
+</tgroup>
+</table>
+</para>
+
+<para><anchor id="ForecastsMoments" xreflabel="Moments of forecasts"/>
+<table><title>Moments of forecasts</title>
+<tgroup cols='2'>
+<thead>
+<row><entry>Field name</entry><entry>Description</entry></row>
+</thead>
+<tbody>
+<row><entry><varname>HPDinf</varname></entry><entry>Lower bound of a 90% HPD interval<footnote id="see_conf_sig"><para>See option <xref linkend="conf_sig"/> to change the size of the HPD interval</para></footnote> of forecast  due to parameter uncertainty</entry></row> 
+<row><entry><varname>HPDsup</varname></entry><entry>Lower bound of a 90% HPD interval <footnoteref linkend="see_conf_sig"/> due to parameter uncertainty</entry></row> 
+<row><entry><varname>HPDTotalinf</varname></entry><entry>Lower bound of a 90% HPD interval of forecast <footnoteref linkend="see_conf_sig"/> due to parameter uncertainty and future shocks</entry></row> 
+<row><entry><varname>HPDTotalsup</varname></entry><entry>Lower bound of a 90% HPD interval <footnoteref linkend="see_conf_sig"/> due to parameter uncertainty and future shocks</entry></row>
+<row><entry><varname>Mean</varname></entry><entry>Mean of the posterior distribution of forecasts</entry></row> 
+<row><entry><varname>Median</varname></entry><entry>Median of the posterior distribution of forecasts</entry></row>  
+<row><entry><varname>Std</varname></entry> <entry>Standard deviation of the posterior distribution of forecasts</entry></row> 
+</tbody>
+</tgroup>
+</table>
+</para>
+<para><anchor id="MomentsNames" xreflabel="Moments Names"/>
+<table><title>Moments Names</title>
+<tgroup cols='2'>
+<thead>
+<row><entry>Field name</entry><entry>Description</entry></row>
+</thead>
+<tbody>
+<row><entry><varname>HPDinf</varname></entry><entry>Lower bound of a 90% HPD interval<footnote id="see_conf_sig1"><para>See option <xref linkend="conf_sig"/> to change the size of the HPD interval</para></footnote></entry></row> 
+<row><entry><varname>HPDsup</varname></entry><entry>Upper bound of a 90% HPD interval <footnoteref linkend="see_conf_sig1"/> </entry></row> 
+<row><entry><varname>Mean</varname></entry><entry>Mean of the posterior distribution</entry></row> 
+<row><entry><varname>Median</varname></entry><entry>Median of the posterior distribution</entry></row>  
+<row><entry><varname>Std</varname></entry> <entry>Standard deviation of the posterior distribution</entry></row> 
+</tbody>
+</tgroup>
+</table>
+</para>
+<para><anchor id="TheoreticalMoments" xreflabel="Theoretical Moments"/>
+<table><title>Theoretical Moments</title>
+<tgroup cols='2'>
+<thead>
+<row><entry>Field name</entry><entry>Description</entry></row>
+</thead>
+<tbody>
+<row><entry><varname>Autocorrelation</varname></entry><entry>Autocorrelation of endogenous variables<footnote><para>The autocorrlation coefficients are computed for the number of periods specified in option <xref linkend="ar"/>.</para></footnote></entry></row>
+<row><entry><varname>Correlation</varname></entry><entry>Correlation between two endogenous variables</entry></row>
+<row><entry><varname>Decomp</varname></entry><entry>Decomposition of variance<footnote><para>When the shocks are correlated, it is the decomposition of orthogonalized shocks via Cholesky decompostion according to the order of declaration of shocks (see <xref linkend="varexo"/>).</para></footnote> </entry></row>
+<row><entry><varname>Expectation</varname></entry><entry>Expectation of endogenous variables</entry></row>
+<row><entry><varname>Variance</varname></entry><entry>(co-)variance of endogenous variables</entry></row>
+</tbody>
+</tgroup>
+</table>
+</para>
+
+<para><anchor id="EstimatedObjects" xreflabel="Estimated Objects"/>
+<table><title>Estimated objects</title>
+<tgroup cols='2'>
+<thead>
+<row><entry>Field name</entry><entry>Description</entry></row>
+</thead>
+<tbody>
+<row><entry><varname>measurement_errors_corr</varname></entry><entry>Correlation between two measurement errors</entry></row>
+<row><entry><varname>measurement_errors_std</varname></entry><entry>Standard deviation of measurement errors</entry></row>
+<row><entry><varname>parameters</varname></entry><entry>Parameters</entry></row>
+<row><entry><varname>shocks_corr</varname></entry><entry>Correlation between two structural shocks</entry></row>
+<row><entry><varname>shocks_std</varname></entry><entry>Standard deviation of structural shocks</entry></row>
+</tbody>
+</tgroup>
+</table>
+</para>
+
+<refsect2><title>Examples</title>
+<para>
+<informalexample>
+<programlisting>
+oo_.posterior_mode.parameters.alp
+oo_.posterior_mean.shocks_std.ex
+oo_.posterior_hpdsup.measurement_errors_corr.gdp_conso
+</programlisting>
+</informalexample>
+</para>
+</refsect2>
+
+</refsect1>
+
+<refsect1><title>Note on steady state computation</title>
+<para>If you know how to compute the steady state for your model, you can provide a Matlab function doing the computation instead of using <command>steady</command>. The function should be called with the name of the <filename>.mod</filename> file followed by <filename>_steadystate</filename>. See <filename>fs2000a_steadystate.m</filename> in <filename>examples/fs2000</filename> directory.
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="unit_root_vars">
+  <refmeta>
+    <refentrytitle>unit_root_vars</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>unit_root_vars</refname>
+    <refpurpose>declares unit-root variables for estimation</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>unit_root_vars</command>
+      <arg choice="plain">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg rep="repeat">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<command>unit_root_vars</command> is used to declare unit-root variables of a model so that a diffuse prior can be used in the initialization of the Kalman filter for these variables only. For stationary variables, the unconditional covariance matrix of these variables is used for initialization. The algorithm to compute a true diffuse prior is taken from Durbin and Koopman (2001, 2003).
+</para>
+
+<para>When <command>unit_root_vars</command> is used the <command>lik_init</command> option of <xref linkend="estimation"/> has no effect.
+</para>
+
+<para>When there are nonstationary variables in a model, there is no unique deterministic steady state. The user must supply a Matlab function that computes the steady state values of the stationary variables in the model and returns dummy values for the nonstationary ones. The function should be called with the name of the <filename>.mod</filename> file followed by <filename>_steadystate</filename>. See <filename>fs2000a_steadystate.m</filename> in <filename>examples/fs2000</filename> directory.
+</para>
+
+<para>Note that the nonstationary variables in the model must be integrated processes(their first difference or k-difference must be stationary).</para>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>Optimal policy</title>
+<para>Dynare has tools to compute optimal policies for quadratic objectives. You can either solve for optimal policy under commitment with <xref linkend='olr'/> or for optimal simple rule with <xref linkend='osr'/>.
+</para>
+
+<itemizedlist>
+<listitem><para><xref linkend='olr'/></para></listitem>
+<listitem><para><xref linkend='olr_inst'/></para></listitem>
+<listitem><para><xref linkend='optim_weights'/></para></listitem>
+<listitem><para><xref linkend='osr'/></para></listitem>
+<listitem><para><xref linkend='osr_params'/></para></listitem>
+</itemizedlist>
+
+<refentry id="olr">
+  <refmeta>
+    <refentrytitle>olr</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>olr</refname>
+    <refpurpose>computes optimal policy under commitment</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>olr</command>
+      <arg>(<arg rep="repeat" choice="plain"><replaceable>OPTION</replaceable>,</arg>)</arg>
+      <arg choice="plain"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg rep="repeat"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>OPTIONS</title>
+<itemizedlist spacing='compact'>
+<listitem><para><command>olr_beta=VALUE</command> sets the value of the discount factor for the intertemporal optimization problem</para></listitem>
+<listitem><para>All options for <xref linkend="stoch_simul"/></para></listitem>
+</itemizedlist>
+</refsect1>
+
+<refsect1><title>Description</title>
+<para>
+<command>olr</command> computes optimal policies under commitment (Ramsey plans) for linear--quadratic problems of the form
+</para>
+<blockquote><para>
+max<subscript>u</subscript> E<subscript>0</subscript>&Sigma;<subscript>t=0</subscript><superscript>&infin;</superscript>&beta;<superscript>t</superscript>(y<subscript>t</subscript>&prime;W<subscript>11</subscript>y<subscript>t</subscript>+2y<subscript>t</subscript>&prime;W<subscript>12</subscript>u<subscript>t</subscript>+u<subscript>t</subscript>&prime;W<subscript>22</subscript>u<subscript>t</subscript>)
+</para>
+<para>s.t.</para>
+<para>
+  A<subscript>1</subscript>E<subscript>t</subscript>(y<subscript>t+1</subscript>)+A<subscript>2</subscript>y<subscript>t</subscript>+A<subscript>3</subscript>y<subscript>t-1</subscript>+Bu<subscript>t</subscript>+Ce<subscript>t</subscript>=0
+</para>
+</blockquote>
+<para>with</para>
+<itemizedlist>
+<listitem><para>y: endogenous variables</para></listitem>
+<listitem><para>u: policiy instrument</para></listitem>
+<listitem><para>e: exogenous stochastic shocks</para></listitem>
+<listitem><para>&beta;: discount factor</para></listitem>
+</itemizedlist>
+<para>The policy instruments must be listed with <xref linkend='olr_inst'/>.
+</para>
+<para>The quadratic objectives must be listed with <xref linkend='optim_weights'/>.
+</para>
+<para>Multipliers are automatically added to the model. Note, however, that the representation isn't minimal and that, in the solution, some multipliers could be sustituted off.
+</para>
+<para>
+Forward-looking endogenous variables don't need to be present in the dynamics of the economy.
+</para>
+<para>
+Dynare automatically builds the corresponding linear rational expectation model and solves it as with <xref linkend='stoch_simul'/>.
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="olr_inst">
+  <refmeta>
+    <refentrytitle>olr_inst</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>olr_inst</refname>
+    <refpurpose>declares instruments for optimal policy under commitment</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>olr_inst</command>
+      <arg choice="plain"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg rep="repeat"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+
+<refsect1><title>Description</title>
+<para>
+<command>olr_inst</command> declares instruments for optimal policy computed by <xref linkend='olr'/>.
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="optim_weights">
+  <refmeta>
+    <refentrytitle>optim_weights</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>optim_weights</refname>
+    <refpurpose>specifies quadratic objectives for optimal policy problems</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>optim_weights;</command><sbr/>
+	<group choice="plain">
+	  <arg choice="plain">
+	    <synopfragmentref linkend="var_st1">VARIANCE STATEMENT</synopfragmentref>
+	  </arg>
+	  <arg choice="plain">
+	    <synopfragmentref linkend="covar_st1">COVARIANCE STATEMENT</synopfragmentref>
+	  </arg>
+	  <arg choice="plain">
+	    <synopfragmentref linkend="stderr_st1">STANDARD ERROR STATEMENT</synopfragmentref>
+	  </arg>
+	</group>
+      <arg choice ="plain">end;</arg>
+      <synopfragment id="var_st1">
+	<arg choice="plain">
+	  var <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	</arg>
+      </synopfragment>
+      <synopfragment id="covar_st1">
+	<arg choice="plain">
+	  var <replaceable>VARIABLE_NAME</replaceable> , <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
+	</arg>
+      </synopfragment>
+      <synopfragment id="stderr_st1">
+	<arg choice="plain">
+	  var <replaceable>VARIABLE_NAME</replaceable>; stderr <replaceable>EXPRESSION</replaceable>;
+	</arg>
+      </synopfragment>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+<refsect1><title>Description</title>
+<para>
+<command>optim_weights</command> secifies the nonzero elements of the quadratic weight matrices for the objectives in <xref linkend='olr'/> and <xref linkend='osr'/>
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="osr">
+  <refmeta>
+    <refentrytitle>osr</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>osr</refname>
+    <refpurpose>computes optimal simple policy rules</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>osr</command>
+      <arg>(<arg rep="repeat" choice="plain"><replaceable>OPTION</replaceable>,</arg>)</arg>
+      <arg choice="plain"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg rep="repeat"><replaceable>VARIABLE_NAME</replaceable></arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>OPTIONS</title>
+<itemizedlist spacing='compact'>
+<listitem><para>All options for <xref linkend="stoch_simul"/></para></listitem>
+</itemizedlist>
+</refsect1>
+
+<refsect1><title>Description</title>
+<para>
+<command>osr</command> computes optimal simple policy rules for linear--quadratic problems of the form
+</para>
+<blockquote><para>
+max<subscript>&gamma;</subscript> E(y<subscript>t</subscript>&prime;Wy<subscript>t</subscript>)
+</para>
+<para>s.t.</para>
+<para>
+  A<subscript>1</subscript>E<subscript>t</subscript>(y<subscript>t+1</subscript>)+A<subscript>2</subscript>y<subscript>t</subscript>+A<subscript>3</subscript>y<subscript>t-1</subscript>+Ce<subscript>t</subscript>=0
+</para>
+</blockquote>
+<para>with</para>
+<itemizedlist>
+<listitem><para>&gamma;: parameters to be optimized. They must be elements of matrices A<subscript>1</subscript>, A<subscript>2</subscript>, A<subscript>3</subscript>.</para></listitem>
+<listitem><para>y: endogenous variables</para></listitem>
+<listitem><para>e: exogenous stochastic shocks</para></listitem>
+</itemizedlist>
+<para>The parameters to be optimized must be listed with <xref linkend='osr_params'/>.
+</para>
+<para>The quadratic objectives must be listed with <xref linkend='optim_weights'/>.
+</para>
+<para>
+This problem is solved using a numerical optimizer.
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="osr_params">
+  <refmeta>
+    <refentrytitle>osr_params</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>osr_params</refname>
+    <refpurpose>declares the parameters to be optimized for optimal simple rules</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>osr_params</command>
+      <arg choice="plain"><replaceable>PARAMETER_NAME</replaceable></arg>
+      <arg rep="repeat"><replaceable>PARAMETER_NAME</replaceable></arg>
+      <arg choice='plain'>;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+
+<refsect1><title>Description</title>
+<para>
+<command>osr_params</command> declares parameters to be optimized  by <xref linkend='osr'/>.
+</para>
+</refsect1>
+</refentry>
+
+
+</sect1>
+<sect1><title>Displaying and saving results</title>
+<para>
+Dynare has comments to plot the results of a simulation and to save the results.
+</para>
+<itemizedlist>
+<listitem><para><xref linkend='rplot'/></para></listitem>
+<listitem><para><xref linkend='dynatype'/></para></listitem>
+<listitem><para><xref linkend='dynasave'/></para></listitem>
+</itemizedlist>
+
+<refentry id="rplot">
+  <refmeta>
+    <refentrytitle>rplot</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>rplot</refname>
+    <refpurpose>plot variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>rplot</command>
+      <arg choice="plain">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg rep="repeat">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+<refsect1><title>Description</title>
+<para>
+Plots one or several variables
+</para>
+</refsect1>
+</refentry>
+
+<refentry id="dynatype">
+  <refmeta>
+    <refentrytitle>dynatype</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>dynatype</refname>
+    <refpurpose>print simulated variables</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>dynatype</command>
+      <arg>
+      (<replaceable>FILENAME</replaceable>)
+      </arg>
+      <arg choice="plain">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg rep="repeat">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<command>dynatype</command> prints the listed variables in a text file named <replaceable>FILENAME</replaceable>. If no <replaceable>VARIABLE_NAME</replaceable> are listed, all endogenous variables are printed.
+</para>
+</refsect1>
+
+</refentry>
+
+<refentry id="dynasave">
+  <refmeta>
+    <refentrytitle>dynasave</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>dynasave</refname>
+    <refpurpose>save simulated variables in a binary file</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>dynasave</command>
+      <arg>
+      (<replaceable>FILENAME</replaceable>)
+      </arg>
+      <arg choice="plain">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg rep="repeat">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+<refsect1><title>Description</title>
+<para>
+<command>dynasave</command> saves the listed variables in a binary file named <replaceable>FILENAME</replaceable>. If no <replaceable>VARIABLE_NAME</replaceable> are listed, all endogenous variables are saved.
+</para>
+<para>
+In Matlab, variables saved with the <command>dynasave</command> command can be retrieved by the Matlab command <command>load -mat <replaceable>FILENAME</replaceable></command>.
+</para>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1><title>Conditional compilation</title>
+<para>
+Dynare has the following commands to choose which part of the *.mod file is executed. This is useful to maintain several versions of a model in the same *.mod file.
+</para>
+<itemizedlist>
+<listitem><para><xref linkend='define'/></para></listitem>
+<listitem><para><xref linkend='if_elseif_else_end'/></para></listitem>
+</itemizedlist>
+
+<refentry id="define">
+  <refmeta>
+    <refentrytitle>@define</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>@define</refname>
+    <refpurpose>defines a macro</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>@define</command>
+      <arg choice="plain">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+      <replaceable>INTEGER</replaceable>
+      </arg>
+      <arg choice="plain">;</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+<refsect1><title>Description</title>
+<para>
+<command>@define</command> defines a macro with name <replaceable>VARIABLE_NAME</replaceable> and value <replaceable>INTEGER</replaceable>. This macro can be used later in the *.mod file only in <command>@if</command> or <command>@elseif</command> statements. The macros can't be used to replace arbitrary part of codes like in C, for example.
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<para>
+<informalexample>
+<programlisting>
+  @define version 1;
+</programlisting>
+</informalexample>
+</para>
+</refsect1>
+
+</refentry>
+
+<refentry id="if_elseif_else_end">
+  <refmeta>
+    <refentrytitle>@if ... @elseif ... @else ... @end</refentrytitle>
+  </refmeta>
+
+  <refnamediv>
+    <refname>@if ... @elseif ... @else ... @end</refname>
+    <refpurpose>defines conditional compilation of the *.mod file</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>@if</command>
+      <arg choice="plain">
+      <replaceable>VARIABLE_NAME</replaceable>
+      </arg>
+      <arg choice="plain">
+      <replaceable>LOGICAL_OPERATOR</replaceable>
+      </arg>
+      <arg choice="plain">
+      <replaceable>INTEGER</replaceable>
+      </arg>
+      <arg choice="plain">;</arg><sbr/>
+      <arg choice="plain">...</arg><sbr/>
+        
+    </cmdsynopsis>
+  </refsynopsisdiv>
+<refsect1><title>Description</title>
+<para><replaceable>LOGICAL_OPERATOR</replaceable> are
+<itemizedlist>
+<listitem><para>== equal</para></listitem>
+<listitem><para>!= not equal</para></listitem>
+<listitem><para>&lt; lesser than</para></listitem>
+<listitem><para>&gt; greater than</para></listitem>
+<listitem><para>&lt;= lesser or equal than</para></listitem>
+<listitem><para>&gt;= greater or equal than</para></listitem>
+</itemizedlist>
+</para>
+
+<para>
+These commands let the user define which part of the *.mod file should be handled by Dynare
+</para>
+</refsect1>
+
+<refsect1><title>Example</title>
+<para>
+<informalexample>
+<programlisting>
+  @define version 1;
+  parameters alph bet;
+  alph = 0.3;
+  @if version == 1;
+    bet = 0.9;
+  @elseif version == 2;
+    bet = 0.95;
+  @else;
+    bet = 0.98;
+  @end;
+</programlisting>
+</informalexample>
+</para>
+</refsect1>
+
+</refentry>
+
+</sect1>
+</chapter>
+
+<chapter><title>Examples</title>
+<para>
+Fabrice Collard (GREMAQ, University of Toulouse) has written a guide to stochastic simulations with Dynare entitled "Dynare in Practice" which is in <filename>guide.pdf</filename>.
+</para>
+</chapter>
+
+<bibliography>
+<biblioentry>
+  <biblioset relation="article">
+    <author>
+      <surname> Boucekkine</surname>
+      <firstname> Raouf</firstname>
+    </author>
+    <pubdate>1995</pubdate>
+    <title>An alternative methodology for solving nonlinear forward-looking models</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Journal of Economic Dynamics and Control</title>
+    <volumenum>19</volumenum>
+    <pagenums>711-734</pagenums>
+  </biblioset>
+</biblioentry>
+<biblioentry>
+  <biblioset relation="article">
+    <authorgroup>
+      <author>
+	<surname>Collard</surname>
+	<firstname>Fabrice</firstname>
+      </author>
+      <author>
+	<surname>Juillard</surname>
+	<firstname>Michel</firstname>
+      </author>
+    </authorgroup>
+    <pubdate>2001</pubdate>
+    <title>Accuracy of stochastic perturbation methods: The case of asset pricing models</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Journal of Economic Dynamics and Control</title>
+    <volumenum>25</volumenum>
+    <pagenums>979-999</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry> 
+  <biblioset relation="article">
+    <authorgroup>
+      <author>
+	<surname>Collard</surname>
+	<firstname>Fabrice</firstname>
+      </author>
+      <author>
+	<surname>Juillard</surname>
+	<firstname>Michel</firstname>
+      </author>
+    </authorgroup>
+    <pubdate>2001</pubdate>
+    <title>A Higher-Order Taylor Expansion Approach to Simulation of Stochastic Forward-Looking Models with an Application to a Non-Linear Phillips Curve</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Computational Economics</title>
+    <volumenum>17</volumenum>
+    <pagenums>125-139</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry>
+  <biblioset relation="book">
+    <authorgroup>
+      <author>
+	<surname>Durbin</surname>
+	<firstname>J.</firstname>
+      </author>
+      <author>
+	<surname>Koopman</surname>
+	<firstname>S.J.</firstname>
+      </author>
+    </authorgroup>
+    <pubdate>2001</pubdate>
+    <title>Time Series Analysis by State Space Methods</title>
+    <publishername>Oxford University Press</publishername>
+  </biblioset>
+</biblioentry>
+
+<biblioentry>
+  <biblioset relation="article">
+    <authorgroup>
+      <author>
+	<surname>Fair</surname>
+	<firstname>Ray</firstname>
+      </author>
+      <author>
+	<surname>Taylor</surname>
+	<firstname>John</firstname>
+      </author>
+    </authorgroup>
+    <pubdate>1983</pubdate>
+    <title>Solution and Maximum Likelihood Estimation of Dynamic Nonlinear Rational Expectation Models</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Econometrica</title>
+    <volumenum>51</volumenum>
+    <pagenums>1169-1185</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry>
+  <biblioset relation="article">
+    <authorgroup>
+      <author>
+	<surname>Fernandez-Villaverde</surname>
+	<firstname>Jesus</firstname>
+      </author>
+      <author>
+	<surname>Rubio-Ramirez</surname>
+	<firstname>Juan</firstname>
+      </author>
+    </authorgroup>
+    <pubdate>2004</pubdate>
+    <title>Comparing Dynamic Equilibrium Economies to Data: A Bayesian Approach</title>
+  </biblioset>
+  <biblioset relation="journal">
+  <title>Journal of Econometrics</title>
+  <volumenum>123</volumenum>
+    <pagenums>153-187</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry>   
+  <biblioset relation="article">
+    <author>
+      <surname>Ireland</surname>
+      <firstname>Peter</firstname>
+    </author>
+    <pubdate>2004</pubdate>
+    <title>A Method for Taking Models to the Data</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Journal of Economic Dynamics and Control</title>
+    <volumenum>28</volumenum>
+    <pagenums>1205-26</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry>  
+  <biblioset relation="article">
+    <author>
+      <surname>Judd</surname>
+      <firstname>Kenneth</firstname>
+    </author>
+    <pubdate>1996</pubdate>    
+    <title>Approximation, Perturbation, and Projection Methods in Economic Analysis</title>
+  </biblioset>
+  <biblioset relation="book">
+    <authorgroup>
+      <author>
+	<surname>Amman</surname>
+	<firstname>Hans</firstname>
+      </author>
+      <author>
+	<surname>Kendrick</surname>
+	<firstname>David</firstname>
+      </author>
+      <author>
+	<surname>Rust</surname>
+	<firstname>John</firstname>
+      </author>
+    </authorgroup>
+    <title>Handbook of Computational Economics</title>
+    <pubdate>1996</pubdate>
+    <publishername>North Holland Press</publishername>
+    <pagenums>511-585</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry> 
+      <author>
+	<surname>Juillard</surname>
+	<firstname>Michel</firstname>
+      </author>
+      <pubdate>1996</pubdate>
+      <title>Dynare: A program for the resolution and simulation of dynamic models with forward variables through the use of a relaxation algorithm</title>
+      <orgname>CEPREMAP</orgname>
+      <citetitle>Couverture Orange</citetitle>
+      <volumenum>9602</volumenum>
+</biblioentry>
+
+<biblioentry>
+  <biblioset relation="article">
+    <authorgroup>
+      <author>
+	<surname>Koopman</surname>
+	<firstname>S.J.</firstname>
+      </author>
+      <author>
+	<surname>Durbin</surname>
+	<firstname>J.</firstname>
+      </author>
+    </authorgroup>
+    <pubdate>2003</pubdate>
+    <title>Filtering and Smoothing of State Vector for Diffuse State Space Models</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Journal of Time Series Analysis</title>
+    <volumenum>24</volumenum>
+    <pagenums>85-98</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry>   
+  <biblioset relation="article">
+    <author>
+      <surname>Laffargue</surname>
+      <firstname>Jean-Pierre</firstname>
+    </author>
+    <title>Résolution d'un modèle macroéconomique avec anticipations rationnelles</title>
+    <pubdate>1990</pubdate>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Annales d'Economie et Statistique</title>
+    <volumenum>17</volumenum>
+    <pagenums>97-119</pagenums>
+  </biblioset>
+</biblioentry>
+<biblioentry> 
+  <authorgroup>
+  <author>
+    <surname>Lubik</surname>
+    <firstname>Thomas</firstname>
+  </author>
+  <author>
+    <surname>Schorfheide</surname>
+    <firstname>Frank</firstname>
+  </author>
+  </authorgroup>
+  <pubdate>2003</pubdate>
+  <title>Do Central Banks Target Exchange Rates? A Structural Investigation</title>
+  <orgname>University of Pennsylvania</orgname>
+</biblioentry>
+<biblioentry> 
+  <authorgroup>
+    <author>
+      <surname>Rabanal</surname>
+      <firstname>Pau</firstname>
+    </author>
+    <author>
+      <surname>Rubio-Ramirez</surname>
+      <firstname>Juan</firstname>
+    </author>
+  </authorgroup>
+  <pubdate>2003</pubdate>
+  <title>Comparing New Keynesian Models of the Business Cycle: A Bayesian Approach</title>
+  <orgname>Atlanta Fed</orgname>
+<citetitle>Working Paper</citetitle>
+<volumenum>2001-22a, rev 2003</volumenum>
+</biblioentry>
+
+<biblioentry> 
+  <biblioset relation="article">
+    <author>
+      <surname>Schorfheide</surname>
+      <firstname>Frank</firstname>
+    </author>
+  <pubdate>2000</pubdate>
+  <title>Loss Function-based evaluation of DSGE models</title>
+  </biblioset>
+  <biblioset relation="journal">
+    <title>Journal of Applied Econometrics</title>
+    <volumenum>15</volumenum>
+    <pagenums>645-70</pagenums>
+  </biblioset>
+</biblioentry>
+
+<biblioentry> 
+  <authorgroup>
+    <author>
+      <surname>Schmitt-Grohe</surname>
+      <firstname>Stephanie</firstname>
+    </author>
+    <author>
+      <surname>Uribe</surname>
+      <firstname>Martin</firstname>
+    </author>
+  </authorgroup>
+  <pubdate>2002</pubdate>
+  <title>Solving Dynamic General Equilibrium Models Using a Second-Order Approximation to the Policy Function</title>
+  <orgname>Rutgers University</orgname>
+</biblioentry>
+
+<biblioentry> 
+  <authorgroup>
+    <author>
+      <surname>Smets</surname>
+      <firstname>Frank</firstname>
+    </author>
+    <author>
+      <surname>Wouters</surname>
+      <firstname>Rafael</firstname>
+    </author>
+  </authorgroup>
+  <pubdate>2002</pubdate>
+  <title>An Estimated Stochastic Dynamic General
+Equilibrium Model of the Euro Area</title>
+  <orgname>European Central Bank</orgname>
+      <citetitle>ECB Working Paper</citetitle>
+      <volumenum>171</volumenum>
+</biblioentry>
+</bibliography>
+<index>
+</index>
+</book>
+
diff --git a/doc/unit_roots.tex b/doc/unit_roots.tex
new file mode 100644
index 0000000000000000000000000000000000000000..b6f42ac6859f307eceb6711e12a405e4d821ae2d
--- /dev/null
+++ b/doc/unit_roots.tex
@@ -0,0 +1,89 @@
+\documentclass{article}
+\usepackage{times}
+\begin{document}
+\title{Notes on estimating models with unit-roots}
+\author{Michel Juillard}
+\maketitle
+
+It is now possible to estimate with DYNARE models with unit-roots. These models must satisfy the following restriction: the dynamics of stochastic trends must be (log)--linear and the dynamics of the stationary part around the stochastic trends may be non-linear. 
+
+\section{Steady state}
+
+For stationay models, DYNARE linearizes around the steady state, using the internal function dynare\_solve.m. When the dynamics of the stochastic trends doesn't contain a deterministic trend (when it is a pure random walk without displacement), there is an infinity of value of $\bar y$ satisfying $f(\bar y)=0$ and it is possible to specify one of them in INITVAL.
+
+When the stochastic trends contain a deterministic trend, there is no solution to the equation $f(\bar y)=0$. It is then necessary to provide DYNARE with a hand written function called \emph{fname\_steadystate.m} that returns the steady state values of the stationary variables and 0 for nonstationary variables when the model is linearized or 1 for nonstationary variables when the model is log--linearized. The variables must be ordered in alphabetical order. See /examples/fs2000a\_steadystate.m for an example. This procedure is cumbersome and we will be trying to automatize it in the future.
+
+\section{Estimation}
+
+For initializing the Kalman filter and for computing the smoother, DYNARE uses now the algorithm described in chapter 5 of J. Durbin and S.J. Koopman (2001) and in S.J. Koopman and J. Durbin (2003). Following the advice of these authors, we prefer it to the augmented filter advocated by De Jong. Note that the results are identical.
+
+In DYNARE, it is necessary to declare the stochastic trends thru the following statement:
+\begin{quote}
+  options\_.unit\_root\_vars = {'P\_obs'; 'Y\_obs'};
+\end{quote}
+This syntax is temporary and will be made more DYNARE-like.
+
+It is also necessary to set the option lik\_init=2 in the estimation statement.
+In the future, this should be triggered automatically from the declaration of a stochastic trend.
+
+It is also necessary to declare the deterministic components of the stochastic trends with the OBSERVATION\_TREND instruction (see /examples/fs2000/fs2000a.mod)
+
+The new functions are
+\begin{itemize}
+\item DgesLikelihood.m: replaces mj\_optmumlik for filtering
+\item DiffuseLikelihood1.m
+\item DiffuseLikelihood2.m
+\item DiffuseLikelihoodH1.m
+\item DiffuseLikelihoodH2.m
+\item DiffuseLikelihoodH3.m
+\item DgseSmoother.m: replaces mj\_optmumlik for smoothing
+\item DiffuseKalmanSmoother.m
+\item DiffuseKalmanSmootherH.m
+\end{itemize}
+They still need thorough testing.
+
+\section{Examples}
+
+DYNARE is now able to estimate purely backward models, in addition to forward--looking models. The first two examples are such to isolate the problematic of estimating nonstationary models from the difficulties of estimating forward--looking rational expectation models.
+
+\subsection{Two unrelated random walks}
+Artificial data (10000 observations) are generated by /examples/arima/mod1.mod for
+\begin{eqnarray*}
+  dx_t = 0.5dx_{t-1}+{e_x}_t\\
+  dy_t = -0.3dy_{t-1}+{e_y}_t\\
+  x_t = x_{t-1}+dx_t\\
+  y_t = y_{t-1}+dy_t
+\end{eqnarray*}
+
+mod1a.mod estimates this model when $dx_t$ and $dy_t$ are observed, and
+mod1b.mod when the level of the data, $x_t$ and $y_t$, are observed. As expected, the results are the same.
+
+\subsection{A cointegrated system} 
+
+Artificial data (10000 observations) are generated by /examples/arima/mod2.mod for
+\begin{eqnarray*}
+  dx_t = 0.5dx_{t-1}-0.1(x_{t-1}-y_{t-1})+{e_x}_t\\
+  dy_t = -0.3dy_{t-1}+0.2(x_{t-1}-y_{t-1})+{e_y}_t\\
+  x_t = x_{t-1}+dx_t\\
+  y_t = y_{t-1}+dy_t
+\end{eqnarray*}
+
+mod2a.mod estimates this model when $dx_t$ and $dy_t$ are observed, and $x$ and $y$ are treated as unobservable variables. The estimation procedure fails as the data is first difference don't contain any information about the initial level of $x$ and $y$.
+
+mod2c.mod again estimates this model when $dx_t$ and $dy_t$ are observed, but the model is reparametrized so as to have the cointegration error as stationary unobservable variable.
+
+mod2b.mod estimates the model with data in level: $x_t$ and $y_t$, are observed.In this case, and on moderate samples (100 observations), data in level provide additional information on the cointegrating relationship. 
+
+\subsection{Schorfheide, 2000}
+
+fs2000.mod estimates the CIA model of Schorfheide (2000) with observation of the rate of growth of prices and output. fs2000a.mod estimates with data in level. The posterior mode of parameters is somewhat different.
+
+
+\section*{References}
+\begin{description}
+\item J. Durbin and S.J. Koopman (2001) \emph{Time Series Analysis by State Space Methods}. Oxford: Oxford University Press.
+\item S.J. Koopman and J. Durbin (2003) ``Filtering and Smoothing of State Vector for Diffuse State Space Models'' in \emph{Journal of Time Series Analysis}, \emph{24}, pp. 85-98.  
+\end{description}
+
+ 
+\end{document}