Reference manual:

- describe 3rd order approximation (closes #124)
- improve description of variable reordering
time-shift
Sébastien Villemot 2010-08-24 15:44:29 +02:00
parent 6d06fbb547
commit 9edb4d7361
1 changed files with 313 additions and 32 deletions

View File

@ -2171,7 +2171,7 @@ steady;
<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. If you know how to compute the steady state for your model, you can provide a <trademark class="registered">MATLAB</trademark> function doing the computation instead of using the nonlinear solver. The function should be called with the name of the <filename class="extension">.mod</filename> file followed by <filename>_steadystate</filename>. See <filename>fs2000a_steadystate.m</filename> in <filename>examples/fs2000</filename> directory.
<para>The Taylor approximation is computed around the steady state. If you know how to compute the steady state for your model, you can provide a <trademark class="registered">MATLAB</trademark>/Octave function doing the computation instead of using the nonlinear solver. The function should be called with the name of the <filename class="extension">.mod</filename> file followed by <filename>_steadystate</filename>. See <filename>fs2000a_steadystate.m</filename> in <filename>examples/fs2000</filename> directory.
</para>
<para>The IRFs are computed as the difference between the trajectory of a variable following a shock at the beginning of period 1 and its steady state value.
@ -2194,58 +2194,332 @@ steady;
</para>
</refsect1>
<refsect1>
<refsect1 id="aux_vars">
<title>Auxiliary variables for leads and lags</title>
<para>For a stochastic model, Dynare will perform a transformation of the model so that there is only one lead and one lag on endogenous, and no lead/lag on exogenous.</para>
<para>This transformation is achieved by the creation of auxiliary variables, and corresponding equations. For example, if <literal>x(+2)</literal> exists in the model, Dynare will create one auxiliary variable <literal>AUX_ENDO_LEAD = x(+1)</literal>, and replace <literal>x(+2)</literal> by <literal>AUX_ENDO_LEAD(+1)</literal>.</para>
<para>A similar transformation is done for lags greater than 2 on endogenous (auxiliary variables will have a name beginning with <literal>AUX_ENDO_LAG</literal>), and for exogenous with leads and lags (auxiliary variables will have a name beginning with <literal>AUX_EXO_LEAG</literal> or <literal>AUX_EXO_LAG</literal> respectively).</para>
<para>Once created, all auxiliary variables are included in the set of endogenous variables. The output of decision rules (see below) is such that auxiliary variable names are replaced by the original variables they refer to.</para>
<para>The number of endogenous variables before the creation of auxiliary variables is stored in <varname>M_.orig_endo_nbr</varname>, and the number of endogenous variables after the creation of auxiliary variables is stored in <varname>M_.endo_nbr</varname>.</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.
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. The decision rules are stored
in the structure <varname>oo_.dr</varname> which is described below.
</para>
<refsect2><title>Typology and ordering of variables</title>
<para>
Dynare distinguishes four types of endogenous variables:
</para>
<variablelist>
<varlistentry>
<term>Purely backward (or purely predetermined) variables</term>
<listitem>
<para>
Those that appear only at current and past period in the model, but not
at future period (<foreignphrase>i.e.</foreignphrase> at
<literal>t</literal> and <literal>t-1</literal> but not
<literal>t+1</literal>). The number of such variables is equal to
<varname>oo_.dr.npred - oo_.dr.nboth</varname>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Purely forward variables</term>
<listitem>
<para>
Those that appear only at current and future period in the model, but
not at past period (<foreignphrase>i.e.</foreignphrase> at
<literal>t</literal> and <literal>t+1</literal> but not
<literal>t-1</literal>). The number of such variables is stored in
<varname>oo_.dr.nfwrd</varname>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Mixed variables</term>
<listitem>
<para>
Those that appear at current, past and future period in the model
(<foreignphrase>i.e.</foreignphrase> at <literal>t</literal>,
<literal>t+1</literal> and <literal>t-1</literal>). The number of such
variables is stored in <varname>oo_.dr.nboth</varname>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Static variables</term>
<listitem>
<para>
Those that appear only at current, not past and future period in the
model (<foreignphrase>i.e.</foreignphrase> only at
<literal>t</literal>, not at <literal>t+1</literal> or
<literal>t-1</literal>). The number of such variables is stored in
<varname>oo_.dr.nstatic</varname>.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Note that all endogenous variables fall into one of these four categories,
since after the creation of <link linkend="aux_vars">auxiliary
variables</link>, all endogenous have at most one lead and one lag. We
therefore have the following identity: <varname>oo_.dr.npred + oo_.dr.nfwrd +
oo_.dr.nstatic = M_.endo_nbr</varname>.
</para>
<para>
Internally, Dynare uses two orderings of the endogenous variables: the order
of declaration (which is reflected in <varname>M_.endo_names</varname>), and
an order based on the four types described above, which we will call the
DR-order ("DR" stands for decision rules). Most of the time, the declaration
order is used, but for elements of the decision rules, the DR-order is used.
</para>
<para>
The DR-order is the following: static variables appear first, then purely
backward variables, then mixed variables, and finally purely forward
variables. Inside each category, variables are arranged according to the
declaration order.
</para>
<para>
Variable <varname>oo_.dr.order_var</varname> maps DR-order to declaration
order, and variable <varname>oo_.dr.inv_order_var</varname> contains the
inverse map. In other words, the k-th variable in the DR-order corresponds
to the endogenous variable numbered <varname>oo_.dr_order_var(k)</varname> in
declaration order. Conversely, k-th declared variable is numbered
<varname>oo_.dr.inv_order_var(k)</varname> in DR-order.
</para>
<para>
Finally, the state variables of the model are the purely backward variables
and the mixed variables. They are orderer in DR-order when they appear in
decision rules elements. There are <varname>oo_.dr.npred</varname> such
variables.
</para>
</refsect2>
<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.
The approximation has the form:
</para>
<blockquote>
<para>
y<subscript>t</subscript> = ys + A yh<subscript>t-1</subscript> + B
u<subscript>t</subscript>
</para>
</blockquote>
<para>
where ys is the steady state value of y and
yh<subscript>t</subscript>=y<subscript>t</subscript>-ys.
</para>
<para>
The coefficients of the decision rules are stored as follows:
<itemizedlist>
<listitem>
<para>
ys is stored in <varname>oo_.dr.ys</varname>. The vector rows
correspond to all endogenous in the declaration order.
</para>
</listitem>
<listitem>
<para>
A is stored in <varname>oo_.dr.ghx</varname>. The matrix rows
correspond to all endogenous in DR-order. The matrix columns correspond
to state variables in DR-order.
</para>
</listitem>
<listitem>
<para>
B is stored <varname>oo_.dr.ghu</varname>. The matrix rows correspond
to all endogenous in DR-order. The matrix columns correspond to
exogenous variables in declaration order.
</para>
</listitem>
</itemizedlist>
</para>
</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.
The approximation has the form:
</para>
<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.5 C
(yh<subscript>t-1</subscript>&otimes;yh<subscript>t-1</subscript>) + 0.5 D
(u<subscript>t</subscript>&otimes;u<subscript>t</subscript>) + E
(yh<subscript>t-1</subscript>&otimes;u<subscript>t</subscript>)
</para>
</blockquote>
<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>
<para>
The coefficients of the decision rules are stored in the variables described
for first order approximation, plus the following variables:
<itemizedlist>
<listitem>
<para>
&Delta;<superscript>2</superscript> is stored in
<varname>oo_.dr.ghs2</varname>. The vector rows correspond to all
endogenous in DR-order.
</para>
</listitem>
<listitem>
<para>
C is stored in <varname>oo_.dr.ghxx</varname>. The matrix rows
correspond to all endogenous in DR-order. The matrix columns correspond
to the Kronecker product of the vector of state variables in DR-order.
</para>
</listitem>
<listitem>
<para>
D is stored in <varname>oo_.dr.ghuu</varname>. The matrix rows
correspond to all endogenous in DR-order. The matrix columns correspond
to the Kronecker product of exogenous variables in declaration order.
</para>
</listitem>
<listitem>
<para>
E is stored in <varname>oo_.dr.ghxu</varname>. The matrix rows
correspond to all endogenous in DR-order. The matrix columns correspond
to the Kronecker product of the vector of state variables (in DR-order)
by the vector of exogenous variables (in declaration order).
</para>
</listitem>
</itemizedlist>
</para>
</refsect2>
<refsect2><title>Third order approximation</title>
<para>
The approximation has the form:
</para>
<blockquote>
<para>
y<subscript>t</subscript> = ys + G<subscript>0</subscript> +
G<subscript>1</subscript> z<subscript>t</subscript> +
G<subscript>2</subscript> (z<subscript>t</subscript>&otimes;
z<subscript>t</subscript>) + G<subscript>3</subscript>
(z<subscript>t</subscript>&otimes; z<subscript>t</subscript> &otimes;
z<subscript>t</subscript>)
</para>
</blockquote>
<para>
where ys is the steady state value of y, and z<subscript>t</subscript> is a
vector consisting of the deviation from the steady state of the state
variables (in DR-order) at date t-1 followed by the exogenous variables at
date t (in declaration order). The vector z<subscript>t</subscript> is
therefore of size n<subscript>z</subscript> = <varname>oo_.dr.npred +
M_.exo_nbr</varname>.
</para>
<para>
The coefficients of the decision rules are stored as follows:
<itemizedlist>
<listitem>
<para>
ys is stored in <varname>oo_.dr.ys</varname>. The vector rows
correspond to all endogenous in the declaration order.
</para>
</listitem>
<listitem>
<para>
G<subscript>0</subscript> is stored in <varname>oo_.dr.g_0</varname>. The
vector rows correspond to all endogenous in DR-order.
</para>
</listitem>
<listitem>
<para>
G<subscript>1</subscript> is stored in <varname>oo_.dr.g_1</varname>. The
matrix rows correspond to all endogenous in DR-order. The matrix
columns correspond to state variables in DR-order, followed by
exogenous in declaration order.
</para>
</listitem>
<listitem>
<para>
G<subscript>2</subscript> is stored in
<varname>oo_.dr.g_2</varname>. The matrix rows correspond to all
endogenous in DR-order. The matrix columns correspond to the Kronecker
product of state variables (in DR-order), followed by exogenous (in
declaration order). Note that the Kronecker product is stored in a
folded way, <foreignphrase>i.e.</foreignphrase> symmetric elements are
stored only once, which implies that the matrix has
n<subscript>z</subscript>(n<subscript>z</subscript>+1)/2 columns. More
precisely, each column of this matrix corresponds to a pair
(i<subscript>1</subscript>, i<subscript>2</subscript>) where each index
represents an element of z<subscript>t</subscript> and is therefore
between 1 and n<subscript>z</subscript>. Only non-decreasing pairs are
stored, <foreignphrase>i.e.</foreignphrase> those for which
i<subscript>1</subscript> &le; i<subscript>2</subscript>. The columns
are arranged in the lexicographical order of non-decreasing pairs. Also
note that for those pairs where i<subscript>1</subscript> &ne;
i<subscript>2</subscript>, since the element is stored only once but
appears two times in the unfolded G<subscript>2</subscript> matrix, it
must be multiplied by 2 when computing the decision rules.
</para>
</listitem>
<listitem>
<para>
G<subscript>3</subscript> is stored in
<varname>oo_.dr.g_3</varname>. The matrix rows correspond to all
endogenous in DR-order. The matrix columns correspond to the third
Kronecker power of state variables (in DR-order), followed by exogenous
(in declaration order). Note that the third Kronecker power is stored
in a folded way, <foreignphrase>i.e.</foreignphrase> symmetric elements
are stored only once, which implies that the matrix has
n<subscript>z</subscript>(n<subscript>z</subscript>+1)(n<subscript>z</subscript>+2)/6
columns. More precisely, each column of this matrix corresponds to a
tuple (i<subscript>1</subscript>, i<subscript>2</subscript>,
i<subscript>3</subscript>) where each index represents an element of
z<subscript>t</subscript> and is therefore between 1 and
n<subscript>z</subscript>. Only non-decreasing tuples are stored,
<foreignphrase>i.e.</foreignphrase> those for which
i<subscript>1</subscript> &le; i<subscript>2</subscript> &le;
i<subscript>3</subscript>. The columns are arranged in the
lexicographical order of non-decreasing tuples. Also note that for
tuples that have three distinct indices
(<foreignphrase>i.e.</foreignphrase> i<subscript>1</subscript> &ne;
i<subscript>2</subscript> and i<subscript>1</subscript> &ne;
i<subscript>3</subscript> and i<subscript>2</subscript> &ne;
i<subscript>3</subscript>), since these elements are stored only once
but appears six times in the unfolded G<subscript>3</subscript> matrix,
they must be multiplied by 6 when computing the decision
rules. Similarly, for those tuples that have two equal indices
(<foreignphrase>i.e.</foreignphrase> of the form (a,a,b) or (a,b,a) or
(b,a,a)), since these elements are stored only once but appears three
times in the unfolded G<subscript>3</subscript> matrix, they must be
multiplied by 3 when computing the decision rules.
</para>
</listitem>
</itemizedlist>
</para>
</refsect2>
</refsect1>
<refsect1><title>Output variables</title>
<refsect1><title>Other 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.
<command>stoch_simul</command> sets other 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>oo_.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>oo_.dr.ys</varname>. The vector rows correspond to variables in the declaration order of the variable names.</para></listitem>
<listitem><para>&Delta;<superscript>2</superscript>: <varname>oo_.dr.ghs2</varname>. The vector rows correspond to re-ordered variables (see below).</para></listitem>
<listitem><para><varname>A</varname>: <varname>oo_.dr.ghx</varname>. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to state variables (see below).</para></listitem>
<listitem><para><varname>B</varname>: <varname>oo_.dr.ghu</varname>. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to exogenous variables in declaration order.</para></listitem>
<listitem><para><varname>C</varname>: <varname>oo_.dr.ghxx</varname>. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to the Kronecker product of the vector of state variables (see below).</para></listitem>
<listitem><para><varname>D</varname>: <varname>oo_.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 declaration order.</para></listitem>
<listitem><para><varname>E</varname>: <varname>oo_.dr.ghxu</varname>. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to the Kronecker product of the vector of state variables (see below) by the vector of exogenous variables in declaration 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 in declaration order. Variable <varname>oo_.dr.order_var</varname> maps reordered variables to declaration order, and variable <varname>oo_.dr.inv_order_var</varname> contains the inverse map. In other words, the first row in transition matrices corresponds to the endogenous declared at position <varname>oo_.dr_order_var(1)</varname>; conversely, first declared variable has row <varname>oo_.dr.inv_order_var(1)</varname> in transition matrices.</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 declaration 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 declaration order.</para></listitem>
@ -2253,14 +2527,21 @@ steady;
</para></listitem>
<listitem>
<para>
Simulated variables, when they have been computed, are available in <trademark class="registered">MATLAB</trademark>
vectors with the same name as the endogenous variables. They are also available in the <varname>oo_.endo_simul</varname> matrix. The series are arranged by row, in declaration order of the variable names</para>
Simulated variables, when they have been computed, are available in
<trademark class="registered">MATLAB</trademark>/Octave vectors in the
global workspace with the same name as the endogenous variables. They
are also available in the <varname>oo_.endo_simul</varname> matrix. The
series are arranged by row, in declaration order of the variable
names</para>
</listitem>
<listitem>
<para>
Impulse responses, when they have been computed, are available in <varname>oo_.irfs</varname>, with the following naming convention: <varname><replaceable>VARIABLE_NAME</replaceable>_<replaceable>SHOCK_NAME</replaceable></varname>.</para>
<para>(DEPRECATED) They are currently also available in <trademark class="registered">MATLAB</trademark> vectors in the global workspace, however they will disappear there in a future version.
<para>
(DEPRECATED) They are currently also available in <trademark
class="registered">MATLAB</trademark>/Octave vectors in the global
workspace, however they will disappear there in a future version.
</para>
<informalexample>
<para>Example: