51
Dynare Manual i Dynare Manual Version 4.0.4

Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Embed Size (px)

Citation preview

Page 1: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manuali

Dynare Manual

Version 4.0.4

Page 2: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manualii

Copyright © 1996-2009 Dynare 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

Page 3: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manualiii

COLLABORATORS

TITLE :

Dynare Manual

ACTION NAME DATE SIGNATURE

WRITTEN BY Stéphane Adjemian,Michel Juillard,Ferhat Mihoubi,

George Perendia,and Sébastien

Villemot

June 19, 2009

REVISION HISTORY

NUMBER DATE DESCRIPTION NAME

Page 4: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manualiv

Contents

1 Introduction 1

1.1 What is Dynare ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Installation and configuration 2

2.1 Software requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.2 Installation of GNU Octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.3 Installation of Dynare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.3.1 On Windows® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.3.2 On Debian GNU/Linux and Ubuntu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.3.3 For other systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.4 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.4.1 For Matlab® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.4.2 For GNU Octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.4.3 Some words of warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Dynare invocation 5

3.1 dynare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 The Model file 7

4.1 Variable declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.1.1 var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.1.2 varexo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4.1.3 varexo_det . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4.1.4 parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.2 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.2.1 Parameters and variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.2.1.1 Inside the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.2.1.2 Outside the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.2.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.2.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.3 Parameter initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Page 5: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manualv

4.4 Model declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.4.1 model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.5 Initial and terminal conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.5.1 initval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4.5.2 initval_file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4.5.3 endval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4.5.4 histval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4.6 Shocks on exogenous variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.6.1 shocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.6.2 mshocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.6.3 Sigma_e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.7 Other general declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.7.1 dsample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.7.2 periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.8 Solving and simulating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.8.1 steady . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.8.2 homotopy_setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.8.3 check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.8.4 forecast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.8.5 simul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4.8.6 stoch_simul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4.9 Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.9.1 varobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.9.2 observation_trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.9.3 estimated_params . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.9.4 estimated_params_init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.9.5 estimated_params_bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.9.6 estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.9.7 prior_analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.9.8 posterior_analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.9.9 unit_root_vars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.10 Optimal policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

4.10.1 optim_weights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

4.10.2 osr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.10.3 osr_params . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.10.4 planner_objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.10.5 ramsey_policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.11 Sensitivity analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.11.1 dynare_sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Page 6: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manualvi

4.12 Displaying and saving results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.12.1 rplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.12.2 dynatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.12.3 dynasave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.13 Macro-processing language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.13.1 @#include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.13.2 @#define . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.13.3 @#if ... @#else ... @#endif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.13.4 @#for ... @#endfor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.13.5 @#echo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

4.13.6 @#error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

4.14 Misc commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

4.14.1 save_params_and_steady_state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

4.14.2 load_params_and_steady_state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4.14.3 bvar_density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4.14.4 bvar_forecast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

5 Examples 42

6 Bibliography 43

Page 7: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manualvii

List of Tables

4.1 Content of oo_ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

4.2 Moments of forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.3 Moments Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.4 Theoretical Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.5 Estimated objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Page 8: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual1 / 44

Chapter 1

Introduction

1.1 What is Dynare ?

Dynare is a pre-processor and a collection of Matlab and GNU Octave routines which solve, simulate and estimate non-linearmodels with forward looking variables. It is the result of research carried at CEPREMAP by several people (see Laffargue (1990),Boucekkine (1995), Juillard (1996), Collard and Juillard (2001a) and Collard and Juillard (2001b)).

When the framework is deterministic, Dynare can be used for models with the assumption of perfect foresight. Typically, thesystem is supposed to be in a state of equilibrium before a period 1 when the news of a contemporaneous or of a future shock islearned by the agents in the model. The purpose of the simulation is to describe the reaction in anticipation of, then in reaction tothe shock, until the system returns to the old or to a new state of equilibrium. In most models, this return to equilibrium is onlyan asymptotic phenomenon, which one must approximate by an horizon of simulation far enough in the future. Another exercisefor 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 Laffargue (1990), instead of a first ordertechnique like the one proposed by Fair and Taylor (1983), and used in earlier generation simulation programs. We believe thisapproach to be in general both faster and more robust. The details of the algorithm used in Dynare can be found in Juillard(1996).

In a stochastic context, Dynare computes one or several simulations corresponding to a random draw of the shocks. Starting withversion 2.3, Dynare uses a second order Taylor approximation of the expectation functions (see Judd (1996), Collard and Juillard(2001a), Collard and Juillard (2001b), and Schmitt-Grohe and Uribe (2002)).

Starting with version 3.0, it is possible to use Dynare to estimate model parameters either by maximum likelihood as in Ireland(2004) or using a Bayesian approach as in Rabanal and Rubio-Ramirez (2003), Schorfheide (2000) or Smets and Wouters (2003).

Currently the development team of Dynare is composed of S. Adjemian, M. Juillard, O. Kamenik, 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, P. Klein, S. Sakata, F. Schorfheide, C. Sims, P. Soederlind and R. Wouters.

Page 9: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual2 / 44

Chapter 2

Installation and configuration

2.1 Software requirements

Packaged versions of Dynare are available for Windows® 98/NT/2000/XP/Vista, Debian GNU/Linux and Ubuntu, on Intel/AMDx86 architectures. Dynare should work on other systems and architectures, 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.

2.2 Installation of GNU Octave

You can skip this step if you are planning to use only Matlab® with Dynare.

Please refer to DynareOctave on Dynare Wiki for detailed instructions.

2.3 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 directoriesdifferent from the one containing the Dynare toolbox. That way you can upgrade Dynare and discard the previous version withouthaving to worry about your own files.

2.3.1 On Windows®

Execute the automated installer called dynare-4.x.y-win32.exe (where 4.x.y is the version number), and follow theinstructions. 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.

You can have several versions of Dynare coexisting (for example in c:\dynare), as long as you correctly adjust your pathsettings (see Section 2.4.3).

Note that no installer is currently avaible for Windows® on 64 bits platforms. For the time being, please follow the instructionsgiven in Section 2.3.3 if you have such a system.

Page 10: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual3 / 44

2.3.2 On Debian GNU/Linux and Ubuntu

Please refer to InstallOnDebianOrUbuntu on Dynare Wiki for detailed instructions.

Dynare will be installed under /usr/lib/dynare. Documentation will be under /usr/share/doc/dynare.

2.3.3 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 BuildingPreprocessor andBuildingDlls on Dynare Wiki.

2.4 Configuration

2.4.1 For Matlab®

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 versionnumber, type:

addpath c:\dynare\4.x.y\matlab

Under Debian GNU/Linux or Ubuntu, type:

addpath /usr/lib/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 yourDynare installation. Note that you should not use "Add with Subfolders...". Apply the settings by clicking on "Save". Notethat Matlab will remember this setting next time you run it.

2.4.2 For GNU Octave

You need to add the matlab subdirectory of your Dynare installation to Octave path, using the addpath at the Octave commandprompt.

Under Windows®, assuming that you have installed Dynare at the standard location, and replacing "4.x.y" by correct versionnumber, type:

