Dynare Manual Version 4.2.0 StéphaneAdjemian Université du Mans and CEPREMAP stephane.adjemian@ens.fr
142 rue du Chevaleret75013ParisFrance
HoutanBastani CEPREMAP houtanb@gmail.com
142 rue du Chevaleret75013ParisFrance
MichelJuillard Banque de France and CEPREMAP michel.juillard@ens.fr
142 rue du Chevaleret75013ParisFrance
FerhatMihoubi Université d'Évry and CEPREMAP fmihoubi@univ-evry.fr
142 rue du Chevaleret75013ParisFrance
GeorgePerendia CEPREMAP george@perendia.orangehome.co.uk
142 rue du Chevaleret75013ParisFrance
MarcoRatto The European Commission, Joint Research Centre and CEPREMAP marco.ratto@jrc.ec.europa.eu
142 rue du Chevaleret75013ParisFrance
SébastienVillemot CEPREMAP sebastien.villemot@ens.fr
142 rue du Chevaleret75013ParisFrance
1996-2010Dynare Team Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found at: http://www.gnu.org/licenses/fdl.txt
Introduction What is Dynare ? Dynare is a pre-processor and a collection of MATLAB and GNU Octave 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 , , , and ). 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. For deterministic simulations, Dynare uses a Newton-type algorithm, first proposed by , instead of a first order technique like the one proposed by , 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 can be found in . In a stochastic context, Dynare computes one or several simulations corresponding to a random draw of the shocks. Dynare uses a Taylor approximation, up to third order, of the expectation functions (see , , , and ). It is also possible to use Dynare to estimate model parameters either by maximum likelihood as in or using a Bayesian approach as in , or . Currently the development team of Dynare is composed of S. Adjemian, H. Bastani, M. Juillard, F. Mihoubi, G. Perendia, M. Ratto and S. Villemot. Several parts of Dynare use or have strongly benefited from publicly available programs by G. Anderson, F. Collard, L. Ingber, O. Kamenik, P. Klein, S. Sakata, F. Schorfheide, C. Sims, P. Soederlind and R. Wouters. Installation and configuration Software requirements Packaged versions of Dynare are available for Windows XP/Vista, Debian GNU/Linux and Ubuntu. Dynare should work on other systems, but some compilation steps are necessary in that case. In order to run Dynare, you need at least one of the following: MATLAB version 6.5 or above; note that no toolbox is needed by Dynare, GNU Octave version 3.0.0 or above. Some installation instructions for GNU Octave can be found on Dynare Wiki. If you plan to use options (in particular when computing third order approximations with ), you will need to install the necessary requirements for compiling MEX files on your machine. If you are using MATLAB under Windows, install a C++ compiler on your machine, and configure it with MATLAB: see instructions on the Dynare wiki. Users of Octave under Linux should install the package for MEX file compilation (under Debian or Ubuntu, it is called octave3.2-headers or octave3.0-headers). Users of MATLAB under Linux and MacOS, and users of Octave under Windows, normally need to do nothing, since a working compilation environment is available by default. Installation of Dynare 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. On <trademark class="registered">Windows</trademark> Execute the automated installer called dynare-4.x.y-win.exe (where 4.x.y is the version number), and follow the instructions. The default installation directory is c:\dynare\4.x.y. After installation, this directory will contain several sub-directories, among which matlab, mex and doc. The installer will also add an entry in your Start Menu with a shortcut to documentation files and to the uninstaller. Users of MATLAB 64-bit also need to install Microsoft Visual C++ runtime libraries in order to have functional MEX files. Note that you can have several versions of Dynare coexisting (for example in c:\dynare), as long as you correctly adjust your path settings (see ). On Debian GNU/Linux and Ubuntu Please refer to Dynare Wiki for detailed instructions. Dynare will be installed under /usr/share/dynare and /usr/lib/dynare. Documentation will be under /usr/share/doc/dynare. For other systems You need to download Dynare source code from the Dynare website and unpack it somewhere. Then you will need to recompile the pre-processor and the dynamic loadable libraries. Please refer to Dynare Wiki. Configuration For <trademark class="registered">MATLAB</trademark> You need to add the matlab subdirectory of your Dynare installation to MATLAB path. You have two options for doing that: Using the addpath command in the MATLAB command window: Under Windows, assuming that you have installed Dynare at the standard location, and replacing "4.x.y" by correct version number, type: addpath c:\dynare\4.x.y\matlab Under Debian GNU/Linux or Ubuntu, type: addpath /usr/share/dynare/matlab MATLAB will not remember this setting next time you run it, and you will have to do it again. Via the menu entries: Select the "Set Path" entry in the "File" menu, then click on "Add Folder...", and select the matlab subdirectory of your Dynare installation. Note that you should not use "Add with Subfolders...". Apply the settings by clicking on "Save". Note that MATLAB will remember this setting next time you run it. For GNU Octave You need to add the matlab subdirectory of your Dynare installation to Octave path, using the addpath at the Octave command prompt. Under Windows, assuming that you have installed Dynare at the standard location, and replacing "4.x.y" by correct version number, type: addpath c:\dynare\4.x.y\matlab Under Debian GNU/Linux or Ubuntu, there is no need to use the addpath command; the packaging does it for you. If you are using an Octave version strictly older than 3.2.0, you will also want to tell to Octave to accept the short syntax (without parentheses and quotes) for the dynare command, by typing: mark_as_command dynare If you don't want to type this command every time you run Octave, you can put it in a file called .octaverc in your home directory (under Windows this will generally by c:\Documents and Settings\USERNAME\). This file is run by Octave at every startup. Some words of warning You should be very careful about the content of you MATLAB or Octave path. You can display its content by simply typing path in the command window. The path should normally contain system directories of MATLAB or Octave, and some subdirectories of your Dynare installation. You have to manually add the matlab subdirectory, and Dynare will automatically add a few other subdirectories at runtime (depending on your configuration). You must verify that there is no directory coming from another version of Dynare than the one you are planning to use. You have to be aware that adding other directories to your path can potentially create problems, if some of your M-files have the same names than Dynare files. Your files would then override Dynare files, and make Dynare unusable. Dynare invocation In order to give instructions to Dynare, the user has to write a model file whose filename extension must be .mod. This file contains the description of the model and the computing tasks required by the user. Its contents is described in . Once the model file is written, Dynare is invoked using the dynare command at the MATLAB or Octave prompt (with the filename of the .mod given as argument). In practice, the handling of the model file is done in two steps: in the first one, the model and the processing instructions written by the user in a model file are interpreted and the proper MATLAB or GNU Octave instructions are generated; in the second step, the program actually runs the computations. Boths steps are triggered automatically by the dynare command. dynare dynare executes Dynare dynare FILENAME[.mod] =FILENAME Description dynare executes instruction included in FILENAME.mod. This user-supplied file contains the model and the processing instructions, as described in . Details dynare begins by launching the preprocessor on the .mod file. By default (unless option has been given to ), the preprocessor creates three intermediary files: FILENAME.m Contains variable declarations, and computing tasks FILENAME_dynamic.m Contains the dynamic model equations FILENAME_static.m Contains the long run static model equations These files may be looked at to understand errors reported at the simulation stage. dynare will then run the computing tasks by executing FILENAME.m. Options By default, dynare will issue a clear all command to MATLAB or Octave, thereby deleting all workspace variables; this options instructs dynare not to clear the workspace Instructs the preprocessor to write some debugging information about the scanning and parsing of the .mod file Instructs the preprocessor to omit temporary terms in the static and dynamic files; this generally decreases performance, but is used for debugging purposes since it makes the static and dynamic files more readable [=FILENAME] Instructs dynare to save the intermediary file which is obtained after macro-processing (see ); the saved output will go in the file specified, or if no file is specified in FILENAME-macroexp.mod Instructs the preprocessor to only perform the macro-processing step, and stop just after. Mainly useful for debugging purposes or for using the macro-processor independently of the rest of Dynare toolbox. Instructs the macro-preprocessor to omit line numbering information in the intermediary .mod file created after the maco-processing step. Useful in conjunction with when one wants that to reuse the intermediary .mod file, without having it cluttered by line numbering directives. Display a warning for each variable or parameter which is not initialized. Initialization should be done through or for parameters, or through , or for endogenous and exogenous. Tells Dynare that your MATLAB is configured for compiling MEX files with Cygwin (see ). This option is only available under Windows, and is used in conjunction with . Tells Dynare that your MATLAB is configured for compiling MEX files with Microsoft Visual C++ (see ). This option is only available under Windows, and is used in conjunction with . Output Depending on the computing tasks requested in the .mod file, executing command dynare will leave in the workspace variables containing results available for further processing. More details are given under the relevant computing tasks. The M_, oo_ and options_ structures are also saved in a file called FILENAME_results.mat. Examples dynare ramst dynare ramst.mod savemacro The Model file Dynare commands are either single instructions or a block of instructions. Each single instruction and each element of a block is terminated by a semicolon (;). Blocks of instructions are terminated by end;. Most Dynare commands have arguments and several accept options, indicated in parentheses after the command keyword. In the description of Dynare commands, the following conventions are observed: optional arguments or options are indicated between square brackets [] repreated arguments are indicated by ellipses ... mutually exclusive arguments are separated by vertical bars | INTEGER indicates an integer number DOUBLE indicates a double precision number. The following syntaxes are valid: 1.1e3, 1.1E3, 1.1d3, 1.1D3 EXPRESSION indicates a mathematical expression valid outside the model description (see ) MODEL_EXPRESSION indicates a mathematical expression valid in the model description (see and ) VARIABLE_NAME indicates a variable name starting with an alphabetical character and can't contain ()+-*/^=!;:@#. or accentuated characters PARAMETER_NAME indicates a parameter name starting with an alphabetical character and can't contain ()+-*/^=!;:@#. or accentuated characters LATEX_NAME indicates a valid LaTeX expression in math mode (not including the dollar signs) FUNCTION_NAME indicates a valid MATLAB function name FILENAME indicates a filename valid in the underlying operating system; it is necessary to put it between double quotes when specifying the extension or if the filename contains a non-alphanumeric character Variable declarations Declarations of variables and parameters are made with the following commands: var var declares endogenous variables var VARIABLE_NAME $LATEX_NAME$ , VARIABLE_NAME $LATEX_NAME$ ; Description This required command declares the endogenous variables in the model. See for the syntax of VARIABLE_NAME. Optionally it is possible to give a LaTeX name to the variable. var commands can appear several times in the file and Dynare will concatenate them. Example var c gnp q1 q2; varexo varexo declares exogenous variables varexo VARIABLE_NAME $LATEX_NAME$ , VARIABLE_NAME $LATEX_NAME$ ; Description This optional command declares the exogenous variables in the model. See for the syntax of VARIABLE_NAME. Optionally it is possible to give a LaTeX name to the variable. Exogenous variables are required if the user wants to be able to apply shocks to her model. varexo commands can appear several times in the file and Dynare will concatenate them. Example varexo m gov; varexo_det varexo_det declares exogenous deterministic variables in a stochastic model varexo_det VARIABLE_NAME $LATEX_NAME$ , VARIABLE_NAME $LATEX_NAME$ ; Description This optional command declares exogenous deterministic variables in a stochastic model. See for the syntax of VARIABLE_NAME. Optionally it is possible to give a LaTeX name to the variable. 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 will compute the rational expectation solution adding future information to the state space (nothing is shown in the output of ) and will compute a simulation conditional on initial conditions and future information. varexo_det commands can appear several times in the file and Dynare will concatenate them. Example varexo m gov; varexo_det tau; parameters parameters declares parameters parameters PARAMETER_NAME $LATEX_NAME$ , PARAMETER_NAME $LATEX_NAME$ ; Description This command declares parameters used in the model, in variable initialization or in shocks declarations. See for the syntax of PARAMETER_NAME. Optionally it is possible to give a LaTeX name to the parameter. The parameters must subsequently be assigned values, see . parameters commands can appear several times in the file and Dynare will concatenate them. Example parameters alpha, bet; change_type change_type modify the type of declared variables/parameters change_type ( var varexo varexo_det parameters ) VARIABLE_NAME PARAMETER_NAME , VARIABLE_NAME PARAMETER_NAME ; Description Changes the types of the specified variables/parameters to another type: endogenous, exogenous, exogenous deterministic or parameter. It is important to understand that this command has a global effect on the .mod file: the type change is effective after, but also before, the change_type command. This command is typically used when flipping some variables for steady state calibration: typically a separate model file is used for calibration, which includes the list of variable declarations with the macro-processor, and flips some variable. Example var y, w; parameters alpha, bet; ... change_type(var) alpha, bet; change_type(parameters) y, w; Here, in the whole model file, alpha and beta will be endogenous and y and w will be parameters. predetermined_variables predetermined_variables declare some endogenous variables as predetermined predetermined_variables VARIABLE_NAME VARIABLE_NAME ; Description In Dynare, the default convention is that the timing of a variable reflects when this variable is decided. The typical example is for capital stock: since the capital stock used at current period is actually decided at the previous period, then the capital stock entering the production function is k(-1), and the law of motion of capital must be written: k = i + (1-delta)*k(-1) Put another way, for stock variables, the default in Dynare is to use a “stock at the end of the period” concept, instead of a “stock at the beginning of the period” convention. The predetermined_variables is used to change that convention. The endogenous variables declared as predetermined variables are supposed to be decided one period ahead of all other endogenous variables. For stock variables, they are supposed to follow a “stock at the beginning of the period” convention. Example The following two program snippets are strictly equivalent. Using default Dynare timing convention: var y, k, i; ... model; y = k(-1)^alpha; k = i + (1-delta)*k(-1); ... end; Using the alternative timing convention: var y, k, i; predetermined_variables k; ... model; y = k^alpha; k(+1) = i + (1-delta)*k; ... end; Expressions Dynare distinguishes between two types of mathematical expressions: those that are used to describe the model, and those that are used outside the model block (e.g. for initializing parameters or variables, or as command options). In this manual, those two types of expressions are respectively denoted by MODEL_EXPRESSION and EXPRESSION. Unlike MATLAB or Octave expressions, Dynare expressions are necessarily scalar ones: they cannot contain matrices or evaluate to matricesNote that arbitrary MATLAB or Octave expressions can be put in a .mod file, but those expressions have to be on separate lines, generally at the end of the file for post-processing purposes. They are not interpreted by Dynare, and are simply passed on unmodified to MATLAB or Octave. Those constructions are not addresses in this section.. Expressions can be constructed using integers (INTEGER), floating point numbers (DOUBLE), parameter names (PARAMETER_NAME), variable names (VARIABLE_NAME), operators and functions. Parameters and variables Parameters and variables can be introduced in expressions by simply typing their names. The semantics of parameters and variables is quite different whether they are used inside or outside the model block. Inside the model Parameters used inside the model refer to the value given through parameter initialization or when doing a simulation, or are the estimated variables when doing an estimation. Variables used in a MODEL_EXPRESSION denote current period values when neither a lead or a lag is given. A lead or a lag can be given by enclosing an integer between parenthesis just after the variable name: a positive integer means a lead, a negative one means a lag. Leads or lags of more than one period are allowed. For example, if c is an endogenous variable, then c(+1) is the variable one period ahead, and c(-2) is the variable two periods before. When specifying the leads and lags of endogenous variables, it is important to respect the following convention: in Dynare, the timing of a variable reflects when that variable is decided. A control variable - which by definition is decided in the current period - must have no lead. A predetermined variable - which by definition has been decided in a previous period - must have a lag. A consequence of this is that all stock variables must use the "stock at the end of the period" convention. Please refer to for more details and concrete examples. Leads and lags are primarily used for endogenous variables, but can be used for exogenous variables. They have no effect on parameters and are forbidden for local model variables (see ). Outside the model When used in an expression outside the model block, a parameter or a variable simply refers to the last value given to that variable. More precisely, for a parameter it refers to the value given in the corresponding parameter initialization; for an endogenous or exogenous variable, it refers to the value given in the most recent or block. Operators The following operators are allowed in both MODEL_EXPRESSION and EXPRESSION: binary arithmetic operators: +, -, *, /, ^ unary arithmetic operators: +, - binary comparison operators (which evaluate to either 0 or 1): <, >, <=, >=, ==, != The following operators are allowed in MODEL_EXPRESSION: steady state operator: STEADY_STATE(MODEL_EXPRESSION). This operator is used to take the value of the enclosed expression at the steady state. A typical usage is in the Taylor rule, where you may want to use the value of GDP at steady state to compute the output gap. expectation operator: EXPECTATION(INTEGER)(MODEL_EXPRESSION). This operator is used to take the expectation of some expression using a different information set than the information available at current period. For example, EXPECTATION(-1)(x(+1)) is equal to the expected value of variable x at next period, using the information set available at the previous period. In practice, Dynare solves this by creating an auxiliary variable equal to AUX_EXPECT_LAG_1 = x(+2), and by replacing the expectation operator by AUX_EXPECT_LAG_1(-1). Note that a value of 0 for the time shift component is reserved for partial information models (not yet fully implemented). Functions Internal The following standard functions are supported internally for both MODEL_EXPRESSION and EXPRESSION: exponential: exp(x) natural logarithm: log(x) (or equivalently ln(x)) base 10 logarithm: log10(x) square root: sqrt(x) trigonometric functions: sin(x), cos(x), tan(x), asin(x), acos(x), atan(x) maximum and minimum: max(a, b), min(a, b) gaussian cumulative distribution function: normcdf(x, μ, σ) (note that normcdf(x) is equivalent to normcdf(x, 0, 1)) gaussian probability density function: normpdf(x, μ, σ) (note that normpdf(x) is equivalent to normpdf(x, 0, 1)) gauss error function: erf(x) External Any other user-defined (or built-in) MATLAB or Octave function may be used in both a MODEL_EXPRESSION and an EXPRESSION, provided that this function has a scalar argument as a return value. To use an external function in a MODEL_EXPRESSION, one must declare the function using the statement. This is not necessary for external functions used in an EXPRESSION. external_function external_function declares external functions external_function ( = NAME , OPTION = INTEGER , OPTION = NAME ); Options = NAME The name of the function, which must also be the name of the M-/MEX file implementing it. = INTEGER The number of arguments of the function. If this option is not provided, Dynare assumes = 1. [= NAME] If NAME is provided, this tells Dynare that the Jacobian is provided as the only output of the M-/MEX file given as the option argument. If NAME is not provided, this tells Dynare that the M-/MEX file specified by the argument passed to returns the Jacobian as its second output argument. [= NAME] If NAME is provided, this tells Dynare that the Hessian is provided as the only output of the M-/MEX file given as the option argument. If NAME is not provided, this tells Dynare that the M-/MEX file specified by the argument passed to returns the Hessian as its third output argument. NB: This option can only be used if the option is used in the same external_function command. Description This command declares the external functions used in the model block. It is required for every unique function used in the model block. external_function commands can appear several times in the file and must come before the model block. Example external_function(name = funcname); external_function(name = funcname, nargs = 2, first_deriv_provided, second_deriv_provided); external_function(name = funcname, nargs = 3, first_deriv_provided = funcname_deriv); Parameter initialization When using Dynare for computing simulations, it is necessary to calibrate the parameters of the model. This is done through parameter initialization. Syntax PARAMETER_NAME = EXPRESSION ; Example parameters alpha, bet; beta = 0.99; alpha = 0.36; A = 1-alpha*beta; Model declaration The model is declared inside a block. Note that it is possible to output the list of model equations to a LaTeX file, using the command, or the (for the steady state model). model model declares the model equations model (OPTION, OPTION) ; MODEL_EXPRESSION = MODEL_EXPRESSION ; MODEL_EXPRESSION ; # VARIABLE_NAME = MODEL_EXPRESSION ; end; Description The equations of the model are written in a block delimited by model and end keywords. There must be as many equations as there are endogenous variables in the model, except when computing the unconstrained optimal policy with . The syntax of equations must follow the conventions for MODEL_EXPRESSION as described in . Each equation must be terminated by a semicolon (;). 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. Inside the model block, Dynare allows the creation of model-local variables, which constitute a simple way to share a common expression between several equations. The syntax consists of a pound sign (#) followed by the name of the new model local variable (which must not be declared as in ), an equal sign, and the expression for which this new variable will stand. Later on, every time this variable appears in the model, Dynare will substitute it by the expression assigned to the variable. Note that the scope of this variable is restricted to the model block; it cannot be used outside. Options Declares the model as being linear. It spares oneself from having to declare initial values for computing the steady state, and it sets automatically =1 in . Instructs the preprocessor to create dynamic loadable libraries (DLL) containing the model equations and derivatives, instead of writing those in M-files. You need a working compilation environment, i.e. a working mex command (see for more details). Using this option can result in faster simulations or estimations, at the expense of some initial compilation time.In particular, for big models, the compilation step can be very time-consuming, and use of this option may be counter-productive in those cases. Perform the block decomposition of the model, and exploit it in computations. See Dynare wiki for details on the algorithm. Instead of M-files, use a bytecode representation of the model, i.e. a binary file containing a compact representation of all the equations. = DOUBLE Threshold under which a jacobian element is considered as null during the model normalization. Only available with option . Default: 1e-15 = INTEGER Controls the handling of minimum feedback set of endogenous variables. Only available with option . Possible values: 0: all the endogenous variables are considered as feedback variables (Default). 1: the endogenous variables assigned to equation naturally normalized (i.e. of the form x=f(Y) where x does not appear in Y) are potentially recursive variables. All the other variables are forced to belong to the set of feedback variables. 2: in addition of variables with mfs = 1 the endogenous variables related to linear equations which could be normalized are potential recursive variables. All the other variables are forced to belong to the set of feedback variables. 3: in addition of variables with mfs = 2 the endogenous variables related to non-linear equations which could be normalized are potential recursive variables. All the other variables are forced to belong to the set of feedback variables. Don't create the static model file. This can be useful for models which don't have a steady state. Examples Example 1: elementary RBC model var c k; varexo x; parameters aa alph bet delt gam; model; c = - k + aa*x*k(-1)^alph + (1-delt)*k(-1); c^(-gam) = (aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam)/(1+bet); end; Example 2: use of model local variables The following program: model; # gamma = 1 - 1/sigma; u1 = c1^gamma/gamma; u2 = c2^gamma/gamma; end; ...is formally equivalent to: model; u1 = c1^(1-1/sigma)/(1-1/sigma); u2 = c2^(1-1/sigma)/(1-1/sigma); end; Example 3: a linear model model(linear); x = a*x(-1)+b*y(+1)+e_x; y = d*y(-1)+e_y; end; write_latex_dynamic_model write_latex_dynamic_model create a LaTeX file containing the (dynamic) model write_latex_dynamic_model; Description If your .mod file is FILENAME.mod, then Dynare will create a file called FILENAME_dynamic.tex, containing the list of all the dynamic model equations. If LaTeX names were given for variables and parameters (see , , , ), then those will be used; otherwise, the plain text names will be used. Time subscripts (t, t+1, t-1, ...) will be appended to the variable names, as LaTeX subscripts. Note that the model written in the TeX file will differ from the model declared by the user in the following dimensions: the timing convention of will have been changed to the default Dynare timing convention; in other words, variables declared as predetermined will be lagged on period back, the expectation operators will have been removed, replaced by auxiliary variables and new equations as explained in the documentation of the operator, for stochastic models, variables with leads or lags greater or equal than two will have been removed, replaced by new auxiliary variables and equations. write_latex_static_model write_latex_static_model create a LaTeX file containing the (static) model write_latex_static_model; Description If your .mod file is FILENAME.mod, then Dynare will create a file called FILENAME_static.tex, containing the list of all the equations of the steady state model. If LaTeX names were given for variables and parameters (see , , , ), then those will be used; otherwise, the plain text names will be used. Note that the model written in the TeX file will differ from the model declared by the user in the some dimensions, see . Also note that this command will not output the contents of the optional block; it will rather output a static version (i.e. without leads and lags) of the dynamic model declared in the block. Initial and terminal conditions For most simulation exercises, it is necessary to provide initial (and possibly terminal) conditions. It is also necessary to provide initial guess values for non-linear solvers. The following statements are used for those purposes: In many contexts (determistic or stochastic), it is necessary to compute the steady state of a non-linear model: then specifies numerical initial values for the non-linear solver. The command can be used to compute the equation residuals for the given initial values. 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. 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 and (see . Another one is to study, how an economy, starting from arbitrary initial conditions converges toward equilibrium. To do that, one needs and ; For models with lags on more than one period, the command permits to specify different historical initial values for periods before the beginning of the simulation. initval initval specifies numerical starting values for finding the steady state and/or initial values for simulations initval; VARIABLE_NAME = EXPRESSION ; end; Description The initval block serves two purposes: declaring the initial (and possibly terminal) conditions in a simulation exercise, and providing guess values for non-linear solvers. In a deterministic (<foreignphrase>i.e.</foreignphrase> perfect foresight) model First, it provides the initial conditions for all the endogenous and exogenous variables at all the periods preceeding the first simulation period (unless some of these initial values are modified by ). Second, in the absence of an block, it sets the terminal conditions for all the periods succeeding the last simulation period. Third, in the absence of an block, it provides initial guess values at all simulation dates for the non-linear solver implemented in . For this last reason, it necessary to provide values for all the endogenous variables in an initval block (even though, theoretically, initial conditions are only necessary for lagged variables). If some exogenous variables are not mentionned in the initval block, a zero value is assumed. Note that if the initval block is immediately followed by a command, its semantics is changed. The command will compute the steady state of the model for all the endogenous variables, assuming that exogenous variables are kept constant to the value declared in the initval block, and using the values declared for the endogenous as initial guess values for the non-linear solver. An initval block followed by is formally equivalent to an initval block with the same values for the exogenous, and with the associated steady state values for the endogenous. In a stochastic model The main purpose of initval is to provide initial guess values for the non-linear solver in the steady state computation. Note that if the initval block is not followed by , the steady state computation will still be triggered by subsequent commands (, ...). It is not necessary to declare 0 as initial value for exogenous stochastic variables, since it is the only possible value. This steady state will be used as the initial condition at all the periods preceeding the first simulation period for the two possible types of simulations in stochastic mode: in , if the options is specified in (in this case, note that it is still possible to modify some of these initial values with ) Example initval; c = 1.2; k = 12; x = 1; end; steady; endval endval specifies terminal values for deterministic simulations endval; VARIABLE_NAME = EXPRESSION ; end; Description The endval block makes only sense in a determistic model, and serves two purposes. First, it sets the terminal conditions for all the periods succeeding the last simulation period. Second, it provides initial guess values at all the simulation dates for the non-linear solver implemented in . For this last reason, it necessary to provide values for all the endogenous variables in an endval block (even though, theoretically, initial conditions are only necessary for forward variables). If some exogenous variables are not mentionned in the endval block, a zero value is assumed. Note that if the endval block is immediately followed by a command, its semantics is changed. The command will compute the steady state of the model for all the endogenous variables, assuming that exogenous variables are kept constant to the value declared in the endval block, and using the values declared for the endogenous as initial guess values for the non-linear solver. An endval block followed by is formally equivalent to an endval block with the same values for the exogenous, and with the associated steady state values for the endogenous. Example var c k; varexo x; ... initval; c = 1.2; k = 12; x = 1; end; steady; endval; c = 2; k = 20; x = 2; end; steady; The initial equilibrium is computed by for x=1, and the terminal one, for x=2. histval histval specifies historical values before the start of a simulation histval; VARIABLE_NAME(INTEGER) = EXPRESSION ; end; Description EXPRESSION is any valid expression returning a numerical value and can contain already initialized variable names. In models with lags on more than one period, the optional histval; ... end; block permits to specify different historical initial values for different periods. 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. If your lagged variables are linked by identities, be careful to satisfy these identities when you set historical initial values. Example 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; resid resid display the residual of the static equations resid; Description This command will display the residuals of the static equations of the model, using the values given for the endogenous in the last or block (or the steady state file if you provided one). initval_file initval_file use an external to specify a path for exogenous and endogenous variables in a deterministic simulation initval_file( = FILENAME); Description In a deterministic setup, this command is used to specify a path for all endogenous and exogenous variables. The length of these paths must be equal to the number of simulation periods, plus the number of leads and the number of lags of the model (for example, with 50 simulation periods, in a model with 2 lags and 1 lead, the paths must have a length of 53). Note that these paths cover two different things: the constraints of the problem, which are given by the path for exogenous and the initial and terminal values for endogenous the initial guess for the non-linear solver, which is given by the path for endogenous variables for the simulation periods (excluding initial and terminal conditions) The command accepts three file formats: M-file (extension .m): for each endogenous and exogenous variable, the file must contain a row vector of the same name MAT-file (extension .mat): same as for M-files Excel file (extension .xls): for each endogenous and exogenous, the file must contain a column of the same name The extension must be omitted in the command argument. Dynare will automatically figure out the extension and select the appropriate file type. Shocks on exogenous variables 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 and . 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 . 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 command. Or, the entire matrix can be direclty entered with (this use is however deprecated). 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. (deprecated) shocks shocks specifies shocks on deterministic or stochastic exogenous variables shocks; DETERMINISTIC SHOCK STATEMENT STOCHASTIC SHOCK STATEMENT end; var VARIABLE_NAME; periods INTEGER:INTEGER, INTEGER:INTEGER; values EXPRESSION , EXPRESSION; var VARIABLE_NAME; stderr EXPRESSION; var VARIABLE_NAME = EXPRESSION; var VARIABLE_NAME, VARIABLE_NAME = EXPRESSION; corr VARIABLE_NAME, VARIABLE_NAME = EXPRESSION; Description In deterministic context For deterministic simulations, the shocks block specifies temporary changes in the value of an exogenous variables. For permanent shocks, use an block. When specifying shocks on several periods, the values EXPRESSION 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 periods statement just before it. Example 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; In stochastic context For stochastic simulations, the shocks block specifies the non zero elements of the covariance matrix of the shocks of exogenous variables. In an estimation context, it is also possible to specify variances and covariances on endogenous variables: in that case, these values are interpreted as the calibration of the measurement errors on these variables. Example shocks; var e = 0.000081; var u; stderr 0.009; corr e, u = 0.8; var v, w = 2; end; See also Mixing determininistic and stochastic shocks 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 will compute the rational expectation solution adding future information to the state space (nothing is shown in the output of ) and will compute a simulation conditional on initial conditions and future information. Example 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; mshocks mshocks specifies multiplicative deterministic shocks on exogenous variables mshocks; var VARIABLE_NAME; periods INTEGER:INTEGER , INTEGER:INTEGER; values EXPRESSION , EXPRESSION; end; Description The purpose of this command is similar to that of the for deterministic shocks, except that the numeric values given will be interpreted in a multiplicative way. For example, if a value of 1.05 is given as shock value for some exogenous at some date, it means 5% above its steady state value (as given by the last or block). This command is only meaningful in two situations: on exogenous variables with a non-zero steady state, in a deterministic setup, on deterministic exogenous variables with a non-zero steady state, in a stochastic setup. Sigma_e Sigma_e specifies directly the covariance matrix of the stochastic shocks Sigma_e = [ EXPRESSION , EXPRESSION ; EXPRESSION , EXPRESSION ]; The matrix elements are actually written between square brackets ([]). Here, the initial [ and final ] don't have the meaning of optional element as elsewhere. Description 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 arbitrary EXPRESSION is allowed (instead of a simple constant), but in that case you need to enclose the expression in parentheses. The order of the covariances in the matrix is the same as the one used in the declaration. Example varexo u, e; ... Sigma_e = [ 0.81 (phi*0.9*0.009); 0.000081]; where the variance of u is 0.81, the variance of e, 0.000081, and the correlation between e and u is phi. Other general declarations (deprecated) dsample dsample reduces the number of periods considered in subsequent output commands dsample INTEGER INTEGER; Description ... periods periods specifies the number of simulation periods periods INTEGER; Description 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 in and . Sets the number of periods in the simulation. The periods are numbered from 1 to INTEGER. In perfect foresight simulations, it is assumed that all future events are perfectly known at the beginning of period 1. Example periods 100; Solving and simulating Dynare has special commands for the computation of the static equilibrium of the model (), of the eigenvalues of the linearized model () for dynamics local analysis, of a deterministic simulation () and for solving and/or simulating a stochastic model (). steady steady computes the steady state of a model steady (OPTION, OPTION); Options = INTEGER Determines the non-linear solver to use. Possible values for the option are: 0: uses MATLAB Optimization Toolbox FSOLVE 1: uses Dynare's own nonlinear equation solver 2: splits the model into recursive blocks and solves each block in turn 3: Chris Sims' solver 4: similar to value 2, except that it deals differently with nearly singular Jacobian 5: Newton algorithm with a sparse Gaussian elimination (SPE) Default value is 2. = INTEGER Use a homotopy (or divide-and-conquer) technique to solve for the steady state (see for a short description of the technique). This option can take three possible values: 1: in this mode, all the parameters are changed simultaneously, and the distance between the boudaries for each parameter is divided in as many intervals as there are steps (as defined by option); the problem is solves as many times as there are steps 2: same as mode 1, except that only one parameter is changed at a time; the problem is solved as many times as steps times number of parameters 3: Dynare tries first the most extreme values. If it fails to compute the steady state, the interval between initial and desired values is divided by two for all parameters. Every time that it is impossible to find a steady state, the previous interval is divided by two. When it succeeds to find a steady state, the previous interval is multiplied by two. In that last case contains the maximum number of computations attempted before giving up. = INTEGER Defines the number of steps when performing a homotopy. See option for more details. Description Computes the equilibrium value of the endogenous variables for the value of the exogenous variables specified in the previous or block. steady uses an iterative procedure and takes as initial guess the value of the endogenous variables set in the previous or block. 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. If you know how to compute the steady state for your model, you can provide a MATLAB function doing the computation instead of using steady. The function should be called with the name of the .mod file followed by _steadystate. See fs2000a_steadystate.m in examples/fs2000 directory. Output variables The steady state is available in oo_.steady_state. Endogenous variables are ordered in order of declaration used in command as in M_.endo_names. Examples See and . homotopy_setup homotopy_setup declare initial and final values when using homotopy method homotopy_setup; VARIABLE_NAME, EXPRESSION, EXPRESSION; end; Description The idea of homotopy (also called divide-and-conquer by some authors) is to subdivide the problem of finding the steady state into smaller problems. It assumes that you know how to compute the steady state for a given set of parameters, and it helps you finding the steady state for another set of parameters, by incrementally moving from one to another set of parameters. The purpose of the homotopy_setup block is to declare the final (and possibly also the initial) values for the parameters or exogenous that will be changed during the homotopy. In the first syntax where only one value is specified for a given parameter/exogenous, then this value is interpreted as the final value, and the initial value is taken from the preceeding block. In the second syntax where two values are specified for a given parameter/exogenous, the first is the initial one, the second is the final one. A necessary condition for a successful homotopy is that Dynare must be able to solve the steady state for the initial parameters/exogenous without additional help (using the guess values given in the block). If the homotopy fails, a possible solution is to increase the number of steps (given in option of ). Example In the following example, Dynare will first compute the steady state for the initial values (gam=0.5 and x=1), and then subdivide the problem into 50 smaller problems to find the steady state for the final values (gam=2 and x=2). var c k; varexo x; parameters alph gam delt bet aa; alph=0.5; delt=0.02; aa=0.5; bet=0.05; model; c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); end; initval; x = 1; k = ((delt+bet)/(aa*x*alph))^(1/(alph-1)); c = aa*x*k^alph-delt*k; end; homotopy_setup; gam, 0.5, 2; x, 2; end; steady(homotopy_mode = 1, homotopy_steps = 50); steady_state_model steady_state_model declares the solution of the static model, when analytically known steady_state_model ; VARIABLE_NAME = EXPRESSION ; end; Description When the analytical solution of the model is known, this command can be used to help Dynare find the steady state in a more efficient and reliable way, especially during estimation where the steady state has to be recomputed for every point in the parameter space. Each line of this block consists of a variable (either an endogenous, a temporary variable or a parameter) which is assigned an expression (which can contain parameters, exogenous at the steady state, or any endogenous or temporary variable already declared above). Internally, Dynare will create a steady state file called FILENAME_steadystate.m, using the information provided in this block. Example var m P c e W R k d n l gy_obs gp_obs y dA; varexo e_a e_m; parameters alp bet gam mst rho psi del; ... // parameter calibration, (dynamic) model declaration, shock calibration... ... steady_state_model; dA = exp(gam); gst = 1/dA; // A temporary variable m = mst; // Three other temporary variables khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1)); xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1); nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp ); n = xist/(nust+xist); P = xist + nust; k = khst*n; l = psi*mst*n/( (1-psi)*(1-n) ); c = mst/P; d = l - mst + 1; y = k^alp*n^(1-alp)*gst^alp; R = mst/bet; W = l/n; e = 1; gp_obs = m/dA; gy_obs = dA; end; steady; check check computes the eigenvalues of the (linearized) model check ( = INTEGER); Options = INTEGER See there for the possible values and their meaning Description Computes the eigenvalues of the model linearized around the values specified by the last , or statement. Generally, the eigenvalues are only meaningful 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. 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. Output variables check returns the eigenvalues in the global variable oo_.dr.eigval. model_info model_info Display the block structure of the model model_info ; Description The model_info command provides information about: the normalization of the model: an endogenous variable is attributed to each equation of the model; the block structure of the model: for each block model_info indicates its type, the equations number and endogenous variables belonging to this block. There are five different types of blocks depending on the simulation method used: EVALUATE FORWARD: in this case the block contains only equations where endogenous variable attributed to the equation appears currently on the left hand side and where no forward looking endogenous variables appear. yj,t = fj(yt, yt-1, ..., yt-k) EVALUATE BACKWARD: the block contains only equations where endogenous variable attributed to the equation appears currently on the left hand side and where no backward looking endogenous variables appear. yj,t = fj(yt, yt+1, ..., yt+k) SOLVE FORWARD x: the block contains only equations where endogenous variable attributed to the equation does not appear currently on the left hand side and where no forward looking endogenous variables appear. gj(yj,t, yt, yt-1, ..., yt-k) =0. x is equal to SIMPLE if the block has only one equation. If several equation appears in the block, x is equal to COMPLETE. SOLVE FORWARD x: the block contains only equations where endogenous variable attributed to the equation does not appear currently on the left hand side and where no backward looking endogenous variables appear. gj(yj,t, yt, yt+1, ..., yt+k) =0. x is equal to SIMPLE if the block has only one equation. If several equation appears in the block, x is equal to COMPLETE. SOLVE TWO BOUNDARIES x: the block contains equations depending on both forward and backward variables. gj(yj,t, yt, yt-1, ..., yt-k ,yt, yt+1, ..., yt+k) =0. x is equal to SIMPLE if the block has only one equation. If several equation appears in the block, x is equal to COMPLETE. simul simul simulates a deterministic model simul (OPTION, OPTION) ; Description Triggers the computation of a deterministic simulation of the model for the number of periods set in the option . simul uses a Options = INTEGER Number of periods of the simulation = INTEGER Algorithm used for computing the solution. Possible values are: 0: Newton method to solve simultaneously all the equations for every period, see . (Default) 1: use a Newton algorithm with a sparse LU solver at each iteration. 2: use a Newton algorithm with a Generalized Minimal Residual (GMRES) solver at each iteration. This option is not available under Octave. 3: use a Newton algorithm with a Stabilized Bi-Conjugate Gradient (BICGSTAB) solver at each iteration. 4: use a Newton algorithm with a optimal path length at each iteration. 5: use a Newton algorithm with a sparse Gaussian elimination (SPE) solver at each iteration. = DOUBLE Value of the Markowitz criterion, used to select the pivot. Only used when = 5. Default: 0.5 = INTEGER Specify the minimal number of periods where the model has to be solved, before using a constant set of operations for the remaining periods. Only used when = 5. Default: 1 = FILENAME If the variables of the model are not constant over time, their initial values, stored in a text file, could be loaded, using that option, as initial values before a deteministic simulation. Output variables The simulated endogenous variables are available in global matrix oo_.endo_simul. The variables are arranged row by row, in order of declaration (as in M_.endo_names). Note that this variable also contains initial and terminal conditions, so it has more columns than the value of option. stoch_simul stoch_simul computes the solution and simulates the model stoch_simul (OPTION, OPTION) VARIABLE_NAME; Options = INTEGER Order of autocorrelation coefficients to compute and to print. Default: 5 = INTEGER Number of points dropped at the beginning of simulation before computing the summary statistics. Default: 100 = INTEGER Uses HP filter with λ = INTEGER before computing moments. Note that this option is currently not available when computing empirical moments (see option). Default: no filter = INTEGER Number of points in the grid for the discrete Inverse Fast Fourier Transform used in the HP filter computation. It may be necessary to increase it for highly autocorrelated processes. Default: 512 = INTEGER Number of periods on which to compute the IRFs. Setting =0, suppresses the plotting of IRF's. Default: 40 Requests the computation of normalized IRFs in percentage of the standard error of each shock Indicates that the original model is linear (put it rather in the command) Don't print the correlation matrix (printing them is the default) Don't print the coefficients of the approximated solution (printing them is the default) Don't print moments of the endogenous variables (printing them is the default) Doesn't do the graphs. Useful for loops Don't print anything. Useful for loops Print results (opposite of the above) Order of Taylor approximation. Acceptable values are 1, 2 and 3. Note that for third order, option is implied, and only empirical moments are available (you must provide a value for option). Default: 2 Use a k-order solver, implemented in C++, instead of the default Dynare solver. When using this option, you must specify the option, and you need a working compilation environment, i.e. a working mex command (see for more details). Default: disabled for order 1 and 2, enabled otherwise = INTEGER If different from zero, empirical moments will be computed instead of theoretical moments. The value of the option specifies the number of periods to use in the simulations. Values of the block, possibly recomputed by , will be used as starting point for the simulation. The simulated endogenous variables are made available to the user in a vector for each variable and in the global matrix oo_.endo_simul. The variables in the oo_.endo_simul matrix, in their order of declaration (as in M_.endo_names) Default: 0 = DOUBLE Value used to split stable from unstable eigenvalues in reordering the Generalized Schur decomposition used for solving 1st order problems. Default: 1.000001 = INTEGER Number of simulated series used to compute the IRFs. Default: 1 if =1, and 50 otherwise = INTEGER 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 = INTEGER Obsolete. Use only the default = 0 = INTEGER See there for the possible values and their meaning Use the Anderson-Moore Algorithm (AIM) to compute the decision rules, instead of using Dynare's default method based on a generalized Schur decomposition. This option is only valid for first order approximation. See AIM website for more details on the algorithm. = INTEGER See below = [INTEGER1:INTEGER2] See below = [INTEGER1 INTEGER2 ...] Computes a conditional variance decomposition for the specified period(s). Conditional variances are given by var(yt+k|t). For period 1, the conditional variance decomposition provides the decomposition of the effects of shocks upon impact. Discard higher order terms when iteratively computing simulations of the solution, as in . Description stoch_simul 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 command. 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 MATLAB function doing the computation instead of using the nonlinear solver. The function should be called with the name of the .mod file followed by _steadystate. See fs2000a_steadystate.m in examples/fs2000 directory. 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. Variance decomposition, correlation, autocorrelation are only displayed for variables with positive variance. Impulse response functions are only plotted for variables with response larger than 10-10. Variance decomposition is computed relative to the sum of the contribution of each shock. Normally, this is of course equal to aggregate variance, but if a model generates very large variances, it may happen that, due to numerical error, the two differ by a significant amount. Dynare issues a warning if the maximum relative difference between the sum of the contribution of each shock and aggregate variance is larger than 0.01 %. Currently, the IRFs are only plotted for 12 variables. Select the ones you want to see, if your model contains more than 12 endogenous variables. Currently, the HP filter is only available when computing theoretical moments, not for for moments of simulated variables. The covariance matrix of the shocks is specified either with the command or with the command. When a list of VARIABLE_NAME is specified, results are displayed only for these variables. Auxiliary variables for leads and lags 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. This transformation is achieved by the creation of auxiliary variables, and corresponding equations. For example, if x(+2) exists in the model, Dynare will create one auxiliary variable AUX_ENDO_LEAD = x(+1), and replace x(+2) by AUX_ENDO_LEAD(+1). A similar transformation is done for lags greater than 2 on endogenous (auxiliary variables will have a name beginning with AUX_ENDO_LAG), and for exogenous with leads and lags (auxiliary variables will have a name beginning with AUX_EXO_LEAG or AUX_EXO_LAG respectively). 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. Decision rules 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. First order approximation
yt = ys + A yht-1 + B ut where ys is the steady state value of y and yht=yt-ys.
Second order approximation
yt = ys + 0.5Δ2 + A yht-1 + B ut + 0.5C(yht-1⊗yht-1) + 0.5D(ut⊗ut) + E(yht-1⊗ut) where ys is the steady state value of y, yht=yt-ys, and Δ2 is the shift effect of the variance of future shocks.
Output variables stoch_simul sets several fields in global variable oo_. The descriptive statistics are theoretical moments when no simulation is requested and otherwise represent the moments of the simulated variables. the coefficients of the decision rules are stored in global structure oo_.dr. Here is the correspondance with the symbols used in the above description of the decision rules: Decision rule coefficients ys: oo_.dr.ys. The vector rows correspond to variables in the declaration order of the variable names. Δ2: oo_.dr.ghs2. The vector rows correspond to re-ordered variables (see below). A: oo_.dr.ghx. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to state variables (see below). B: oo_.dr.ghu. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to exogenous variables in declaration order. C: oo_.dr.ghxx. 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). D: oo_.dr.ghuu. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to the Kronecker product of exogenous variables in declaration order. E: oo_.dr.ghxu. 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. 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 oo_.dr.order_var maps reordered variables to declaration order, and variable oo_.dr.inv_order_var contains the inverse map. In other words, the first row in transition matrices corresponds to the endogenous declared at position oo_.dr_order_var(1); conversely, first declared variable has row oo_.dr.inv_order_var(1) in transition matrices. 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. The mean of the endogenous variables is available in the vector oo_.mean. The variables are arranged in declaration order. The matrix of variance-covariance of the endogenous variables in the matrix oo_.var. The variables are arranged in declaration order. The matrix of autocorrelation of the endogenous variables are made available in cell array oo_.autocorr. The element number of the matrix in the cell array corresponds to the order of autocorrelation. The option specifies the number of autocorrelation matrices available. Simulated variables, when they have been computed, are available in MATLAB vectors with the same name as the endogenous variables. They are also available in the oo_.endo_simul matrix. The series are arranged by row, in declaration order of the variable names Impulse responses, when they have been computed, are available in oo_.irfs, with the following naming convention: VARIABLE_NAME_SHOCK_NAME. (DEPRECATED) They are currently also available in MATLAB vectors in the global workspace, however they will disappear there in a future version. Example: oo_.irfs.gnp_ea contains the effect on gnp of a one standard deviation shock on ea. Examples Example 1 shocks; var e; stderr 0.0348; end; stoch_simul; Performs the simulation of the 2nd order approximation of a model with a single stochastic shock e, with a standard error of 0.0348. Example 2 stoch_simul(linear,irf=60) y k; Performs the simulation of a linear model and displays impulse response functions on 60 periods for variables y and k.
Estimation 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. 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. (deprecated) varobs varobs lists the observed variables varobs VARIABLE_NAME ; Description varobs lists the name of observed endogenous variables for the estimation procedure. These variables must be available in the data file (see ). Only one instance of varobs is allowed in a model file. If one needs to declare observed variables in a loop, the macroprocessor can be used as shown in the second example below. Examples Simple example varobs C y rr; In a loop varobs @#for co in countries GDP_@{co} @#endfor ; observation_trends observation_trends specifies linear trends for observed variables observation_trends; VARIABLE_NAME(EXPRESSION); end; Description observation_trends specifies trends for observed variables as functions of model parameters. In most cases, variables shouldn't be centered when observation_trends is used. Example observation_trends; Y (eta); P (mu/eta); end; estimated_params estimated_params specifies the estimated parameters and their prior Syntax I (Maximum likelihood estimation) estimated_params; VARIABLE_NAME VARIABLE_NAME_1, VARIABLE_NAME_2 PARAMETER_NAME , INITIAL_VALUE , LOWER_BOUND , UPPER_BOUND ; end; Syntax II (Bayesian estimation) estimated_params; VARIABLE_NAME VARIABLE_NAME_1, VARIABLE_NAME_2 PARAMETER_NAME , INITIAL_VALUE , LOWER_BOUND , UPPER_BOUND , PRIOR_SHAPE , PRIOR_MEAN , PRIOR_STANDARD_ERROR , PRIOR_3RD_PARAMETER , PRIOR_4TH_PARAMETER , SCALE_PARAMETER ; end; Description The estimated_params block lists all parameters to be estimated and specifies bounds and priors as necessary. Estimated parameter specification Each line corresponds to an estimated parameter and follows this syntax: VARIABLE_NAME Indicates that the standard error of the exogenous variable VARIABLE_NAME, or of the observation error associated with endogenous observed variable VARIABLE_NAME, is to be estimated VARIABLE_NAME_1, VARIABLE_NAME_2 Indicates that the correlation between the exogenous variables VARIABLE_NAME_1 and VARIABLE_NAME_2, or the correlation of the observation errors associated with endogenous observed variables VARIABLE_NAME_1 and VARIABLE_NAME_2, is to be estimated PARAMETER_NAME The name of a model parameter to be estimated INITIAL_VALUE Specifies a starting value for maximum likelihood estimation LOWER_BOUND Specifies a lower bound for the parameter value in maximum likelihood estimation UPPER_BOUND Specifies an upper bound for the parameter value in maximum likelihood estimation PRIOR_SHAPE A keyword specifying the shape of the prior density. See the list of possible values. Note that is equivalent to PRIOR_MEAN The mean of the prior distribution PRIOR_STANDARD_ERROR The standard error of the prior distribution PRIOR_3RD_PARAMETER A third parameter of the prior used for generalized beta distribution, generalized gamma and for the uniform distribution. Default: 0 PRIOR_4TH_PARAMETER A fourth parameter of the prior used for generalized beta distribution and for the uniform distribution. Default: 1 SCALE_PARAMETER The scale parameter to be used for the jump distribution of the Metropolis-Hasting algorithm INITIAL_VALUE, LOWER_BOUND, UPPER_BOUND, PRIOR_MEAN, PRIOR_STANDARD_ERROR, PRIOR_3RD_PARAMETER, PRIOR_4TH_PARAMETER and SCALE_PARAMETER can be any valid EXPRESSION. Some of them can be empty, in which Dynare will select a default value depending on the context and the prior shape. At minimum, one must specify the name of the parameter and an initial guess. That will trigger unconstrained maximum likelihood estimation. As one uses options more towards the end of the list, all previous options must be filled: for example, if you want to specify SCALE_PARAMETER, you must specify PRIOR_3RD_PARAMETER and PRIOR_4TH_PARAMETER. Use empty values, if these parameters don't apply. Parameter transformation 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. In such a case, it is possible to declare the parameter to be estimated in the statement and to define the transformation, using a pound sign (#) expression (see ). Example parameters bet; model; # sig = 1/bet; c = sig*c(+1)*mpk; end; estimated_params; bet, normal_pdf, 1, 0.05; end; estimated_params_init estimated_params_init specifies initial values for optimization estimated_params_init; VARIABLE_NAME VARIABLE_NAME_1, VARIABLE_NAME_2 PARAMETER_NAME , INITIAL_VALUE ; end; Description The estimated_params_init block declares numerical initial values for the optimizer when these ones are different from the prior mean. Estimated parameter initial value specification See for the meaning and syntax of the various components. estimated_params_bounds estimated_params_bounds specifies lower and upper bounds for the estimated parameters estimated_params_bounds; VARIABLE_NAME VARIABLE_NAME_1, VARIABLE_NAME_2 PARAMETER_NAME , LOWER_BOUND , UPPER_BOUND ; end; Description The estimated_params_bounds block declares lower and upper bounds for parameters in maximum likelihood estimation. Estimated parameter bounds specification See for the meaning and syntax of the various components. estimation estimation computes estimation estimation (OPTION, OPTION) VARIABLE_NAME; Options = FILENAME The datafile (a .m file, a .mat file or a .xls file) = NAME The name of the sheet with the data in an Excel file = RANGE The range with the data in an Excel file = INTEGER The number of observations to be used. Default: all observations in the file = [INTEGER_1:INTEGER_2] Runs a recursive estimation and forecast for samples of size ranging of INTEGER_1 to INTEGER_2. Option must also be specified = INTEGER The number of the first observation to be used. Default: 1 = INTEGER A value of 1 means that the estimation procedure will demean the data. Default: 0, i.e. no prefiltering = INTEGER The number of observations to be skipped before evaluating the likelihood. Default: 0 Computes a log--linear approximation of the model instead of a linear approximation. The data must correspond to the definition of the variables used in the model. Default: computes a linear approximation No graphs should be plotted = INTEGER Type of initialization of Kalman filter: 1: for stationary models, the initial matrix of variance of the error of forecast is set equal to the unconditional variance of the state variables 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 Default value is 1. = INTEGER ... = DOUBLE See there = INTEGER Number of replications for Metropolis-Hastings algorithm. For the time being, should be larger than 1200. Default: 20000 = INTEGER Number of parallel chains for Metropolis-Hastings algorithm. Default: 2 = DOUBLE The fraction of initially generated parameter vectors to be dropped before using posterior simulations. Default: 0.5 = DOUBLE The scale to be used for the jumping distribution in Metropolis-Hastings algorithm. The default value is rarely satisfactory. This option must be tuned to obtain, ideally, an acceptation rate of 25% in the Metropolis-Hastings algorithm. Default: 0.2 = DOUBLE The scale to be used for drawing the initial value of the Metropolis-Hastings chain. Default: 2* Attempts to recover a Metropolis-Hastings simulation that crashed prematurely. Shouldn't be used together with = INTEGER ... = FILENAME Name of the file containing previous value for the mode. When computing the mode, Dynare stores the mode (xparam1) and the hessian (hh) in a file called MODEL_FILENAME_mode.mat = INTEGER | FUNCTION_NAME Specifies the optimizer for the mode computation: 0: the mode isn't computed. option must be specified 1: uses MATLAB's fmincon 2: value no longer used 3: uses MATLAB's fminunc 4: uses Chris Sims's csminwel 5: uses Marco Ratto's newrat 6: uses a Monte-Carlo based optimization routine (see Dynare wiki for more details) 7: uses MATLAB's fminsearch (a simplex based routine) It is also possible to give a FUNCTION_NAME to this option, instead of an INTEGER. In that case, Dynare takes the return value of that function as the posterior mode. Default value is 4. Tells Dynare to plot the posterior density for values around the computed mode for each estimated parameter in turn. This is helpful to diagnose problems with the optimizer = DOUBLE Probability of extreme values of the prior density that is ignored when computing bounds for the parameters. Default: 1e-32 Tells Dynare to add to previous Metropolis-Hastings simulations instead of starting from scratch. Shouldn't be used together with = (fmincon options) Can be used to set options for fmincon, the optimizing function of MATLAB Optimizaiton toolbox. Use MATLAB's syntax for these options. Default: ('display','iter','LargeScale','off','MaxFunEvals',100000,'TolFun',1e-8,'TolX',1e-6) Doesn't compute the convergence diagnostics for Metropolis-Hastings. Default: diagnostics are computed and displayed Triggers the computation of the posterior distribution of IRFs. The length of the IRFs are controlled by the option Triggers the estimation of a DSGE-VAR model, where the weight of the DSGE prior of the VAR model will be estimated. The prior on the weight of the DSGE prior, dsge_prior_weight, must be defined in the estimated_params section. NB: The previous method of declaring dsge_prior_weight as a parameter and then placing it in estimated_params is now deprecated and will be removed in a future release of Dynare. = DOUBLE Triggers the estimation of a DSGE-VAR model, where the weight of the DSGE prior of the VAR model is calibrated to the value passed. NB: The previous method of declaring dsge_prior_weight as a parameter and then calibrating it is now deprecated and will be removed in a future release of Dynare. = INTEGER The number of lags used to estimate a DSGE-VAR model. Default: 4. Triggers the computation of the posterior distribution of the theoretical moments of the endogenous variables Triggers the computation of the posterior distribution of filtered endogenous variables and shocks Triggers the computation of the posterior distribution of smoothered endogenous variables and shocks = INTEGER Computes the posterior distribution of a forecast on INTEGER periods after the end of the sample used in estimation Requests the printing of results and graphs in TeX tables and graphics that can be later directly included in LaTeX files (not yet implemented) = INTEGER ... = INTEGER ... Saves the series of one step ahead error of forecast covariance matrices. = [INTEGER_1:INTEGER_2] Triggers the computation k-step ahead filtered values. Triggers the computation of the shock decomposition of the above k-step ahead filtered values. ... ... ... Only run the smoother on the variables listed just after the estimation command. Default: run the smoother on all the declared endogenous variables. = INTEGER See there = INTEGER See there = INTEGER See there See there If no parameter is used in estimated_params, the procedure uses for all parameters. If option isn't set, the procedure uses 0.2 for all parameters. Results results from posterior optimization (also for maximum likelihood) marginal log density mean and shortest confidence interval from posterior simulation Metropolis-Hastings convergence graphs that still need to be documented graphs with prior, posterior and mode graphs of smoothed shocks, smoothed observation errors, smoothed and historical variables Output After running estimation, 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. After estimation with Metropolis iterations (option > 0 or option set) the parameters and the variance matrix of the shocks are set to the posterior mean. Depending on the options, estimation stores results in the following fields of structure oo_: Content of <varname>oo_</varname> Field 1Field 2Field 3Field 4Field 5Required optionsForecastSee Variable nameMarginalDensityLaplaceApproximationAlways providedModifiedHarmonicMean> 0 or PosteriorFilteredVariablesSee Variable namePosteriorIRFDsgeSee IRF name: name of endogenous variable '_' name of shockPosteriorSmoothedObservationErrorsSee Variable namePosteriorSmoothedShocksSee Variable namePosteriorSmoothedVariablesSee Variable namePosteriorTheoreticalMomentsSee See See Variable nameposterior_densityParameter name> 0 or posterior_hpdinfSee Variable name> 0 or posterior_hpdsupSee Variable name> 0 or posterior_meanSee Variable name> 0 or posterior_modeSee Variable name> 0 or posterior_stdSee Variable name> 0 or
Moments of forecasts Field nameDescriptionHPDinfLower bound of a 90% HPD intervalSee option to change the size of the HPD interval of forecast due to parameter uncertaintyHPDsupLower bound of a 90% HPD interval due to parameter uncertaintyHPDTotalinfLower bound of a 90% HPD interval of forecast due to parameter uncertainty and future shocksHPDTotalsupLower bound of a 90% HPD interval due to parameter uncertainty and future shocksMeanMean of the posterior distribution of forecastsMedianMedian of the posterior distribution of forecastsStd Standard deviation of the posterior distribution of forecasts
Moments Names Field nameDescriptionHPDinfLower bound of a 90% HPD intervalSee option to change the size of the HPD intervalHPDsupUpper bound of a 90% HPD interval MeanMean of the posterior distributionMedianMedian of the posterior distributionStd Standard deviation of the posterior distribution
Theoretical Moments Field nameDescriptionAutocorrelationAutocorrelation of endogenous variablesThe autocorrlation coefficients are computed for the number of periods specified in option .CorrelationCorrelation between two endogenous variablesDecompDecomposition of varianceWhen the shocks are correlated, it is the decomposition of orthogonalized shocks via Cholesky decompostion according to the order of declaration of shocks (see ). ExpectationExpectation of endogenous variablesVariance(co-)variance of endogenous variables
Estimated objects Field nameDescriptionmeasurement_errors_corrCorrelation between two measurement errorsmeasurement_errors_stdStandard deviation of measurement errorsparametersParametersshocks_corrCorrelation between two structural shocksshocks_stdStandard deviation of structural shocks
Examples oo_.posterior_mode.parameters.alp oo_.posterior_mean.shocks_std.ex oo_.posterior_hpdsup.measurement_errors_corr.gdp_conso
Note on steady state computation If you know how to compute the steady state for your model, you can provide a MATLAB function doing the computation instead of using steady. The function should be called with the name of the .mod file followed by _steadystate. See fs2000a_steadystate.m in examples/fs2000 directory.
model_comparison model_comparison Bayesian model comparison model_comparison ( = laplacemodifiedharmonicmean) FILENAME(DOUBLE) , FILENAME(DOUBLE) ; Description This function computes odds ratios and estimate a posterior density over a colletion of models. The priors over models can be specified as the DOUBLE values, otherwise a uniform prior is assumed. shock_decomposition shock_decomposition computes and displays shock decomposition according to the model for a given sample shock_decomposition (OPTION, OPTION); Options = PARAMETER_NAME ... = [ [VARIABLE_NAME ...] ; ...] ... = [VARIABLE_NAME ...] ... Description ... unit_root_vars unit_root_vars declares unit-root variables for estimation unit_root_vars VARIABLE_NAME , VARIABLE_NAME ; Description unit_root_vars is now deprecated and will result in no action, It was 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 and . When unit_root_vars is used the option of has no effect. 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 .mod file followed by _steadystate. See fs2000a_steadystate.m in examples/fs2000 directory. Note that the nonstationary variables in the model must be integrated processes(their first difference or k-difference must be stationary).
Forecasting On a calibrated model, forecasting is done using the command. On an estimated command, use the option of command. It is also possible to compute forecasts on a calibrated or estimated model for a given constrained path of the future endogenous variables. This is done, from the reduced form representation of the DSGE model, by finding the structural shocks that are needed to match the restricted paths. Use , and for that purpose. forecast forecast computes a simulation of a stochastic model from a given state forecast (OPTION, OPTION) VARIABLE_NAME , VARIABLE_NAME; Options = INTEGER Number of periods of the forecast. Default: 40 = DOUBLE Level of significance for confidence interval. Default: 0.90 Don't display graphics. Description forecast computes a simulation of a stochastic model from an arbitrary initial point. 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. forecast must be called after . forecast plots the trajectory of endogenous variables. When a list of variable names follows the command, only those variables are plotted. A 90% confidence interval is plotted around the mean trajectory. Use option to change the level of the confidence interval. Output variables The following variables are set in structure oo_: oo_.forecast.Mean.VARIABLE_NAME: mean forecast of endogenous variables oo_.forecast.HPDinf.VARIABLE_NAME: lower bound of a confidence interval around the forecast oo_.forecast.HPDsup.VARIABLE_NAME: upper bound of a confidence interval around the forecast oo_.forecast.Exogenous.VARIABLE_NAME: trajectory of the deterministic exogenous variables Example 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; conditional_forecast conditional_forecast computes a simulation of a stochastic model conditionally to a specified future path for some endogenous variables. conditional_forecast (OPTION, OPTION) VARIABLE_NAME , VARIABLE_NAME; Options = | | | | Specify the parameter set to use for the forecasting. No default value, mandatory option. = (VARIABLE_NAME [ [,] VARIABLE_NAME ... ] ) Specify the exogenous variables to use as control variables. No default value, mandatory option. = INTEGER Number of periods of the forecast. Default: 40. cannot be less than the number of constrained periods. = INTEGER Number of simulations. Default: 5000. = DOUBLE Level of significance for confidence interval. Default: 0.80 Description conditional_forecast computes forecasts on an estimated model for a given constrained path of some future endogenous variables. This is done, from the reduced form representation of the DSGE model, by finding the structural shocks that are needed to match the restricted paths. This command has to be called after estimation. Use to give the list of constrained endogenous, and their constrained future path. Option is used to specify the structural shocks which will be matched to generate the constrained path. Use to graph the results. Example var y a varexo e u; ... estimation(...); conditional_forecast_paths; var y; periods 1:3, 4:5; values 2, 5; var a; periods 1:5; values 3; end; conditional_forecast(parameter_set = calibration, controlled_varexo = (e, u), replic = 3000); plot_conditional_forecast(periods = 10) e u; conditional_forecast_paths conditional_forecast_paths in a conditional forecast, gives the list of constrained endogenous and their path conditional_forecast_paths; var VARIABLE_NAME; periods INTEGER:INTEGER, INTEGER:INTEGER; values EXPRESSION , EXPRESSION; end; Description Describes the path of constrained endogenous, before calling . The syntax is similar to deterministic shocks in , see for an example. plot_conditional_forecast plot_conditional_forecast plots the conditional forecasts plot_conditional_forecast ( = INTEGER); Options = INTEGER Number of periods to be plotted. Default: equal to in conditional_forecast. The number of periods declared in plot_conditional_forecast cannot be greater than the one declared in conditional_forecast. Description To be used after . Optimal policy Dynare has tools to compute optimal policies for quadratic objectives. You can either solve for optimal policy under commitment with planner_objective or for optimal simple rule with . optim_weights optim_weights specifies quadratic objectives for optimal policy problems optim_weights; VARIABLE_NAME EXPRESSION; VARIABLE_NAME, VARIABLE_NAME EXPRESSION; end; Description optim_weights secifies the nonzero elements of the quadratic weight matrices for the objectives in . osr osr computes optimal simple policy rules osr (OPTION, OPTION) VARIABLE_NAME; Options All options for . Description osr computes optimal simple policy rules for linear--quadratic problems of the form:
maxγ E(y'tWyt) s.t. A1Et(yt+1)+A2yt+A3yt-1+Cet=0
with: γ: parameters to be optimized. They must be elements of matrices A1, A2, A3. y: endogenous variables e: exogenous stochastic shocks The parameters to be optimized must be listed with . The quadratic objectives must be listed with . This problem is solved using a numerical optimizer.
osr_params osr_params declares the parameters to be optimized for optimal simple rules osr_params PARAMETER_NAME PARAMETER_NAME ; Description osr_params declares parameters to be optimized by . planner_objective planner_objective declares the policy maker objective, for use with planner_objective MODEL_EXPRESSION ; Description ... ramsey_policy ramsey_policy computes the first order approximation of the policy that maximizes the policy maker objective function (see ) submitted to the constraints provided by the equilibrium path of the economy ramsey_policy (OPTION, OPTION) VARIABLE_NAME; Options All options for , plus: = DOUBLE Declares the discount factor of the central planner. Default: 1.0 Note that only first order approximation is available (i.e. order=1 must be specified). Output variables This command generates all the output variables of . In addition, it stores the value of planner objective function under Ramsey policy in oo_.planner_objective_value.
Sensitivity and identification analysis dynare_sensitivity dynare_sensitivity interface to the global sensitivity analysis (GSA) toolbox dynare_sensitivity (OPTION, OPTION) ; Description This function is an interface to the global sensitivity analysis (GSA) toolbox developed by the Joint Research Center (JRC) of the European Commission. The GSA toolbox needs to be downloaded separately from the JRC web site. Options Please refer to the documentation of the GSA toolbox on the official website. identification identification triggers identification analysis identification (OPTION, OPTION) ; Options = INTEGER Number of lags of computed autocorrelations (theoretical moments). Default: 3 = INTEGER If equal to 1, compute derivatives of autocorrelation. If equal to 0, compute derivatives of autocovariances. Default: 1 = INTEGER If equal to 1, allow Dynare to load previously computed analyzes. Default: 0 = INTEGER Size of Monte Carlo sample. Default: 2000 Displaying and saving results Dynare has comments to plot the results of a simulation and to save the results. rplot rplot plot variables rplot VARIABLE_NAME VARIABLE_NAME ; Description Plots the simulated path of one or several variables. dynatype dynatype print simulated variables dynatype (FILENAME) VARIABLE_NAME ; Description dynatype prints the listed variables in a text file named FILENAME. If no VARIABLE_NAME is listed, all endogenous variables are printed. dynasave dynasave save simulated variables in a binary file dynasave (FILENAME) VARIABLE_NAME ; Description dynasave saves the listed variables in a binary file named FILENAME. If no VARIABLE_NAME are listed, all endogenous variables are saved. In MATLAB, variables saved with the dynasave command can be retrieved by the MATLAB command load -mat FILENAME. Macro-processing language It is possible to use "macro" commands in the .mod file for doing the following tasks: source file inclusion, replicating blocks of equations through loops, conditional inclusion of code... Technically, this macro language is totally independent of the basic Dynare language, and is processed by a separate component of the Dynare pre-processor. The macro processor transforms a .mod file with macros into a .mod file without macros (doing expansions/inclusions), and then feeds it to the Dynare parser. @#include @#include includes another file Description ... @#define @#define defines a macro-variable Description ... @#if ... @#else ... @#endif @#if ... @#else ... @#endif conditional inclusion of some part of the .mod file Description ... @#for ... @#endfor @#for ... @#endfor loop for replications of portions of the .mod file Description ... @#echo @#echo asks the preprocessor to display some message on standard output Description ... @#error @#error asks the preprocessor to display some error message on standard output and to abort Description ... Misc commands save_params_and_steady_state save_params_and_steady_state saves the values of the parameters and of the computed steady-state in a file save_params_and_steady_state FILENAME ; Description For all parameters, endogenous and exogenous variables, stores their value in a text file, using a simple name/value associative table. for parameters, the value is taken from the last parameter initialization for exogenous, the value is taken from the last initval block for endogenous, the value is taken from the last steady state computation (or, if no steady state has been computed, from the last initval block) Note that no variable type is stored in the file, so that the values can be reloaded (with ) in a setup where the variable types are different. The typical usage of this function is to compute the steady-state of a model by calibrating the steady-state value of some endogenous variables (which implies that some parameters must be endogeneized during the steady-state computation). You would then write a first .mod file which computes the steady state and saves the result of the computation at the end of the file, using save_params_and_steady_state. In a second file designed to perform the actual simulations, you would use just after your variable declarations, in order to load the steady state previously computed (including the parameters which had been endogeneized during the steady state computation). The need for two separate .mod files arises from the fact that the variable declarations differ between the files for steady state calibration and for simulation (the set of endogenous and parameters differ between the two); this leads to different and statements. Also note that you can take advantage of the directive to share the model equations between the two files. load_params_and_steady_state load_params_and_steady_state loads the values of the parameters and of the steady-state from a file load_params_and_steady_state FILENAME ; Description For all parameters, endogenous and exogenous variables, loads their value from a file created with save_params_and_steady_state. for parameters, their value will be initialized as if they had been calibrated in the .mod file for endogenous and exogenous, their value will be initialized as they would have been from an initval block This function is used in conjunction with ; see the documentation of that function for more information. bvar_density bvar_density computes the marginal density of an estimated BVAR model, using Minnesota priors Description ... bvar_forecast bvar_forecast computes in-sample or out-sample forecasts for an estimated BVAR model, using Minnesota priors Description ...
Examples Dynare comes with a database of example .mod files, which are designed to show a broad range of Dynare features, and are taken from academic papers for most of them. You should have these files in the examples subdirectory of your distribution. Here is a short list of the examples included. For a more complete description, please refer to the comments inside the files themselves. ramst.mod An elementary real business cycle (RBC) model, simulated in a deterministic setup. example1.mod example2.mod Two examples of a small RBC model in a stochastic setup, presented in (see the file guide.pdf which comes with Dynare). fs2000.mod A cash in advance model, estimated by . bkk.mod Multi-country RBC model with time to build, presented in . Boucekkine Raouf 1995 An alternative methodology for solving nonlinear forward-looking models Journal of Economic Dynamics and Control 19 711-734 Collard Fabrice Juillard Michel 2001 Accuracy of stochastic perturbation methods: The case of asset pricing models Journal of Economic Dynamics and Control 25 979-999 Collard Fabrice Juillard Michel 2001 A Higher-Order Taylor Expansion Approach to Simulation of Stochastic Forward-Looking Models with an Application to a Non-Linear Phillips Curve Computational Economics 17 125-139 Durbin J. Koopman S.J. 2001 Time Series Analysis by State Space Methods Oxford University Press Fair Ray Taylor John 1983 Solution and Maximum Likelihood Estimation of Dynamic Nonlinear Rational Expectation Models Econometrica 51 1169-1185 Fernandez-Villaverde Jesus Rubio-Ramirez Juan 2004 Comparing Dynamic Equilibrium Economies to Data: A Bayesian Approach Journal of Econometrics 123 153-187 Ireland Peter 2004 A Method for Taking Models to the Data Journal of Economic Dynamics and Control 28 1205-26 Judd Kenneth 1996 Approximation, Perturbation, and Projection Methods in Economic Analysis Amman Hans Kendrick David Rust John Handbook of Computational Economics 1996 North Holland Press 511-585 Juillard Michel 1996 Dynare: A program for the resolution and simulation of dynamic models with forward variables through the use of a relaxation algorithm CEPREMAP Couverture Orange 9602 Koopman S.J. Durbin J. 2003 Filtering and Smoothing of State Vector for Diffuse State Space Models Journal of Time Series Analysis 24 1 85-98 Laffargue Jean-Pierre Résolution d'un modèle macroéconomique avec anticipations rationnelles 1990 Annales d'Économie et Statistique 17 97-119 Lubik Thomas Schorfheide Frank 2007 Do Central Banks Respond to Exchange Rate Movements? A Structural Investigation Journal of Monetary Economics 54 4 1069-1087 Mancini-Griffoli Tommaso 2007 Dynare User Guide An introduction to the solution and estimation of DSGE models Rabanal Pau Rubio-Ramirez Juan 2003 Comparing New Keynesian Models of the Business Cycle: A Bayesian Approach Federal Reserve of Atlanta Working Paper Series 2003-30 Schorfheide Frank 2000 Loss Function-based evaluation of DSGE models Journal of Applied Econometrics 15 6 645-670 Schmitt-Grohe Stephanie Uribe Martin 2002 Solving Dynamic General Equilibrium Models Using a Second-Order Approximation to the Policy Function NBER Technical Working Papers 0282 Smets Frank Wouters Rafael 2003 An Estimated Dynamic Stochastic General Equilibrium Model of the Euro Area Journal of the European Economic Association 1 5 1123-1175 Collard Fabrice 2001 Stochastic simulations with Dynare: A practical guide Backus David K. Kehoe Patrick J. Kydland Finn E. 1992 International Real Business Cycles Journal of Political Economy 100 4 745-775 Kim Jinill Kim Sunghyun Schaumburg Ernst Sims Christopher A. 2008 Calculating and using second-order accurate solutions of discrete time dynamic equilibrium models Journal of Economic Dynamics and Control 32 11 3397-3414