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 <xreflinkend="model"/> and in <xreflinkend="estimated_params"/></para></listitem>
<listitem><para>added conditional compilation commands <xreflinkend="define"/> and <xreflinkend="if_elseif_else_end"/></para></listitem>
<listitem><para>enhanced output section of command <xreflinkend="estimation"/></para></listitem>
<listitem><para>added exogenous deterministic shocks in stochastic models. See <xreflinkend="varexo_det"/>, <xreflinkend="forecast"/>, <xreflinkend="shocks"/>, <xreflinkend="stoch_simul"/></para></listitem>
<listitem><para>added a forecast command for calibrated models. See <xreflinkend="forecast"/>.</para></listitem>
</itemizedlist>
<para>October 14, 2005</para>
<itemizedlist>
<listitem><para>added syntax for computing optimal policy. See <xreflinkend='olr'/>, <xreflinkend='olr_inst'/>, <xreflinkend='optim_weights'/>, <xreflinkend='osr'/>, <xreflinkend='osr_params'/>.</para></listitem>
<listitem><para>added syntax for estimating correlation between two shocks or two measurment errors in <xreflinkend="estimated_params"/>, <xreflinkend="estimated_params_bounds"/> and <xreflinkend="estimated_params_init"/>
</para></listitem>
</itemizedlist>
<para>July 20, 2005</para>
<itemizedlist>
<listitem><para>Expanded description of <xreflinkend="unit_root_vars"/> statement</para></listitem>
<listitem><para>changed the default for nonlinear solver in <xreflinkend="steady"/></para></listitem>
<listitem><para>added a mention of the possibility to write explicitly a steady state function in <xreflinkend="steady"/>, <xreflinkend="stoch_simul"/>, <xreflinkend="estimation"/> and <xreflinkend="unit_root_vars"/></para></listitem>
<listitem><para>added a brief <emphasis>Ouput</emphasis> section in <xreflinkend="estimation"/></para></listitem>
<listitem><para>corrected misleading description of option <command>prefilter</command> in <xreflinkend="estimation"/></para></listitem>
<listitem><para>added variance decomposition among the statistics computed with option <command>moments_varendo</command> in <xreflinkend="estimation"/></para></listitem>
<listitem><para>tex option in <xreflinkend="estimation"/> isn't yet implemented</para></listitem>
</itemizedlist>
<para>May 3, 2005</para>
<itemizedlist>
<listitem><para>added option <command>noprint</command> in <xreflinkend="stoch_simul"/></para></listitem>
<listitem><para>modified option <command>irf</command> in <xreflinkend="stoch_simul"/></para></listitem>
<listitem><para>modified option <command>simul_seed</command> in <xreflinkend="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 <xreflinkend="stoch_simul"/>.</para></listitem>
<listitem><para>temporarily removed description of output variables in <xreflinkend="estimation"/> as old content was outdated and the new one isn't ready yet.</para></listitem>
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>
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>
<refentryid="Dynare">
<refmeta>
<refentrytitle>dynare</refentrytitle>
</refmeta>
<refnamediv>
<refname>dynare</refname>
<refpurpose>executes Dynare</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>dynare</command>
<argchoice="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:
<itemizedlistspacing='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:
<itemizedlistspacing='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>
<refpurpose>specifies the number of simulation periods</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>periods</command><argchoice="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.
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.
This optional command declares the exogenous variables in the model. See command <xreflinkend="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>
<refentryid="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>
<argchoice="plain">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<arg>
,
</arg>
<argrep="repeat">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argchoice="plain">;</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>
This optional command declares exogenous deterministic variables in a stochastic model. See command <xreflinkend="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 <xreflinkend="stoch_simul"/> will compute the rational expectation solution adding future information to the state space (nothing is shown in the output of <xreflinkend="stoch_simul"/>) and <xreflinkend="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>
<refentryid="parameters">
<refmeta>
<refentrytitle>parameters</refentrytitle>
</refmeta>
<refnamediv>
<refname>parameters</refname>
<refpurpose>declares parameters</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>parameters</command>
<argchoice="plain">
<replaceable>PARAMETER_NAME</replaceable>
</arg>
<arg>
,
</arg>
<argrep="repeat">
<replaceable>PARAMETER_NAME</replaceable>
</arg>
<argchoice="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 <xreflinkend="model"/> block.</para>
<refentryid="model">
<refmeta>
<refentrytitle>model</refentrytitle>
</refmeta>
<refnamediv>
<refname>model</refname>
<refpurpose>declares the model equations</refpurpose>
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 <xreflinkend="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>.
<sect1><title>Initial and terminal conditions</title>
<para>
In many contexts, it is necessary to compute the steady state of a non-linear model <xreflinkend='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 <xreflinkend='initval'/> and <xreflinkend='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 <xreflinkend='initval'/> and <xreflinkend='endval'/>;
</para>
<para>
For models with lags on more than one period, the command <xreflinkend='histval'/> permits to specify different historical initial values in different periods.
<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 (<xreflinkend='steady'/>, <xreflinkend='simul'/>, <xreflinkend='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 <xreflinkend='steady'/>, it is not necessary to provide exact initialization values for the endogenous variables. <xreflinkend='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>
<refentryid="endval">
<refmeta>
<refentrytitle>endval</refentrytitle>
</refmeta>
<refnamediv>
<refname>endval</refname>
<refpurpose>specifies terminal values for deterministic simulations</refpurpose>
<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 (<xreflinkend='steady'/>, <xreflinkend='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 <xreflinkend='steady'/>, it is not necessary to provide exact values for the endogenous variables. <xreflinkend='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 <xreflinkend='steady'/> for x=1, and the terminal one, for x=2.
</para>
</refsect1>
</refentry>
<refentryid="histval">
<refmeta>
<refentrytitle>histval</refentrytitle>
</refmeta>
<refnamediv>
<refname>histval</refname>
<refpurpose>specifies historical values before the start of a simulation</refpurpose>
<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 <xreflinkend='initval'/> and <xreflinkend='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 <xreflinkend='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 <xreflinkend='shocks'/> command. Or, the entire matrix can be direclty entered with <xreflinkend='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.
var <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
</arg>
</synopfragment>
<synopfragmentid="covar_st">
<argchoice="plain">
var <replaceable>VARIABLE_NAME</replaceable> , <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
</arg>
</synopfragment>
<synopfragmentid="stderr_st">
<argchoice="plain">
var <replaceable>VARIABLE_NAME</replaceable>; stderr <replaceable>EXPRESSION</replaceable>;
</arg>
</synopfragment>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Options</title>
<itemizedlistspacing='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 <xreflinkend='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 <xreflinkend="stoch_simul"/> will compute the rational expectation solution adding future information to the state space (nothing is shown in the output of <xreflinkend="stoch_simul"/>) and <xreflinkend="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>
<refentryid="Sigma_e">
<refmeta>
<refentrytitle>Sigma_e</refentrytitle>
</refmeta>
<refnamediv>
<refname>Sigma_e</refname>
<refpurpose>specifies directly the covariance matrix of the stochastic shocks</refpurpose>
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 (<xreflinkend='steady'/>, of the eigenvalues of the linearized model (<xreflinkend='check'/>) for dynamics local analysis, of a deterministic simulation (<xreflinkend='simul'/>) and for solving and/or simulating a stochastic model (<xreflinkend='stoch_simul'/>).
<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 <xreflinkend='initval'/> or <xreflinkend='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 <xreflinkend='initval'/> or <xreflinkend='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 <xreflinkend='initval'/> and <xreflinkend='endval'/>.
</para>
</refsect1>
</refentry>
<refentryid="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>
<argchoice='plain'>;</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>
Computes the eigenvalues of the model linearized around the values specified by the last <xreflinkend='initval'/>, <xreflinkend='endval'/> or <xreflinkend='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>
<refentryid="forecast">
<refmeta>
<refentrytitle>forecast</refentrytitle>
</refmeta>
<refnamediv>
<refname>forecast</refname>
<refpurpose>computes a simulation of a stochastic model from a given state</refpurpose>
<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 <xreflinkend="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>:
<itemizedlistspacing="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>
<refentryid="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>
<argchoice='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>
<refentryid="stoch_simul">
<refmeta>
<refentrytitle>stoch_simul</refentrytitle>
</refmeta>
<refnamediv>
<refname>stoch_simul</refname>
<refpurpose>computes the solution and simulates the model</refpurpose>
specifies the algorithm used for computing the quadratic approximation of the decision rules:
<itemizedlistspacing='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)
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)
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>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).
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 <xreflinkend='initval'/> values, possibly recomputed by <xreflinkend='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)
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 <xreflinkend='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 <xreflinkend='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 <xreflinkend='shocks'/> command or with the <xreflinkend='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Δ<superscript>2</superscript> + A yh<subscript>t-1</subscript> + B u<subscript>t</subscript> + 0.5C(yh<subscript>t-1</subscript>⊗yh<subscript>t-1</subscript>) + 0.5D(u<subscript>t</subscript>⊗u<subscript>t</subscript>) + E(yh<subscript>t-1</subscript>⊗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 Δ<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:
<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>Δ<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.
<refpurpose>lists the observed variables</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>varobs</command>
<argchoice="plain"rep="repeat">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argrep="repeat">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argchoice="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 <xreflinkend='estimation'/>).
</para>
</refsect1>
<refsect1><title>Example</title>
<para>
<informalexample>
<programlisting>
varobs C y rr;
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentryid="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/>
<argchoice="plain">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argchoice="plain">
(<replaceable>EXPRESSION</replaceable>);
</arg><sbr/>
<argchoice="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>
<refentryid="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>
Each line corresponds to an estimated parameter and follows this syntax:
<itemizedlistspacing='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 <xreflinkend="parameters"/> statement and to define the transformation at the top of the <xreflinkend="model"/> section, as a Matlab expression. The first character of the line must be a pound sign (#).
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:
<itemizedlistspacing='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>
Each line corresponds to an estimated parameter and follows this syntax:
<itemizedlistspacing='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>
<refentryid="estimation">
<refmeta>
<refentrytitle>estimation</refentrytitle>
</refmeta>
<refnamediv>
<refname>estimation</refname>
<refpurpose>computes estimation.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>estimation</command>
<arg>(OPTIONS)</arg>
<argchoice='plain'>;</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>OPTIONS</title>
<itemizedlistspacing='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 = 0)</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.
<itemizedlistspacing='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><anchorid="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><anchorid="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.
<itemizedlistspacing='compact'>
<listitem><para>0: the mode isn't computed. mode_file must be specified</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><anchorid="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>
<command>nodiagnostic</command>: doesn't compute the convergence diagnostics for Metropolis (default: diagnostics are computed and displayed).
</para>
</listitem>
<listitem><para><anchorid="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><anchorid="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><anchorid="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><anchorid="smoother"xreflabel="smoother"/><para><command>smoother</command> triggers the computation of the posterior distribution of smoothered endogenous variables and shocks</para></listitem>
<listitem><para><anchorid="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 <xreflinkend="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>
<itemizedlistspacing='compact'>
<listitem><para> results from posterior optimization (also for maximum likelihood)</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>:
<tableorient="land"><title>Content of <varname>oo_</varname></title><tgroupcols='2'>
<row><entry><varname>ModifiedHarmonicMean</varname></entry><entry></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
<row><entry><varname>PosteriorIRF</varname></entry><entry><varname>Dsge</varname></entry><entry>See <xreflinkend="MomentsNames"/></entry><entry><para>IRF name: name of endogenous variable '_' name of shock</para></entry><entry></entry><entry><xreflinkend="bayesian_irf"/></entry></row>
<row><entry><varname>posterior_density</varname></entry><entry><replaceable>Parameter name</replaceable></entry><entry></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
<row><entry><varname>posterior_hpdinf</varname></entry><entry>See <xreflinkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
<row><entry><varname>posterior_hpdsup</varname></entry><entry>See <xreflinkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
<row><entry><varname>posterior_mean</varname></entry><entry>See <xreflinkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
<row><entry><varname>posterior_mode</varname></entry><entry>See <xreflinkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
<row><entry><varname>posterior_std</varname></entry><entry>See <xreflinkend="EstimatedObjects"/></entry><entry><replaceable>Variable name</replaceable></entry><entry></entry><entry></entry><entry><para><xreflinkend="mh_replic"/>> 0 or <xreflinkend="load_mh_file"/></para></entry></row>
</tbody>
</tgroup>
</table>
</para>
<para><anchorid="ForecastsMoments"xreflabel="Moments of forecasts"/>
<row><entry><varname>HPDinf</varname></entry><entry>Lower bound of a 90% HPD interval<footnoteid="see_conf_sig"><para>See option <xreflinkend="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 <footnotereflinkend="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 <footnotereflinkend="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 <footnotereflinkend="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>
<row><entry><varname>HPDinf</varname></entry><entry>Lower bound of a 90% HPD interval<footnoteid="see_conf_sig1"><para>See option <xreflinkend="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 <footnotereflinkend="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>
<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 <xreflinkend="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 <xreflinkend="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>
<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>
<refentryid="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>
<argchoice="plain">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argrep="repeat">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argchoice="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 <xreflinkend="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 <xreflinkend='olr'/> or for optimal simple rule with <xreflinkend='osr'/>.
<para>The policy instruments must be listed with <xreflinkend='olr_inst'/>.
</para>
<para>The quadratic objectives must be listed with <xreflinkend='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 <xreflinkend='stoch_simul'/>.
</para>
</refsect1>
</refentry>
<refentryid="olr_inst">
<refmeta>
<refentrytitle>olr_inst</refentrytitle>
</refmeta>
<refnamediv>
<refname>olr_inst</refname>
<refpurpose>declares instruments for optimal policy under commitment</refpurpose>
var <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
</arg>
</synopfragment>
<synopfragmentid="covar_st1">
<argchoice="plain">
var <replaceable>VARIABLE_NAME</replaceable> , <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;
</arg>
</synopfragment>
<synopfragmentid="stderr_st1">
<argchoice="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 <xreflinkend='olr'/> and <xreflinkend='osr'/>
<listitem><para>γ: parameters to be optimized. They must be elements of matrices A<subscript>1</subscript>, A<subscript>2</subscript>, A<subscript>3</subscript>.</para></listitem>
<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>
<refentryid="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>
<argchoice="plain">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argrep="repeat">
<replaceable>VARIABLE_NAME</replaceable>
</arg>
<argchoice="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.
<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.
<listitem><para><= lesser or equal than</para></listitem>
<listitem><para>>= 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>
<bibliosetrelation="article">
<author>
<surname> Boucekkine</surname>
<firstname> Raouf</firstname>
</author>
<pubdate>1995</pubdate>
<title>An alternative methodology for solving nonlinear forward-looking models</title>
</biblioset>
<bibliosetrelation="journal">
<title>Journal of Economic Dynamics and Control</title>
<volumenum>19</volumenum>
<pagenums>711-734</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="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>
<bibliosetrelation="journal">
<title>Journal of Economic Dynamics and Control</title>
<volumenum>25</volumenum>
<pagenums>979-999</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="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>
<bibliosetrelation="journal">
<title>Computational Economics</title>
<volumenum>17</volumenum>
<pagenums>125-139</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="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>
<bibliosetrelation="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>
<bibliosetrelation="journal">
<title>Econometrica</title>
<volumenum>51</volumenum>
<pagenums>1169-1185</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="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>
<bibliosetrelation="journal">
<title>Journal of Econometrics</title>
<volumenum>123</volumenum>
<pagenums>153-187</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="article">
<author>
<surname>Ireland</surname>
<firstname>Peter</firstname>
</author>
<pubdate>2004</pubdate>
<title>A Method for Taking Models to the Data</title>
</biblioset>
<bibliosetrelation="journal">
<title>Journal of Economic Dynamics and Control</title>
<volumenum>28</volumenum>
<pagenums>1205-26</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="article">
<author>
<surname>Judd</surname>
<firstname>Kenneth</firstname>
</author>
<pubdate>1996</pubdate>
<title>Approximation, Perturbation, and Projection Methods in Economic Analysis</title>
</biblioset>
<bibliosetrelation="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>
<bibliosetrelation="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>
<bibliosetrelation="journal">
<title>Journal of Time Series Analysis</title>
<volumenum>24</volumenum>
<pagenums>85-98</pagenums>
</biblioset>
</biblioentry>
<biblioentry>
<bibliosetrelation="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>
<bibliosetrelation="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>
<bibliosetrelation="article">
<author>
<surname>Schorfheide</surname>
<firstname>Frank</firstname>
</author>
<pubdate>2000</pubdate>
<title>Loss Function-based evaluation of DSGE models</title>
</biblioset>
<bibliosetrelation="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>