addpath c:\dynare\4.x.y\matlab

Under Debian GNU/Linux or Ubuntu, type:

addpath /usr/lib/dynare/matlab

You will also want to tell to Octave to accept the short syntax (without parentheses and quotes) for the dynare command, bytyping:

mark_as_command dynare

If you don’t want to type these two commands every time you run Octave, you can put them in a file called .octaverc in yourhome directory (under Windows® this will generally by c:\DocumentsandSettings\USERNAME\). This file is run byOctave at every startup.

Page 11: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual4 / 44

2.4.3 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 pathin the command window.

The path should normally contain system directories of Matlab® or Octave, and the matlab subdirectory of your Dynareinstallation. It should not contain any other Dynare-related directory, from another Dynare version of from the version you areusing. However, note that Dynare will automatically add one (and only one) of the mex/2007a, mex/2007b, and mex/octave subdirectories, depending on your installation.

You have to be aware that adding other directories to your path can potentially create problems, if some of your M-files have thesame names than Dynare files. Your files would then override Dynare files, and make Dynare unusable.

Page 12: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual5 / 44

Chapter 3

Dynare invocation

In order to give instructions to Dynare, the user has to write a model file whose filename extension must be .mod. This filecontains the description of the model and the computing tasks required by the user. Its contents is described in Chapter 4.

Once the model file is written, Dynare is invoked using the dynare command at the Matlab® or Octave prompt (with the filenameof 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 writtenby 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.

3.1 dynare

dynare – executes Dynare

Synopsis

dynare FILENAME[.mod] [noclearall] [savemacro] [debug] [notmpterms]

Description

dynare executes instruction included in FILENAME.mod. This user-supplied file contains the model and the processing instruc-tions, as described in Chapter 4.

Details

dynare begins by launching the preprocessor on the .mod file. By default (unless use_dll option has been given to model),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.

Page 13: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual6 / 44

Options

noclearall By default, dynare will issue a clear all command to Matlab® or Octave, thereby deleting all workspace vari-ables; this options instructs dynare not to clear the workspace

savemacro Instructs dynare to save the intermediary file which is obtained after macro-processing (see Section 4.13); thesaved output will go in FILENAME-macroexp.mod

debug Instructs the preprocessor to write some debugging information about the scanning and parsing of the .mod file

notmpterms Instructs the preprocessor to omit temporary terms in the static and dynamic files; this generally decreasesperformance, but is used for debugging purposes since it makes the static and dynamic files more readable

Output

Depending on the computing tasks requested in the .mod file, executing command dynare will leave in the workspace variablescontaining 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 ramstdynare ramst.mod savemacro

Page 14: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual7 / 44

Chapter 4

The Model file

Dynare commands are either single instructions or a block of instructions. Each single instruction and each element of a block isterminated 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 Section 4.2)

• MODEL_EXPRESSION indicates a mathematical expression valid in the model description (see Section 4.2 and model)

• VARIABLE_NAME indicates a variable name starting with an alphabetical character and can’t contain ()+-*/ˆ=!;:@#. oraccentuated characters

• PARAMETER_NAME indicates a parameter name starting with an alphabetical character and can’t contain ()+-*/ˆ=!;:@#.or accentuated characters

• FILENAME indicates a file name valid in the underlying operating system (Windows®, GNU/Linux, ...)

4.1 Variable declarations

Declarations of variables and parameters are made with the following commands:

• var

• varexo

• varexo_det

• parameters

4.1.1 var

var – declares endogenous variables

Page 15: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual8 / 44

Synopsis

var VARIABLE_NAME [[,]VARIABLE_NAME...] ;

Description

This required command declares the endogenous variables in the model. See Conventions [7] for the syntax of VARIABLE_NAME.

var commands can appear several times in the file and Dynare will concatenate them.

Example

var c gnp q1 q2;

4.1.2 varexo

varexo – declares exogenous variables

Synopsis

varexo VARIABLE_NAME [[,]VARIABLE_NAME...] ;

Description

This optional command declares the exogenous variables in the model. See Conventions [7] for the syntax of VARIABLE_NAME.

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;

4.1.3 varexo_det

varexo_det – declares exogenous deterministic variables in a stochastic model

Synopsis

varexo_det VARIABLE_NAME [[,]VARIABLE_NAME...] ;

Description

This optional command declares exogenous deterministic variables in a stochastic model. See Conventions [7] for the syntax ofVARIABLE_NAME.

It is possible to mix deterministic and stochastic shocks to build models where agents know from the start of the simulation aboutfuture exogenous changes. In that case stoch_simul will compute the rational expectation solution adding future informationto the state space (nothing is shown in the output of stoch_simul) and forecast will compute a simulation conditional on initialconditions and future information.

varexo_det commands can appear several times in the file and Dynare will concatenate them.

Page 16: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual9 / 44

Example

varexo m gov;varexo_det tau;

4.1.4 parameters

parameters – declares parameters

Synopsis

parameters PARAMETER_NAME [[,]PARAMETER_NAME...] ;

Description

This optional command declares parameters used in the model, in variable initialization or in shocks declarations. See Conven-tions [7] for the syntax of PARAMETER_NAME.

The parameters must subsequently be assigned values, see Section 4.3.

parameters commands can appear several times in the file and Dynare will concatenate them.

Example

parameters alpha, bet;

4.2 Expressions

Dynare distinguishes between two types of mathematical expressions: those that are used to describe the model, and those thatare used outside the model block (e.g. for initializing parameters or variables, or as command options). In this manual, those twotypes 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 evaluateto matrices1.

Expressions can be constructed using integers (INTEGER), floating point numbers (DOUBLE), parameter names (PARAMETER_N-AME), variable names (VARIABLE_NAME), operators and functions.

4.2.1 Parameters and variables

Parameters and variables can be introduced in expressions by simply typing their names. The semantics of parameters andvariables is quite different whether they are used inside or outside the model block.

1Note 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 thefile for post-processing purposes. They are not interpreted by Dynare, and are simply passed on unmodified to Matlab® or Octave. Those constructions are notaddresses in this section.

Page 17: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual10 / 44

4.2.1.1 Inside the model

Parameters used inside the model refer to the value given through parameter initialization or homotopy_setup when doing asimulation, 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 canbe given by enclosing an integer between parenthesis just after the variable name: a positive integer means a lead, a negative onemeans a lag. Leads or lags of more than one period are allowed. For example, if c is an endogenous variable, then c(+1) is thevariable 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, thetiming of a variable reflects when that variable is decided. A control variable - which by definition is decided in the currentperiod - must have no lead. A predetermined variable - which by definition has been decided in a previous period - must havea lag. A consequence of this is that all stock variables must use the "stock at the end of the period" convention. Please refer toMancini-Griffoli (2007) for more details and concrete examples.

Leads and lags are primarily used for endogenous variables. They can be used for exogenous variables under some conditions(TO BE EXPLICITED). They are forbidden for parameters and for local model variables (see model).

4.2.1.2 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 orexogenous variable, it refers to the value given in the most recent initval or endval block.

4.2.2 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): <, >, <=, >=, ==, !=

