Commit 74b566d3 by michel

### v4: branching out /doc

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@630 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 0d6ed778
 % ---------------------------------------------------------------- % 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{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} $\{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{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} 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: \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)} \bigskip \noindent The diffuse filtering equations are given by: \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} 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{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} otherwise, we consider a diffuse version of the univariate approach described above. \section{Smoothing} \noindent The smoothing equations are given by: \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} initializing with $r_n = 0$ and with $L_t = T-K_tZ$. The diffuse smoothing equations are given by : \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} 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} % ----------------------------------------------------------------
 \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
doc/dynare.xsl 0 → 100644
 1 0 1 , page
doc/dynare_fo.xsl 0 → 100644
 1 0em 0em 0em 0em 0em
 1 1 0 1

This diff is collapsed.
doc/guide.bbl 0 → 100644
 \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}
doc/guide.blg 0 → 100644
 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)
doc/guide.tex 0 → 100644
This diff is collapsed.
doc/makefile 0 → 100644
 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/
doc/manual.xml 0 → 100644
This source diff could not be displayed because it is too large. You can view the blob instead.
 \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}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!