4.2.3 Functions

The following standard functions are allowed in 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))

In a MODEL_EXPRESSION , no other function is allowed.2

In an EXPRESSION , it is possible to use any arbitrary Matlab® or Octave function, provided that this function has scalar argu-ments and return value.

2This is due to the fact that the Dynare preprocessor performs a symbolical derivation of all model equations, and therefore needs to know the analyticalderivatives of all the equations in the model equations. In the future, we should add support for other usual functions, and implement an interface to let the userdefine custom functions, for which he would provide the analytical derivatives.

Page 18: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual11 / 44

4.3 Parameter initialization

When using Dynare for computing simulations, it is necessary to calibrate the parameters of the model. This is done throughparameter initialization.

Syntax PARAMETER_NAME = EXPRESSION ;

Example

parameters alpha, bet;

beta = 0.99;alpha = 0.36;A = 1-alpha*beta;

4.4 Model declaration

The model is declared inside a model block.

4.4.1 model

model – declares the model equations

Synopsis

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 unconstrainedoptimal policy with ramsey_policy.

The syntax of equations must follow the conventions for MODEL_EXPRESSION as described in Section 4.2. Each equation mustbe 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 theequation.

Inside the model block, Dynare allows the creation of model-local variables, which constitute a simple way to share a commonexpression between several equations. The syntax consists of a pound sign (#) followed by the name of the new model localvariable (which must not be declared as in Section 4.1), 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. Notethat the scope of this variable is restricted to the model block; it cannot be used outside.

Options

linear Declares the model as being linear. It spares oneself from having to declare initial values for computing the steadystate, and it sets automatically order=1 in stoch_simul.

Page 19: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual12 / 44

use_dll Instructs the preprocessor to create dynamic loadable libraries (DLL) containing the model equations and derivatives,instead of writing those in M-files. You need to having a working compilation environment (i.e. the mex command ofMatlab® or Octave must be operational). Using this option can result in faster simulations or estimations, at the expenseof some initial compilation time.3

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;

4.5 Initial and terminal conditions

For most simulation exercises, it is necessary to provide initial (and possibly terminal) conditions. It is also necessary to provideinitial guess values for non-linear solvers. The following statements are used for those purposes:

• initval

• initval_file

• endval3In particular, for big models, the compilation step can be very time-consuming, and use of this option may be counter-productive in those cases.

Page 20: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual13 / 44

• histval

In many contexts (determistic or stochastic), it is necessary to compute the steady state of a non-linear model: initval thenspecifies numerical initial values for the non-linear solver.

Used in perfect foresight mode, the types of forward-loking models for which Dynare was designed require both initial andterminal 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 ofreturn at the initial equilbrium. To do that, one needs initval and shocks (see Section 4.6.

Another one is to study, how an economy, starting from arbitrary initial conditions converges toward equilibrium. To do that, oneneeds initval and endval;

For models with lags on more than one period, the command histval permits to specify different historical initial values forperiods before the beginning of the simulation.

4.5.1 initval

initval – specifies numerical starting values for finding the steady state and/or initial values for simulations

Synopsis

initval ;VARIABLE_NAME = EXPRESSION ; ...

end ;

Description

The initval block serves two purposes: declaring the initial (and possibly terminal) conditions in a simulation exercise, andproviding guess values for non-linear solvers.

In a deterministic (i.e. perfect foresight) model

First, it provides the initial conditions for all the endogenous and exogenous variables at all the periods preceeding the firstsimulation period (unless some of these initial values are modified by histval).

Second, in the absence of an endval block, it sets the terminal conditions for all the periods succeeding the last simulation period.

Third, in the absence of an endval block, it provides initial guess values at all simulation dates for the non-linear solver imple-mented in simul.

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 steady command, its semantics is changed. The steady command willcompute the steady state of the model for all the endogenous variables, assuming that exogenous variables are kept constant tothe value declared in the initval block, and using the values declared for the endogenous as initial guess values for the non-linearsolver. An initval block followed by steady is formally equivalent to an initval block with the same values for the exogenous,and with the associated steady state values for the endogenous.

Page 21: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual14 / 44

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. Notethat if the initval block is not followed by steady, the steady state computation will still be triggered by subsequent commands(stoch_simul, estimation...).

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 possibletypes of simulations in stochastic mode:

• in stoch_simul, if the simul or periods options are specified

• in forecast (in this case, note that it is still possible to modify some of these initial values with histval)

Example

initval;c = 1.2;k = 12;x = 1;end;

steady;

4.5.2 initval_file

initval_file – use an external file for specifying initial values (for steady-state computation or for simulations)

Synopsis

initval_file (filename = FILENAME);

4.5.3 endval

endval – specifies terminal values for deterministic simulations

Synopsis

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 simul.

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.

Page 22: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual15 / 44

Note that if the endval block is immediately followed by a steady command, its semantics is changed. The steady command willcompute the steady state of the model for all the endogenous variables, assuming that exogenous variables are kept constant tothe value declared in the endval block, and using the values declared for the endogenous as initial guess values for the non-linearsolver. An endval block followed by steady 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 steady for x=1, and the terminal one, for x=2.

4.5.4 histval

histval – specifies historical values before the start of a simulation

Synopsis

histval ;VARIABLE_NAME = 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 initialvalues 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 startof 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.

Page 23: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual16 / 44

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;

4.6 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 analyzethe consequences of a permanent shock and this in done in Dynare through the proper use of initval and endval.

Another typical experiment is to study the effects of a temporary shock after which the system goes back to the original equilib-rium (if the model is stable ...). A temporary shock is a temporary change of value of one or several exogenous variables in themodel. Temporary shocks are specified with the command shocks.

In a stochastic framework, the exogenous variables take random values in each period. In Dynare, these random values follow anormal distribution with zero mean, but it belongs to the user to specify the variability of these shocks. The non-zero elementsof the matrix of variance-covariance of the shocks can be entered with the shocks command. Or, the entire matrix can be direcltyentered with Sigma_e (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 ofremoving an exogenous shock.

• shocks

• mshocks

• Sigma_e (deprecated)

4.6.1 shocks

shocks – specifies shocks on deterministic or stochastic exogenous variables

Synopsis

shocks ;[[(1)DETERMINISTIC SHOCK STATEMENT | (2)STOCHASTIC SHOCK STATEMENT]...]

Page 24: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual17 / 44

end ;

(1) var VARIABLE_NAME; periods INTEGER [:INTEGER] [[,]INTEGER [:INTEGER]...]; values EXPRESSION [[,]EXPRESSION ...];

(2) 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 perma-nent shocks, use an endval block.

When specifying shocks on several periods, the values EXPRESSION must return either a scalar value common to all periodswith 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.

Example

shocks;var e = 0.000081;var u; stderr 0.009;corr e, u = 0.8;var v, w = 2;end;

See also

Sigma_e

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 aboutfuture exogenous changes. In that case stoch_simul will compute the rational expectation solution adding future informationto the state space (nothing is shown in the output of stoch_simul) and forecast will compute a simulation conditional on initialconditions and future information.

Page 25: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual18 / 44

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;

4.6.2 mshocks

mshocks – specifies multiplicative shocks on deterministic or stochastic exogenous variables

Synopsis

mshocks ;[[(1)DETERMINISTIC SHOCK STATEMENT | (2)STOCHASTIC SHOCK STATEMENT]...]

end ;

(1) var VARIABLE_NAME; periods INTEGER [:INTEGER] [[,]INTEGER [:INTEGER]...]; values EXPRESSION [[,]EXPRESSION ...];

(2) var VARIABLE_NAME; stderr EXPRESSION ; | var VARIABLE_NAME = EXPRESSION ; | var VARIABLE_NAME, VARIABLE_NAME= EXPRESSION ; | corr VARIABLE_NAME, VARIABLE_NAME = EXPRESSION ;

4.6.3 Sigma_e

Sigma_e – specifies directly the covariance matrix of the stochastic shocks

Synopsis

Sigma_e = [ EXPRESSION [[,]EXPRESSION ...] [; EXPRESSION [[,]EXPRESSION ...]...] ];

WarningThe matrix elements are actually written between square brackets ([]). Here, the initial [ and final ] don’t have themeaning 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 buildsthe 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 enclosethe expression in parentheses. The order of the covariances in the matrix is the same as the one used in the varexo declaration.

Page 26: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual19 / 44

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.

4.7 Other general declarations

• dsample

• periods (deprecated)

4.7.1 dsample

dsample – reduces the number of periods considered in subsequent output commands

Synopsis

dsample INTEGER [INTEGER];

4.7.2 periods

periods – specifies the number of simulation periods

Synopsis

periods INTEGER;

Description

This command is now deprecated (but will still work for older model files). It is not necessary when no simulation is performedand is replaced by an option periods in simul and stoch_simul.

Sets the number of periods in the simulation. The periods are numbered from 1 to INTEGER. In perfect foresight simulations, itis assumed that all future events are perfectly known at the beginning of period 1.

Example

periods 100;

4.8 Solving and simulating

Dynare has special commands for the computation of the static equilibrium of the model (steady, of the eigenvalues of thelinearized model (check) for dynamics local analysis, of a deterministic simulation (simul) and for solving and/or simulating astochastic model (stoch_simul).

• steady

Page 27: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual20 / 44

• homotopy_setup

• check

• forecast

• simul

• stoch_simul

4.8.1 steady

steady – computes the steady state of a model

Synopsis

steady [(OPTION [, OPTION ...])];

Options

solve_algo = 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

Default value is 2.

homotopy_mode = INTEGER ...

homotopy_steps = INTEGER ...

Description

Computes the equilibrium value of the endogenous variables for the value of the exogenous variables specified in the previousinitval or endval block.

steady uses an iterative procedure and takes as initial guess the value of the endogenous variables set in the previous initval orendval block.

For complicated models, finding good numerical initial values for the endogenous variables is the trickiest part of finding theequilibrium 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 computationinstead of using steady. The function should be called with the name of the .mod file followed by _steadystate. Seefs2000a_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 varcommand as in M_.endo_names.

Page 28: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual21 / 44

Examples

See initval and endval.

4.8.2 homotopy_setup

homotopy_setup – instructs steady to use homotopy methods

Synopsis

homotopy_setup ;VARIABLE_NAME, EXPRESSION [, EXPRESSION ];...

end ;

4.8.3 check

check – computes the eigenvalues of the (linearized) model

Synopsis

check [(solve_algo = INTEGER)];

Options

solve_algo = 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 initval, endval or steady statement.Generally, the eigenvalues are only meaningful if the linearization is done around a steady state of the model. It is a device forlocal 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 asmany eigenvalues larger than one in modulus as there are forward looking variables in the system. An additional rank conditionrequires that the square submatrix of the right Schur vectors corresponding to the forward looking variables (jumpers) and to theexplosive eigenvalues must have full rank.

Output variables

check returns the eigenvalues in the global variable oo_.dr.eigval.

4.8.4 forecast

forecast – computes a simulation of a stochastic model from a given state

Synopsis

forecast [(OPTION [, OPTION ...])] [VARIABLE_NAME] [[,]VARIABLE_NAME...];

Page 29: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual22 / 44

Options

periods = INTEGER Number of periods of the forecast. Default: 40

conf_sig = DOUBLE Level of significance for confidence interval. Default: 0.90

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 knowingthe future values of the deterministic exogenous variables.

forecast must be called after stoch_simul.

forecast plots the trajectory of endogenous variables. When a list of variable names follows the command, only those variablesare plotted. A 90% confidence interval is plotted around the mean trajectory. Use option conf_sig to change the level of theconfidence 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;

4.8.5 simul

simul – simulates a deterministic model

Synopsis

simul [(periods=INTEGER) ];

Page 30: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual23 / 44

Description

Triggers the computation of a deterministic simulation of the model for the number of periods set in the option periods. simuluses a Newton method to solve simultaneously all the equations for every period (see Juillard (1996)).

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 hasmore columns than the value of periods option.

4.8.6 stoch_simul

stoch_simul – computes the solution and simulates the model

Synopsis

stoch_simul [(OPTION [, OPTION ...])] [VARIABLE_NAME...];

Options

ar = INTEGER Order of autocorrelation coefficients to compute and to print. Default: 5

drop = INTEGER Number of points dropped at the beginning of simulation before computing the summary statistics. Default:100

hp_filter = INTEGER Uses HP filter with λ = INTEGER before computing moments. Default: no filter

hp_ngrid = INTEGER Number of points in the grid for the discrete Inverse Fast Fourier Transform used in the HP filtercomputation. It may be necessary to increase it for highly autocorrelated processes. Default: 512

irf = INTEGER Number of periods on which to compute the IRFs. Setting irf=0, suppresses the plotting of IRF’s. Default:40

relative_irf Requests the computation of normalized IRFs in percentage of the standard error of each shock

linear Indicates that the original model is linear (put it rather in the model command)

nocorr Don’t print the correlation matrix (printing them is the default)

nofunctions Don’t print the coefficients of the approximated solution (printing them is the default)

nomoments Don’t print moments of the endogenous variables (printing them is the default)

nograph Doesn’t do the graphs. Useful for loops

noprint Don’t print anything. Useful for loops

print Print results (opposite of the above)

order = INTEGER Order of Taylor approximation. Acceptable values are 1 and 2. Default: 2

periods = INTEGER Specifies the number of periods to use in simulations. If order=1, no simulation is necessary to computetheoretical moments and IRFs. A number of periods larger than one triggers automatically option simul. Default: 0

qz_criterium = DOUBLE Value used to split stable from unstable eigenvalues in reordering the Generalized Schur decom-position used for solving 1st order problems. Default: 1.000001

replic = INTEGER Number of simulated series used to compute the IRFs. Default: 1 if order=1, and 50 otherwise

Page 31: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual24 / 44

simul Computes a stochastic simulation of the model for the number of periods specified in the periods option. Uses initvalvalues, possibly recomputed by steady, as initial values for the simulation. The simulated endogenous variables are madeavailable to the user in a vector for each variable and in the global matrix oo_.endo_simul. The variables in theoo_.endo_simul matrix, in their order of declaration (as in M_.endo_names). Default: no simulation

simul_seed = INTEGER Specifies a seed for the random generator so as to obtain the same random sample at each run of theprogram. Otherwise a different sample is used for each run. Default: seed not specified

simul_algo = INTEGER Obsolete. Use only the default = 0

solve_algo = INTEGER See there for the possible values and their meaning

Description

stoch_simul computes a Taylor approximation of the decision and transition functions for the model, impulse response functionsand various descriptive statistics (moments, variance decomposition, correlation and autocorrelation coefficients). For correlatedshocks, the variance decomposition is computed as in the VAR literature through a Cholesky decomposition of the covariancematrix of the exogenous variables. When the shocks are correlated, the variance decomposition depends upon the order of thevariables in the varexo 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 calledwith the name of the .mod file followed by _steadystate. See fs2000a_steadystate.m in examples/fs2000directory.

Variance decomposition, correlation, autocorrelation are only displayed for variables with positive variance. Impulse responsefunctions are only plotted for variables with response larger than 10-10.

Currently, the IRFs are only plotted for 12 variables. Select the ones you want to see, if your model contains more than 12endogenous 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 shocks command or with the Sigma_e command.

When a list of VARIABLE_NAME is specified, results are displayed only for these variables.

Decision rules

The approximated solution of a model takes the form of a set of decision rules or transition equations expressing the current valueof the endogenous variables of the model as function of the previous state of the model and shocks oberved at the beginning ofthe 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.

Page 32: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual25 / 44

Output variables

stoch_simul sets several fields in global variable oo_. The descriptive statistics are theoretical moments when no simulation isrequested 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 usedin 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 statevariables (see below).

– B: oo_.dr.ghu. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond toexogenous variables in declaration order.

– C: oo_.dr.ghxx. The matrix rows correspond to re-ordered variables (see below). The matrix columns correspond to theKronecker 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 theKronecker 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 theKronecker 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 (variablesthat 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 thatappear 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_varcontains the inverse map. In other words, the first row in transition matrices corresponds to the endogenous declared at po-sition oo_.dr_order_var(1); conversely, first declared variable has row oo_.dr.inv_order_var(1) in transitionmatrices.

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 firstaccording to their lag: first variables from the previous period, then variables from two periods before and so on. Note alsothat 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 decla-ration order.

• The matrix of autocorrelation of the endogenous variables are made available in cell array oo_.autocorr. The elementnumber of the matrix in the cell array corresponds to the order of autocorrelation. The option ar specifies the number ofautocorrelation matrices available.

• Simulated variables, when they have been computed, are available in Matlab® vectors with the same name as the endogenousvariables. They are also available in the oo_.endo_simul matrix. The series are arranged by row, in declaration order ofthe variable names

• Impulse responses, when they have been computed, are available in Matlab® vectors with the following naming conventionVARIABLE_NAME_SHOCK_NAME. They are also available in oo_.irfs.

Example: gnp_ea contains the effect on gnp of a one standard deviation shock on ea.

Page 33: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual26 / 44

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 of0.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.

4.9 Estimation

Provided that you have observations on some endogenous variables, it is possible to use Dynare to estimate some or all parame-ters. 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 asyou have observed variables.

• varobs

• observation_trends

• estimated_params

• estimated_params_init

• estimated_params_bounds

• estimation

• prior_analysis

• posterior_analysis

• unit_root_vars (deprecated)

4.9.1 varobs

varobs – lists the observed variables

Synopsis

varobs VARIABLE_NAME... ;

Page 34: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual27 / 44

Description

varobs lists the name of observed endogenous variables for the estimation procedure. These variables must be available in thedata file (see estimation).

Example

varobs C y rr;

4.9.2 observation_trends

observation_trends – specifies linear trends for observed variables

Synopsis

observation_trends ;VARIABLE_NAME(EXPRESSION ); ...

end ;

Description

observation_trends specifies trends for observed variables as functions of model parameters. In most cases, variables shouldn’tbe centered when observation_trends is used.

Example

observation_trends;Y (eta);P (mu/eta);end;

4.9.3 estimated_params

estimated_params – specifies the estimated parameters and their prior

Synopsis

Syntax I (Maximum likelihood estimation)

estimated_params ;stderrVARIABLE_NAME | corrVARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME , INITIAL_VALUE [ , LOWER-_BOUND , UPPER_BOUND] ; ...

end ;

Page 35: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual28 / 44

Syntax II (Bayesian estimation)

estimated_params ;stderrVARIABLE_NAME | corrVARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME [ , INITIAL_VALUE [ , LOW-ER_BOUND , UPPER_BOUND]] , (1)PRIOR_SHAPE , PRIOR_MEAN , PRIOR_STANDARD_ERROR [ , PRIOR_3RD_PARAMETER [ ,PRIOR_4TH_PARAMETER [ , SCALE_PARAMETER]]] ; ...

end ;

(1) beta_pdf | gamma_pdf | normal_pdf | uniform_pdf | inv_gamma_pdf | inv_gamma1_pdf | inv_gamma2-_pdf

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:

stderr VARIABLE_NAME Indicates that the standard error of the exogenous variable VARIABLE_NAME, or of the observationerror associated with endogenous observed variable VARIABLE_NAME, is to be estimated

corr VARIABLE_NAME_1, VARIABLE_NAME_2 Indicates that the correlation between the exogenous variables VARIABLE_NA-ME_1 and VARIABLE_NAME_2, or the correlation of the observation errors associated with endogenous observed variablesVARIABLE_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 inv_gamma_pdfis equivalent to inv_gamma1_pdf

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 theuniform distribution. Default: 0

PRIOR_4TH_PARAMETER A fourth parameter of the prior used for generalized beta distribution, generalized gamma and for theuniform distribution. Default: 1

SCALE_PARAMETER The scale parameter to be used for the jump distribution of the Metropolis-Hasting algorithm

NoteINITIAL_VALUE, LOWER_BOUND, UPPER_BOUND, PRIOR_MEAN , PRIOR_STANDARD_ERROR, PRIOR_3RD_PARAMETER, P-RIOR_4TH_PARAMETER and SCALE_PARAMETER must be positive or negative INTEGER or DOUBLE. Some of them can beempty, in which Dynare will select a default value depending on the context and the prior shape.

NoteAt minimum, one must specify the name of the parameter and an initial guess. That will trigger unconstrained maximumlikelihood estimation.

Page 36: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual29 / 44

NoteAs one uses options more towards the end of the list, all previous options must be filled: for example, if you want to specifySCALE_PARAMETER, you must specify PRIOR_3RD_PARAMETER and PRIOR_4TH_PARAMETER. Use empty values, if theseparameters 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. Itis of course possible to replace the original parameter by a function of the estimated parameter everywhere is the model, but it isoften unpractical.

In such a case, it is possible to declare the parameter to be estimated in the parameters statement and to define the transformation,using a pound sign (#) expression (see model).

Example

parameters bet;

model;# sig = 1/bet;c = sig*c(+1)*mpk;end;

estimated_params;bet, normal_pdf, 1, 0.05;end;

4.9.4 estimated_params_init

estimated_params_init – specifies initial values for optimization

Synopsis

estimated_params_init ;stderrVARIABLE_NAME | corrVARIABLE_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 theprior mean.

Estimated parameter initial value specification

See estimated_params for the meaning and syntax of the various components.

4.9.5 estimated_params_bounds

estimated_params_bounds – specifies lower and upper bounds for the estimated parameters

Page 37: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual30 / 44

Synopsis

estimated_params_bounds ;stderrVARIABLE_NAME | corrVARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME , LOWER_BOUND , UPPER_BO-UND ; ...

end ;

Description

The estimated_params_bounds block declares lower and upper bounds for parameters in maximum likelihood estimation.

Estimated parameter bounds specification

See estimated_params for the meaning and syntax of the various components.

4.9.6 estimation

estimation – computes estimation

Synopsis

estimation [(OPTION [, OPTION ...])] [VARIABLE_NAME...];

Options

datafile = FILENAME The datafile (a .m file, a .mat file or a .xls file)

xls_sheet = NAME The name of the sheet with the data in an Excel file

xls_range = RANGE The range with the data in an Excel file

nobs = INTEGER The number of observations to be used. Default: all observations in the file

nobs = [INTEGER_1:INTEGER_2] Runs a recursive estimation and forecast for samples of size ranging of INTEGER_1 to IN-

TEGER_2. Option forecast must also be specified

first_obs = INTEGER The number of the first observation to be used. Default: 1

prefilter = INTEGER A value of 1 means that the estimation procedure will demean the data. Default: 0, i.e. no prefiltering

presample = INTEGER The number of observations to be skipped before evaluating the likelihood. Default: 0

loglinear Computes a log--linear approximation of the model instead of a linear approximation. The data must correspondto the definition of the variables used in the model. Default: computes a linear approximation

nograph No graphs should be plotted

lik_init = 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 varianceof the state variables

• 2: for nonstationary models: a wide prior is used with an initial matrix of variance of the error of forecast diagonal with10 on the diagonal

Default value is 1.

Page 38: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual31 / 44

lik_algo = INTEGER ...

conf_sig = DOUBLE See there

mh_replic = INTEGER Number of replications for Metropolis-Hastings algorithm. For the time being, mh_replic shouldbe larger than 1200. Default: 20000

mh_nblocks = INTEGER Number of parallel chains for Metropolis-Hastings algorithm. Default: 2

mh_drop = DOUBLE The fraction of initially generated parameter vectors to be dropped before using posterior simulations.Default: 0.5

mh_jscale = DOUBLE The scale to be used for the jumping distribution in Metropolis-Hastings algorithm. The default valueis rarely satisfactory. This option must be tuned to obtain, ideally, an acceptation rate of 25% in the Metropolis-Hastingsalgorithm. Default: 0.2

mh_init_scale = DOUBLE The scale to be used for drawing the initial value of the Metropolis-Hastings chain. Default:2*mh_scale

mh_recover Attempts to recover a Metropolis-Hastings simulation that crashed prematurely. Shouldn’t be used together withload_mh_file

mh_mode = INTEGER ...

mode_file = FILENAME Name of the file containing previous value for the mode. When computing the mode, Dynare storesthe mode (xparam1) and the hessian (hh) in a file called MODEL_FILENAME_mode.mat

mode_compute = INTEGER Specifies the optimizer for the mode computation:

• 0: the mode isn’t computed. mode_file must be specified

• 1: uses Matlab®’s fmincon• 2: value no longer used

• 3: uses Matlab®’s fminunc• 4: uses Chris Sim’s csminwel• 5: uses a routine by Marco Ratto

• 6: uses a simulated annealing-like algorithm

• 7: uses Matlab®’s fminsearch (a simplex based routine)

Default value is 4.

mode_check Tells Dynare to plot the posterior density for values around the computed mode for each estimated parameter inturn. This is helpful to diagnose problems with the optimizer

prior_trunc = DOUBLE Probability of extreme values of the prior density that is ignored when computing bounds for theparameters. Default: 1e-32

load_mh_file Tells Dynare to add to previous Metropolis-Hastings simulations instead of starting from scratch. Shouldn’tbe used together with mh_recover

optim = (fmincon options) Can be used to set options for fmincon, the optimizing function of Matlab® Optimizaitontoolbox. Use Matlab®’s syntax for these options. Default: (’display’,’iter’,’LargeScale’,’off’,’Max-FunEvals’,100000,’TolFun’,1e-8,’TolX’,1e-6)

nodiagnostic Doesn’t compute the convergence diagnostics for Metropolis-Hastings. Default: diagnostics are computedand displayed

bayesian_irf Triggers the computation of the posterior distribution of IRFs. The length of the IRFs are controlled by theirf option

moments_varendo Triggers the computation of the posterior distribution of the theoretical moments of the endogenousvariables

Page 39: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual32 / 44

filtered_vars Triggers the computation of the posterior distribution of filtered endogenous variables and shocks

smoother Triggers the computation of the posterior distribution of smoothered endogenous variables and shocks

forecast = INTEGER Computes the posterior distribution of a forecast on INTEGER periods after the end of the sample usedin estimation

tex Requests the printing of results and graphs in TeX tables and graphics that can be later directly included in LaTeX files (notyet implemented)

kalman_algo = INTEGER ...

kalman_tol = INTEGER ...

filter_step_ahead = [INTEGER_1:INTEGER_2] ...

constant ...

noconstant ...

diffuse_filter ...

solve_algo = INTEGER See there

order = INTEGER See there

irf = INTEGER See there

NoteIf no mh_jscale parameter is used in estimated_params, the procedure uses mh_jscale for all parameters. If mh_jsc-ale 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 likelihoodestimation or posterior mode computation without Metropolis iterations.

After estimation with Metropolis iterations (option mh_replic > 0 or option load_mh_file set) the parameters and thevariance matrix of the shocks are set to the posterior mean.

Depending on the options, estimation stores results in the following fields of structure oo_:

Page 40: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual33 / 44

Fiel

d1

Fiel

d2

Fiel

d3

Fiel

d4

Fiel

d5

Req

uire

dop

tions

Forecast

See

Mom

ents

offo

reca

sts

Variablename

fore

cast

MarginalDensity

LaplaceApproxim-

ation

Alw

ays

prov

ided

ModifiedHarmoni-

cMean

mh_

repl

ic>

0or

load

_mh_

file

PosteriorFilter-

edVariables

See

Mom

ents

Nam

esVariablename

filte

red_

vars

PosteriorIRF

Dsge

See

Mom

ents

Nam

esIR

Fna

me:

nam

eof

endo

geno

usva

riab

le’_

’na

me

ofsh

ock

baye

sian

_irf

PosteriorSmooth-

edObservationEr-

rors

See

Mom

ents

Nam

esVariablename

smoo

ther

PosteriorSmooth-

edShocks

See

Mom

ents

Nam

esVariablename

smoo

ther

PosteriorSmooth-

edVariables

See

Mom

ents

Nam

esVariablename

smoo

ther

PosteriorTheore-

ticalMoments

See

The

oret

ical

Mom

ents

See

Est

imat

edO

bjec

tsSe

eM

omen

tsN

ames

Variablename

mom

ents

_var

endo

posterior_densi-

ty

Parametername

mh_

repl

ic>

0or

load

_mh_

file

posterior_hpdinf

See

Est

imat

edO

bjec

tsVariablename

mh_

repl

ic>

0or

load

_mh_

file

posterior_hpdsup

See

Est

imat

edO

bjec

tsVariablename

mh_

repl

ic>

0or

load

_mh_

file

posterior_mean

See

Est

imat

edO

bjec

tsVariablename

mh_

repl

ic>

0or

load

_mh_

file

posterior_mode

See

Est

imat

edO

bjec

tsVariablename

mh_

repl

ic>

0or

load

_mh_

file

posterior_std

See

Est

imat

edO

bjec

tsVariablename

mh_

repl

ic>

0or

load

_mh_

file

Tabl

e4.

1:C

onte

ntofoo_

Page 41: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual34 / 44

Field name Description

HPDinfLower bound of a 90% HPD interval4 of forecast due toparameter uncertainty

HPDsupLower bound of a 90% HPD interval 4 due to parameteruncertainty

HPDTotalinfLower bound of a 90% HPD interval of forecast 4 due toparameter uncertainty and future shocks

HPDTotalsupLower bound of a 90% HPD interval 4 due to parameteruncertainty and future shocks

Mean Mean of the posterior distribution of forecastsMedian Median of the posterior distribution of forecastsStd Standard deviation of the posterior distribution of forecasts

Table 4.2: Moments of forecasts

Field name DescriptionHPDinf Lower bound of a 90% HPD interval5

HPDsup Upper bound of a 90% HPD interval 5

Mean Mean of the posterior distributionMedian Median of the posterior distributionStd Standard deviation of the posterior distribution

Table 4.3: Moments Names

Field name DescriptionAutocorrelation Autocorrelation of endogenous variables6

Correlation Correlation between two endogenous variablesDecomp Decomposition of variance7

Expectation Expectation of endogenous variablesVariance (co-)variance of endogenous variables

Table 4.4: Theoretical Moments

Examples

oo_.posterior_mode.parameters.alpoo_.posterior_mean.shocks_std.exoo_.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 computationinstead of using steady. The function should be called with the name of the .mod file followed by _steadystate. Seefs2000a_steadystate.m in examples/fs2000 directory.

4.9.7 prior_analysis

prior_analysis – Prior distribution analysis4See option conf_sig to change the size of the HPD interval5See option conf_sig to change the size of the HPD interval6The autocorrlation coefficients are computed for the number of periods specified in option ar.7When the shocks are correlated, it is the decomposition of orthogonalized shocks via Cholesky decompostion according to the order of declaration of

shocks (see varexo).

Page 42: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual35 / 44

Field name Descriptionmeasurement_errors_corr Correlation between two measurement errorsmeasurement_errors_std Standard deviation of measurement errorsparameters Parametersshocks_corr Correlation between two structural shocksshocks_std Standard deviation of structural shocks

Table 4.5: Estimated objects

Synopsis

prior_analysis [(OPTION [, OPTION ...])];

Options

nograph See there

conf_sig = DOUBLE See there

prior_trunc = DOUBLE See there

bayesian_irf See there

irf = INTEGER See there

tex See there

forecast = INTEGER See there

smoother See there

moments_varendo See there

filtered_vars See there

xls_sheet = NAME See there

xls_range = RANGE See there

filter_step_ahead = [INTEGER_1:INTEGER_2] See there

4.9.8 posterior_analysis

posterior_analysis – Posterior distribution analysis

Synopsis

posterior_analysis [(OPTION [, OPTION ...])];

Options

This command accepts exactly the same options than prior_analysis

4.9.9 unit_root_vars

unit_root_vars – declares unit-root variables for estimation

Page 43: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual36 / 44

Synopsis

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 diffuseprior can be used in the initialization of the Kalman filter for these variables only. For stationary variables, the unconditionalcovariance matrix of these variables is used for initialization. The algorithm to compute a true diffuse prior is taken from Durbinand Koopman (2001) and Koopman and Durbin (2003).

When unit_root_vars is used the lik_init option of estimation has no effect.

When there are nonstationary variables in a model, there is no unique deterministic steady state. The user must supply a Mat-lab® function that computes the steady state values of the stationary variables in the model and returns dummy values forthe nonstationary ones. The function should be called with the name of the .mod file followed by _steadystate. Seefs2000a_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 bestationary).

4.10 Optimal policy

Dynare has tools to compute optimal policies for quadratic objectives. You can either solve for optimal policy under commitmentwith planner_objective or for optimal simple rule with osr.

• optim_weights

• osr

• osr_params

• planner_objective

• ramsey_policy

4.10.1 optim_weights

optim_weights – specifies quadratic objectives for optimal policy problems

Synopsis

optim_weights;(1)VARIANCE STATEMENT | (2)COVARIANCE STATEMENT | (3)STANDARD ERROR STATEMENT end;

(1) var VARIABLE_NAME = EXPRESSION ;

(2) var VARIABLE_NAME , VARIABLE_NAME = EXPRESSION ;

(3) var VARIABLE_NAME; stderr EXPRESSION ;

Description

optim_weights secifies the nonzero elements of the quadratic weight matrices for the objectives in osr

Page 44: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual37 / 44

4.10.2 osr

osr – computes optimal simple policy rules

Synopsis

osr [( OPTION ,... )] VARIABLE_NAME [VARIABLE_NAME...] ;

OPTIONS

• All options for stoch_simul

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 osr_params.

The quadratic objectives must be listed with optim_weights.

This problem is solved using a numerical optimizer.

4.10.3 osr_params

osr_params – declares the parameters to be optimized for optimal simple rules

Synopsis

osr_params PARAMETER_NAME [PARAMETER_NAME...] ;

Description

osr_params declares parameters to be optimized by osr.

4.10.4 planner_objective

planner_objective – declares the policy maker objective, for use with ramsey_policy

Page 45: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual38 / 44

4.10.5 ramsey_policy

ramsey_policy – computes the first order approximation of the policy that maximizes the policy maker objective function (seeplanner_objective) submitted to the constraints provided by the equilibrium path of the economy. See http://www.dynare.org/-DynareWiki/OptimalPolicy for more information.

4.11 Sensitivity analysis

4.11.1 dynare_sensitivity

dynare_sensitivity – interface to the global sensitivity analysis (GSA) toolbox developed by the Joint Research Center of the Eu-ropean Commission. The GSA toolbox needs to be downloaded separately from the JRC web site (http://eemc.jrc.ec.europa.eu/-Software-DYNARE.htm)

4.12 Displaying and saving results

Dynare has comments to plot the results of a simulation and to save the results.

• rplot

• dynatype

• dynasave

4.12.1 rplot

rplot – plot variables

Synopsis

rplot VARIABLE_NAME [VARIABLE_NAME...] ;

Description

Plots one or several variables

4.12.2 dynatype

dynatype – print simulated variables

Synopsis

dynatype [ (FILENAME) ] VARIABLE_NAME [VARIABLE_NAME...] ;

Description

dynatype prints the listed variables in a text file named FILENAME. If no VARIABLE_NAME are listed, all endogenous variablesare printed.

Page 46: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual39 / 44

4.12.3 dynasave

dynasave – save simulated variables in a binary file

Synopsis

dynasave [ (FILENAME) ] VARIABLE_NAME [VARIABLE_NAME...] ;

Description

dynasave saves the listed variables in a binary file named FILENAME. If no VARIABLE_NAME are listed, all endogenous variablesare saved.

In Matlab®, variables saved with the dynasave command can be retrieved by the Matlab® command load -mat FILENAME.

4.13 Macro-processing language

It is possible to use "macro" commands in the .mod file for doing the following tasks: source file inclusion, replicating blocksof 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 componentof the Dynare pre-processor. The macro processor transforms a .mod file with macros into a .mod file without macros (doingexpansions/inclusions), and then feeds it to the Dynare parser.

• @#include

• @#define

• @#if ... @#else ... @#endif

• @#for ... @#endfor

• @#echo

• @#error

4.13.1 @#include

@#include – includes another file

4.13.2 @#define

@#define – defines a macro-variable

4.13.3 @#if ... @#else ... @#endif

@#if ... @#else ... @#endif – conditional inclusion of some part of the .mod file

4.13.4 @#for ... @#endfor

@#for ... @#endfor – loop for replications of portions of the .mod file

Page 47: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual40 / 44

4.13.5 @#echo

@#echo – asks the preprocessor to display some message on standard output

4.13.6 @#error

@#error – asks the preprocessor to display some error message on standard output and to abort

4.14 Misc commands

• save_params_and_steady_state

• load_params_and_steady_state

• bvar_density

• bvar_forecast

4.14.1 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

Synopsis

save_params_and_steady_state FILENAME ;

Description

For all parameters, endogenous and exogenous variables, stores their value in a file, using a simple name/value associative array.

• 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 thelast initval block)

Note that no variable type is stored in the file, so that the values can be reloaded (with load_params_and_steady_state) in a setupwhere 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 endoge-nous 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 thefile, using save_params_and_steady_state.

In a second file designed to perform the actual simulations, you would use load_params_and_steady_state just after your variabledeclarations, in order to load the steady-state previously computed (including the parameters which had been endogeneizedduring 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-statecalibration and for simulation (the set of endogenous and parameters differ between the two); this leads to different var andparameters statements.

Also note that you can take advantage of the @#include directive to share the model equations between the two files.

Page 48: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual41 / 44

4.14.2 load_params_and_steady_state

load_params_and_steady_state – loads the values of the parameters and of the steady-state from a file

Synopsis

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 save_params_and_steady_state; see the documentation of that function for more infor-mation.

4.14.3 bvar_density

bvar_density – computes the marginal density of an estimated BVAR model, using Minnesota priors

4.14.4 bvar_forecast

bvar_forecast – computes in-sample or out-sample forecasts for an estimated BVAR model, using Minnesota priors

Page 49: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual42 / 44

Chapter 5

Examples

Fabrice Collard (GREMAQ, University of Toulouse) has written a guide to stochastic simulations with Dynare entitled "Dynarein Practice" which is in guide.pdf.

Page 50: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual43 / 44

Chapter 6

Bibliography

[1] Jesus Fernandez-Villaverde and Juan Rubio-Ramirez, "Comparing Dynamic Equilibrium Economies to Data:A Bayesian Approach", 2004.

Journal of Econometrics, 123, 153-187.

[2] Thomas Lubik and Frank Schorfheide, "Do Central Banks Respond to Exchange Rate Movements? A StructuralInvestigation", 2007.

Journal of Monetary Economics, 54, 1069-1087.

[Boucekkine (1995)] Raouf Boucekkine, "An alternative methodology for solving nonlinear forward-looking models", 1995.

Journal of Economic Dynamics and Control, 19, 711-734.

[Collard and Juillard (2001a)] Fabrice Collard and Michel Juillard, "Accuracy of stochastic perturbation methods: The case ofasset pricing models", 2001.

Journal of Economic Dynamics and Control, 25, 979-999.

[Collard and Juillard (2001b)] Fabrice Collard and Michel Juillard, "A Higher-Order Taylor Expansion Approach to Simulationof Stochastic Forward-Looking Models with an Application to a Non-Linear Phillips Curve", 2001.

Computational Economics, 17, 125-139.

[Durbin and Koopman (2001)] J. Durbin and S.J. Koopman, Time Series Analysis by State Space Methods, 2001.

[Fair and Taylor (1983)] Ray Fair and John Taylor, "Solution and Maximum Likelihood Estimation of Dynamic Nonlinear Ra-tional Expectation Models", 1983.

Econometrica, 51, 1169-1185.

[Ireland (2004)] Peter Ireland, "A Method for Taking Models to the Data", 2004.

Journal of Economic Dynamics and Control, 28, 1205-26.

[Judd (1996)] Kenneth Judd, "Approximation, Perturbation, and Projection Methods in Economic Analysis", 1996.

Hans Amman, David Kendrick, and John Rust, Handbook of Computational Economics, 1996, 511-585.

[Juillard (1996)] Michel Juillard, "Dynare: A program for the resolution and simulation of dynamic models with forward vari-ables through the use of a relaxation algorithm", 1996.

Couverture Orange, 9602.

[Koopman and Durbin (2003)] S.J. Koopman and J. Durbin, "Filtering and Smoothing of State Vector for Diffuse State SpaceModels", 2003.

Journal of Time Series Analysis, 24, 85-98.

[Laffargue (1990)] Jean-Pierre Laffargue, "Résolution d’un modèle macroéconomique avec anticipations rationnelles", 1990.

Annales d’Économie et Statistique, 17, 97-119.

Page 51: Dynare Manual Version 4.0 - MikroBittikakex.mbnet.fi/laskelmia/aino/manual.pdf · Dynare Manual iii COLLABORATORS TITLE : Dynare Manual ACTION NAME DATE SIGNATURE WRITTEN BY Stéphane

Dynare Manual44 / 44

[Mancini-Griffoli (2007)] Tommaso Mancini-Griffoli, Dynare User Guide, 2007, An introduction to the solution and estimationof DSGE models.

[Rabanal and Rubio-Ramirez (2003)] Pau Rabanal and Juan Rubio-Ramirez, "Comparing New Keynesian Models of the Busi-ness Cycle: A Bayesian Approach", 2003.

Working Paper Series, 2003-30.

[Schmitt-Grohe and Uribe (2002)] Stephanie Schmitt-Grohe and Martin Uribe, "Solving Dynamic General Equilibrium ModelsUsing a Second-Order Approximation to the Policy Function", 2002.

NBER Technical Working Papers, 0282.

[Schorfheide (2000)] Frank Schorfheide, "Loss Function-based evaluation of DSGE models", 2000.

Journal of Applied Econometrics, 15, 645-70.

[Smets and Wouters (2003)] Frank Smets and Rafael Wouters, "An Estimated Dynamic Stochastic General Equilibrium Modelof the Euro Area", 2003.

Journal of the European Economic Association, 1, 1123-1175.