dynare.texi 284 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
\input texinfo
@c %**start of header
@setfilename dynare.info
@documentencoding UTF-8
@settitle Dynare Reference Manual
@afourwide
@dircategory Math
@direntry
* Dynare: (dynare).             A platform for handling a wide class
                                  of economic models.
@end direntry

@include version.texi

@c Define some macros

@macro descriptionhead
@ifnothtml
@sp 1
@end ifnothtml
@emph{Description}
@end macro

@macro optionshead
@iftex
@sp 1
@end iftex
@emph{Options}
@end macro

31
32
33
34
35
36
37
@macro flagshead
@iftex
@sp 1
@end iftex
@emph{Flags}
@end macro

38
39
40
41
42
43
44
45
46
47
48
49
50
51
@macro examplehead
@iftex
@sp 1
@end iftex
@emph{Example}
@end macro

@macro outputhead
@iftex
@sp 1
@end iftex
@emph{Output}
@end macro

52
53
54
55
56
57
58
@macro algorithmhead
@iftex
@sp 1
@end iftex
@emph{Algorithm}
@end macro

59
60
61
62
63
64
65
66
@macro algorithmshead
@iftex
@sp 1
@end iftex
@emph{Algorithms}
@end macro


67

68
69
70
71
72
73
74
75
76
77
@macro customhead{title}
@iftex
@sp 1
@end iftex
@emph{\title\}
@end macro

@c %**end of header

@copying
78
Copyright @copyright{} 1996-2013, Dynare Team.
79
80
81
82
83
84
85
86
87
88
89
90
91
92

@quotation
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 @uref{http://www.gnu.org/licenses/fdl.txt}.
@end quotation
@end copying

@titlepage
@title Dynare
@subtitle Reference Manual, version @value{VERSION}
93
@author Stéphane Adjemian
94
@author Houtan Bastani
95
@author Frédéric Karamé
96
97
98
99
@author Michel Juillard
@author Junior Maih
@author Ferhat Mihoubi
@author George Perendia
100
@author Johannes Pfeifer
101
@author Marco Ratto
102
@author Sébastien Villemot
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@contents

@ifnottex
@node Top
@top Dynare
This is Dynare Reference Manual, version @value{VERSION}.

@insertcopying
@end ifnottex

@menu
Sébastien Villemot's avatar
Sébastien Villemot committed
119
120
* Introduction::
* Installation and configuration::
121
* Running Dynare::
Sébastien Villemot's avatar
Sébastien Villemot committed
122
123
* The Model file::
* The Configuration File::
124
* Time Series::
Sébastien Villemot's avatar
Sébastien Villemot committed
125
126
127
128
129
130
* Reporting::
* Examples::
* Dynare internal documentation and unitary tests::
* Bibliography::
* Command and Function Index::
* Variable Index::
131
132
133
134
135
136

@detailmenu
 --- The Detailed Node Listing ---

Introduction

Sébastien Villemot's avatar
Sébastien Villemot committed
137
138
139
* What is Dynare ?::
* Documentation sources::
* Citing Dynare in your research::
140
141
142

Installation and configuration

Sébastien Villemot's avatar
Sébastien Villemot committed
143
144
145
* Software requirements::
* Installation of Dynare::
* Configuration::
146
147
148

Installation of Dynare

Sébastien Villemot's avatar
Sébastien Villemot committed
149
150
151
152
* On Windows::
* On Debian GNU/Linux and Ubuntu::
* On Mac OS X::
* For other systems::
153
154
155

Configuration

Sébastien Villemot's avatar
Sébastien Villemot committed
156
157
158
* For MATLAB::
* For GNU Octave::
* Some words of warning::
159

160
161
162
Running Dynare

* Dynare invocation::
163
* Dynare hooks::
164
165
166
167
* Understanding Preprocessor Error Messages::

Dynare invocation

168
* Dynare hooks
169
170
* Understanding Preprocessor Error Messages::

171
172
The Model file

Sébastien Villemot's avatar
Sébastien Villemot committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
* Conventions::
* Variable declarations::
* Expressions::
* Parameter initialization::
* Model declaration::
* Auxiliary variables::
* Initial and terminal conditions::
* Shocks on exogenous variables::
* Other general declarations::
* Steady state::
* Getting information about the model::
* Deterministic simulation::
* Stochastic solution and simulation::
* Estimation::
* Forecasting::
* Optimal policy::
* Sensitivity and identification analysis::
* Markov-switching SBVAR::
* Displaying and saving results::
* Macro-processing language::
* Misc commands::
194
195
196

Expressions

Sébastien Villemot's avatar
Sébastien Villemot committed
197
198
199
* Parameters and variables::
* Operators::
* Functions::
200
* A few words of warning in stochastic context::
201
202
203

Parameters and variables

Sébastien Villemot's avatar
Sébastien Villemot committed
204
205
* Inside the model::
* Outside the model::
206
207
208

Functions

Sébastien Villemot's avatar
Sébastien Villemot committed
209
210
* Built-in Functions::
* External Functions::
211
212
213

Steady state

Sébastien Villemot's avatar
Sébastien Villemot committed
214
215
216
* Finding the steady state with Dynare nonlinear solver::
* Using a steady state file::
* Replace some equations during steady state computations::
217
218
219

Stochastic solution and simulation

Sébastien Villemot's avatar
Sébastien Villemot committed
220
221
222
223
224
* Computing the stochastic solution::
* Typology and ordering of variables::
* First order approximation::
* Second order approximation::
* Third order approximation::
225

226
227
Sensitivity and identification analysis

Sébastien Villemot's avatar
Sébastien Villemot committed
228
229
230
231
232
233
234
* Sampling::
* Stability Mapping::
* Reduced Form Mapping::
* RMSE::
* Screening Analysis::
* Identification Analysis::
* Performing Sensitivity and Identification Analysis::
235

236
237
Macro-processing language

Sébastien Villemot's avatar
Sébastien Villemot committed
238
239
240
241
* Macro expressions::
* Macro directives::
* Typical usages::
* MATLAB/Octave loops versus macro-processor loops::
242
243
244

Typical usages

Sébastien Villemot's avatar
Sébastien Villemot committed
245
246
247
248
* Modularization::
* Indexed sums or products::
* Multi-country models::
* Endogeneizing parameters::
249

250
251
The Configuration File

Sébastien Villemot's avatar
Sébastien Villemot committed
252
253
* Dynare Configuration::
* Parallel Configuration::
254
255
256
257
258
259
260
261

@end detailmenu
@end menu

@node Introduction
@chapter Introduction

@menu
Sébastien Villemot's avatar
Sébastien Villemot committed
262
263
264
* What is Dynare ?::
* Documentation sources::
* Citing Dynare in your research::
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
@end menu

@node What is Dynare ?
@section What is Dynare ?

Dynare is a software platform for handling a wide class of economic
models, in particular dynamic stochastic general equilibrium (DSGE)
and overlapping generations (OLG) models. The models solved by Dynare
include those relying on the @i{rational expectations} hypothesis, wherein
agents form their expectations about the future in a way consistent
with the model. But Dynare is also able to handle models where
expectations are formed differently: on one extreme, models where
agents perfectly anticipate the future; on the other extreme, models
where agents have limited rationality or imperfect knowledge of the
state of the economy and, hence, form their expectations through a
learning process. In terms of types of agents, models solved by Dynare
can incorporate consumers, productive firms, governments, monetary
authorities, investors and financial intermediaries. Some degree of
heterogeneity can be achieved by including several distinct classes of
agents in each of the aforementioned agent categories.

Dynare offers a user-friendly and intuitive way of describing these
models. It is able to perform simulations of the model given a
calibration of the model parameters and is also able to estimate these
parameters given a dataset. In practice, the user will write a text
file containing the list of model variables, the dynamic equations
linking these variables together, the computing tasks to be performed
and the desired graphical or numerical outputs.

A large panel of applied mathematics and computer science techniques
are internally employed by Dynare: multivariate nonlinear solving and
optimization, matrix factorizations, local functional approximation,
Kalman filters and smoothers, MCMC techniques for Bayesian estimation,
graph algorithms, optimal control, @dots{}

Various public bodies (central banks, ministries of economy and
finance, international organisations) and some private financial
institutions use Dynare for performing policy analysis exercises and
as a support tool for forecasting exercises. In the academic world,
Dynare is used for research and teaching purposes in postgraduate
macroeconomics courses.

Dynare is a free software, which means that it can be downloaded free
of charge, that its source code is freely available, and that it can
be used for both non-profit and for-profit purposes. Most of the
source files are covered by the GNU General Public Licence (GPL)
version 3 or later (there are some exceptions to this, see the file
@file{license.txt} in Dynare distribution). It is available for the
Windows, Mac and Linux platforms and is fully documented through a
user guide and a reference manual. Part of Dynare is programmed in
C++, while the rest is written using the
@uref{http://www.mathworks.com/products/matlab/, MATLAB} programming
language.  The latter implies that commercially-available MATLAB
software is required in order to run Dynare. However, as an
alternative to MATLAB, Dynare is also able to run on top of
@uref{http://www.octave.org, GNU Octave} (basically a free clone of
MATLAB): this possibility is particularly interesting for students or
institutions who cannot afford, or do not want to pay for, MATLAB and
are willing to bear the concomitant performance loss.

The development of Dynare is mainly done at
@uref{http://www.cepremap.ens.fr, Cepremap} by a core team of
327
328
329
330
researchers who devote part of their time to software development.
Currently the development team of Dynare is composed of Stéphane
Adjemian (Université du Maine, Gains and Cepremap), Houtan Bastani
(Cepremap), Michel Juillard (Banque de France), Frédéric Karamé
Sébastien Villemot's avatar
Sébastien Villemot committed
331
(Université du Maine, Gains and Cepremap), Junior Maih (IMF),
332
333
Ferhat Mihoubi (Université d'Évry, Epee and Cepremap), George
Perendia, Johannes Pfeifer (Universität Tübingen), Marco Ratto (JRC)
Sébastien Villemot's avatar
Sébastien Villemot committed
334
and Sébastien Villemot (Cepremap).
335
336
337
338
339
340
341
342
Increasingly, the developer base is expanding, as tools developed by
researchers outside of Cepremap are integrated into Dynare. Financial
support is provided by Cepremap, Banque de France and DSGE-net (an
international research network for DSGE modeling). The Dynare project
also received funding through the Seventh Framework Programme for
Research (FP7) of the European Commission's Socio-economic Sciences
and Humanities (SSH) Program from October 2008 to September 2011 under
grant agreement SSH-CT-2009-225149.
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366

Interaction between developers and users of Dynare is central to the
project. A @uref{http://www.dynare.org/phpBB3, web forum} is available
for users who have questions about the usage of Dynare or who want to
report bugs. Training sessions are given through the Dynare Summer
School, which is organized every year and is attended by about 40
people. Finally, priorities in terms of future developments and
features to be added are decided in cooperation with the institutions
providing financial support.

@node Documentation sources
@section Documentation sources

The present document is the reference manual for Dynare. It documents
all commands and features in a systematic fashion.

New users should rather begin with Dynare User Guide (@cite{Mancini
(2007)}), distributed with Dynare and also available from the
@uref{http://www.dynare.org,official Dynare web site}.

Other useful sources of information include the
@uref{http://www.dynare.org,Dynare wiki} and the
@uref{http://www.dynare.org/phpBB3, Dynare forums}.

367
368
369
370
371
372
373
@node Citing Dynare in your research
@section Citing Dynare in your research

If you would like to refer to Dynare in a research article, the
recommended way is to cite the present manual, as follows:

@quotation
374
375
376
377
Stéphane Adjemian, Houtan Bastani, Michel Juillard, Frédéric Karamé,
Ferhat Mihoubi, George Perendia, Johannes Pfeifer, Marco Ratto and
Sébastien Villemot (2011), ``Dynare: Reference Manual, Version 4,''
@i{Dynare Working Papers}, 1, CEPREMAP
378
379
380
381
382
383
384
385
@end quotation

Note that citing the Dynare Reference Manual in your research is a
good way to help the Dynare project.

If you want to give a URL, use the address of the Dynare website:
@uref{http://www.dynare.org}.

386
387
388
389
@node Installation and configuration
@chapter Installation and configuration

@menu
Sébastien Villemot's avatar
Sébastien Villemot committed
390
391
392
* Software requirements::
* Installation of Dynare::
* Configuration::
393
394
395
396
397
@end menu

@node Software requirements
@section Software requirements

398
Packaged versions of Dynare are available for Windows XP/Vista/7/8,
399
400
401
402
403
@uref{http://www.debian.org,Debian GNU/Linux},
@uref{http://www.ubuntu.com/,Ubuntu} and Mac OS X Leopard/Snow
Leopard.  Dynare should work on other systems, but some compilation
steps are necessary in that case.

404
In order to run Dynare, you need one of the following:
405

406
@itemize
407
408

@item
409
MATLAB version 7.3 (R2006b) or above;
410
411

@item
412
GNU Octave version 3.6 or above.
413
414
@end itemize

Sébastien Villemot's avatar
Sébastien Villemot committed
415
416
Packages of GNU Octave can be downloaded on the
@uref{http://www.dynare.org/download/octave,Dynare website}.
417

418
419
420
421
422
423
The following optional extensions are also useful to benefit from extra
features, but are in no way required:

@itemize

@item
424
425
If under MATLAB: the optimization toolbox, the statistics toolbox, the
control system toolbox;
426
427
428
429

@item
If under GNU Octave, the following
@uref{http://octave.sourceforge.net/,Octave-Forge} packages: optim,
430
io, java, statistics, control.
431
432
433

@end itemize

434
435
436
437
438
439
440
441
If you plan to use the @code{use_dll} option of the @code{model}
command, you will need to install the necessary requirements for
compiling MEX files on your machine. If you are using MATLAB under
Windows, install a C++ compiler on your machine and configure it with
MATLAB: see
@uref{http://www.dynare.org/DynareWiki/ConfigureMatlabWindowsForMexCompilation,instructions
on the Dynare wiki}. Users of Octave under Linux should install the
package for MEX file compilation (under Debian or Ubuntu, it is called
442
@file{liboctave-dev}). If you are
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
using Octave or MATLAB under Mac OS X, you should install the latest
version of XCode: see
@uref{http://www.dynare.org/DynareWiki/InstallOnMacOSX,instructions on
the Dynare wiki}. Mac OS X Octave users will also need to install
gnuplot if they want graphing capabilities. Users of MATLAB under
Linux and Mac OS X, and users of Octave under Windows, normally need
to do nothing, since a working compilation environment is available by
default.

@node Installation of Dynare
@section Installation of Dynare

After installation, Dynare can be used in any directory on your
computer. It is best practice to keep your model files in directories
different from the one containing the Dynare toolbox. That way you can
upgrade Dynare and discard the previous version without having to worry
about your own files.

@menu
Sébastien Villemot's avatar
Sébastien Villemot committed
462
463
464
465
* On Windows::
* On Debian GNU/Linux and Ubuntu::
* On Mac OS X::
* For other systems::
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
@end menu

@node On Windows
@subsection On Windows

Execute the automated installer called @file{dynare-4.@var{x}.@var{y}-win.exe}
(where 4.@var{x}.@var{y} is the version number), and follow the instructions. The
default installation directory is @file{c:\dynare\4.@var{x}.@var{y}}.

After installation, this directory will contain several sub-directories,
among which are @file{matlab}, @file{mex} and @file{doc}.

The installer will also add an entry in your Start Menu with a shortcut
to the documentation files and uninstaller.

Note that you can have several versions of Dynare coexisting (for
example in @file{c:\dynare}), as long as you correctly adjust your path
settings (@pxref{Some words of warning}).

@node On Debian GNU/Linux and Ubuntu
@subsection On Debian GNU/Linux and Ubuntu

Please refer to the
@uref{http://www.dynare.org/DynareWiki/InstallOnDebianOrUbuntu,Dynare
Wiki} for detailed instructions.

Dynare will be installed under @file{/usr/share/dynare} and
@file{/usr/lib/dynare}. Documentation will be under
@file{/usr/share/doc/dynare}.

@node On Mac OS X
@subsection On Mac OS X

Execute the automated installer called
Houtan Bastani's avatar
Houtan Bastani committed
500
@file{dynare-4.@var{x}.@var{y}.pkg} (where
501
502
503
504
505
506
507
508
509
510
511
512
4.@var{x}.@var{y} is the version number), and follow the
instructions. The default installation directory is
@file{/Applications/Dynare/4.@var{x}.@var{y}}.

Please refer to the
@uref{http://www.dynare.org/DynareWiki/InstallOnMacOSX,Dynare Wiki} for
detailed instructions.

After installation, this directory will contain several sub-directories,
among which are @file{matlab}, @file{mex} and @file{doc}.

Note that you can have several versions of Dynare coexisting (for
Houtan Bastani's avatar
Houtan Bastani committed
513
514
example in @file{/Applications/Dynare}), as long as you correctly
adjust your path settings (@pxref{Some words of warning}).
515
516
517
518
519
520
521
522
523

@node For other systems
@subsection For other systems

You need to download Dynare source code from the
@uref{http://www.dynare.org,Dynare website} and unpack it somewhere.

Then you will need to recompile the pre-processor and the dynamic
loadable libraries. Please refer to
524
@uref{https://github.com/DynareTeam/dynare/blob/master/README.md,README.md}.
525
526
527
528
529

@node Configuration
@section Configuration

@menu
Sébastien Villemot's avatar
Sébastien Villemot committed
530
531
532
* For MATLAB::
* For GNU Octave::
* Some words of warning::
533
534
535
536
537
538
539
540
@end menu

@node For MATLAB
@subsection For MATLAB

You need to add the @file{matlab} subdirectory of your Dynare
installation to MATLAB path. You have two options for doing that:

541
@itemize
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564

@item
Using the @code{addpath} command in the MATLAB command window:

Under Windows, assuming that you have installed Dynare in the standard
location, and replacing @code{4.@var{x}.@var{y}} with the correct
version number, type:

@example
addpath c:\dynare\4.@var{x}.@var{y}\matlab
@end example

Under Debian GNU/Linux or Ubuntu, type:

@example
addpath /usr/share/dynare/matlab
@end example

Under Mac OS X, assuming that you have installed Dynare in the standard
location, and replacing @code{4.@var{x}.@var{y}} with the correct version
number, type:

@example
Houtan Bastani's avatar
Houtan Bastani committed
565
addpath /Applications/Dynare/4.@var{x}.@var{y}/matlab
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
@end example

MATLAB will not remember this setting next time you run it, and you
will have to do it again.

@item
Via the menu entries:

Select the ``Set Path'' entry in the ``File'' menu, then click on
``Add Folder@dots{}'', and select the @file{matlab} subdirectory of your
Dynare installation. Note that you @emph{should not} use ``Add with
Subfolders@dots{}''. Apply the settings by clicking on ``Save''. Note that
MATLAB will remember this setting next time you run it.
@end itemize

@node For GNU Octave
@subsection For GNU Octave

You need to add the @file{matlab} subdirectory of your Dynare
installation to Octave path, using the @code{addpath} at the Octave
command prompt.

Under Windows, assuming that you have installed Dynare in the standard
location, and replacing ``4.@var{x}.@var{y}'' with the correct version
number, type:

@example
addpath c:\dynare\4.@var{x}.@var{y}\matlab
@end example

Under Debian GNU/Linux or Ubuntu, there is no need to use the
@code{addpath} command; the packaging does it for you.

Under Mac OS X, assuming that you have installed Dynare in the
standard location, and replacing ``4.@var{x}.@var{y}'' with the correct
version number, type:

@example
addpath /Applications/Dynare/4.@var{x}.@var{y}/matlab
@end example

If you don't want to type this command every time you run Octave, you
can put it in a file called @file{.octaverc} in your home directory
Houtan Bastani's avatar
Houtan Bastani committed
609
(under Windows this will generally be @file{c:\Documents and
610
611
Settings\USERNAME\} while under Mac OS X it is @file{/Users/USERNAME/}).
This file is run by Octave at every startup.
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627

@node Some words of warning
@subsection Some words of warning

You should be very careful about the content of your MATLAB or Octave
path. You can display its content by simply typing @code{path} in the
command window.

The path should normally contain system directories of MATLAB or Octave,
and some subdirectories of your Dynare installation. You have to
manually add the @file{matlab} subdirectory, and Dynare will
automatically add a few other subdirectories at runtime (depending on
your configuration). You must verify that there is no directory coming
from another version of Dynare than the one you are planning to use.

You have to be aware that adding other directories to your path can
Houtan Bastani's avatar
Houtan Bastani committed
628
629
potentially create problems if any of your M-files have the same name
as a Dynare file. Your file would then override the Dynare file, making
630
631
Dynare unusable.

632
633
@node Running Dynare
@chapter Running Dynare
634
635
636
637
638
639

In order to give instructions to Dynare, the user has to write a
@emph{model file} whose filename extension must be @file{.mod}. This
file contains the description of the model and the computing tasks
required by the user. Its contents is described in @ref{The Model file}.

640
641
@menu
* Dynare invocation::
642
* Dynare hooks::
643
644
645
646
647
648
* Understanding Preprocessor Error Messages::
@end menu

@node Dynare invocation
@section Dynare invocation

649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
Once the model file is written, Dynare is invoked using the
@code{dynare} command at the MATLAB or Octave prompt (with the filename
of the @file{.mod} given as argument).

In practice, the handling of the model file is done in two steps: in the
first one, the model and the processing instructions written by the user
in a @emph{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 @code{dynare} command.

@deffn {MATLAB/Octave command} dynare @var{FILENAME}[.mod] [@var{OPTIONS}@dots{}]

@descriptionhead

This command launches Dynare and executes the instructions included in
@file{@var{FILENAME}.mod}.  This user-supplied file contains the model
and the processing instructions, as described in @ref{The Model file}.

@code{dynare} begins by launching the preprocessor on the @file{.mod}
file.  By default (unless @code{use_dll} option has been given to
@code{model}), the preprocessor creates three intermediary files:

@table @file

@item @var{FILENAME}.m
Contains variable declarations, and computing tasks

@item @var{FILENAME}_dynamic.m
Contains the dynamic model equations

@item @var{FILENAME}_static.m
Contains the long run static model equations
@end table

@noindent
These files may be looked at to understand errors reported at the simulation stage.

@code{dynare} will then run the computing tasks by executing @file{@var{FILENAME}.m}.

@optionshead

@table @code

@item noclearall
By default, @code{dynare} will issue a @code{clear all} command to
MATLAB or Octave, thereby deleting all workspace variables; this options
instructs @code{dynare} not to clear the workspace

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

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

@item savemacro[=@var{FILENAME}]
Instructs @code{dynare} to save the intermediary file which is obtained
after macro-processing (@pxref{Macro-processing language}); the saved
output will go in the file specified, or if no file is specified in
@file{@var{FILENAME}-macroexp.mod}

@item onlymacro
Instructs the preprocessor to only perform the macro-processing step,
and stop just after. Mainly useful for debugging purposes or for using
the macro-processor independently of the rest of Dynare toolbox.

@item nolinemacro
Instructs the macro-preprocessor to omit line numbering information in
the intermediary @file{.mod} file created after the maco-processing
step. Useful in conjunction with @code{savemacro} when one wants that to
reuse the intermediary @file{.mod} file, without having it cluttered by
line numbering directives.

726
727
728
729
@item nolog
Instructs Dynare to no create a logfile of this run in
@file{@var{FILENAME}.log}. The default is to create the logfile.

730
731
732
@item nowarn
Suppresses all warnings.

733
734
735
736
737
738
739
740
741
@item warn_uninit
Display a warning for each variable or parameter which is not
initialized. @xref{Parameter initialization}, or
@ref{load_params_and_steady_state} for initialization of parameters.
@xref{Initial and terminal conditions}, or
@ref{load_params_and_steady_state} for initialization of endogenous
and exogenous variables.

@item console
742
743
744
Activate console mode. In addition to the behavior of
@code{nodisplay}, Dynare will not use graphical waitbars for long
computations.
745

746
747
748
749
@item nograph
Activate the @code{nograph} option (@xref{nograph}), so that Dynare will not produce any
graph

750
751
752
@item nointeractive
Instructs Dynare to not request user input

753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
@item cygwin
Tells Dynare that your MATLAB is configured for compiling MEX files with
Cygwin (@pxref{Software requirements}). This option is only available
under Windows, and is used in conjunction with @code{use_dll}.

@item msvc
Tells Dynare that your MATLAB is configured for compiling MEX files with
Microsoft Visual C++ (@pxref{Software requirements}). This option is
only available under Windows, and is used in conjunction with
@code{use_dll}.

@item parallel[=@var{CLUSTER_NAME}]
Tells Dynare to perform computations in parallel. If @var{CLUSTER_NAME}
is passed, Dynare will use the specified cluster to perform parallel
computations. Otherwise, Dynare will use the first cluster specified in
the configuration file. @xref{The Configuration File}, for more
information about the configuration file.

@item conffile=@var{FILENAME}
Specifies the location of the configuration file if it differs from the
default. @xref{The Configuration File}, for more information about the
configuration file and its default location.

@item parallel_slave_open_mode
Instructs Dynare to leave the connection to the slave node open after
computation is complete, closing this connection only when Dynare
finishes processing.

@item parallel_test
Tests the parallel setup specified in the configuration file without
executing the @file{.mod} file. @xref{The Configuration File}, for more
information about the configuration file.
785
786
787
788

@item -D@var{MACRO_VARIABLE}=@var{MACRO_EXPRESSION}
Defines a macro-variable from the command line (the same effect as using
the Macro directive @code{@@#define} in a model file, @pxref{Macro-processing language}).
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
@end table

@outputhead

Depending on the computing tasks requested in the @file{.mod} file,
executing command @code{dynare} will leave in the workspace variables
containing results available for further processing. More details are
given under the relevant computing tasks.

The @code{M_}, @code{oo_} and @code{options_} structures are also saved
in a file called @file{@var{FILENAME}_results.mat}.

@examplehead

@example
dynare ramst
805
dynare ramst.mod savemacro
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
@end example

@end deffn

The output of Dynare is left into three main variables in the
MATLAB/Octave workspace:

@defvr {MATLAB/Octave variable} M_
Structure containing various informations about the model.
@end defvr

@defvr {MATLAB/Octave variable} options_
Structure contains the values of the various options used by Dynare
during the computation.
@end defvr

@defvr {MATLAB/Octave variable} oo_
Structure containing the various results of the computations.
@end defvr

826
827
828
829
830
831
832
833
834
835

@node Dynare hooks
@section Dynare hooks

It is possible to call pre and post dynare preprocessor hooks written as matlab scripts.
The script @file{@var{FILENAME}_pre_dynare_preprocessor_hook.m} is executed before the
call to Dynare's preprocessor, and  can be used to programatically transform the mod file
that will be read by the preprocessor. The script @file{@var{FILENAME}_post_dynare_preprocessor_hook.m}
is executed just after the call to Dynare's preprocessor, and can be used to programatically
transform the files generated by Dynare's preprocessor before actual computations start. The
Houtan Bastani's avatar
Houtan Bastani committed
836
pre and/or post dynare preprocessor hooks are executed if and only if the aforementioned scripts
837
838
839
are detected in the same folder as the the model file, @file{@var{FILENAME}.mod}.


840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
@node Understanding Preprocessor Error Messages
@section Understanding Preprocessor Error Messages

If the preprocessor runs into an error while processing your
@file{.mod} file, it will issue an error. Due to the way that a parser
works, sometimes these errors can be misleading. Here, we aim to
demystify these error messages.

The preprocessor issues error messages of the form:
@enumerate
@item @code{ERROR: <<file.mod>>: line A, col B: <<error message>>}
@item @code{ERROR: <<file.mod>>: line A, cols B-C: <<error message>>}
@item @code{ERROR: <<file.mod>>: line A, col B - line C, col D: <<error message>>}
@end enumerate
@noindent The first two errors occur on a single line, with error
two spanning multiple columns. Error three spans multiple rows.

Often, the line and column numbers are precise, leading you directly
to the offending syntax. Infrequently however, because of the way the
parser works, this is not the case. The most common example of
misleading line and column numbers (and error message for that matter)
is the case of a missing semicolon, as seen in the following example:
@example
varexo a, b
parameters c, ...;
@end example
@noindent In this case, the parser doesn't know a semicolon is missing at the
end of the @code{varexo} command until it begins parsing the second
line and bumps into the @code{parameters} command. This is because we
allow commands to span multiple lines and, hence, the parser cannot
know that the second line will not have a semicolon on it until it
gets there. Once the parser begins parsing the second line, it
realizes that it has encountered a keyword, @code{parameters}, which
it did not expect. Hence, it throws an error of the form: @code{ERROR:
<<file.mod>>: line 2, cols 0-9: syntax error, unexpected
PARAMETERS}. In this case, you would simply place a semicolon at the
end of line one and the parser would continue processing.

878
879
880
881
@node The Model file
@chapter The Model file

@menu
Sébastien Villemot's avatar
Sébastien Villemot committed
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
* Conventions::
* Variable declarations::
* Expressions::
* Parameter initialization::
* Model declaration::
* Auxiliary variables::
* Initial and terminal conditions::
* Shocks on exogenous variables::
* Other general declarations::
* Steady state::
* Getting information about the model::
* Deterministic simulation::
* Stochastic solution and simulation::
* Estimation::
* Forecasting::
* Optimal policy::
* Sensitivity and identification analysis::
* Markov-switching SBVAR::
* Displaying and saving results::
* Macro-processing language::
* Misc commands::
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
@end menu

@node Conventions
@section Conventions

A model file contains a list of commands and of blocks.  Each command
and each element of a block is terminated by a semicolon
(@code{;}). Blocks are terminated by @code{end;}.

Most Dynare commands have arguments and several accept options,
indicated in parentheses after the command keyword. Several options
are separated by commas.

In the description of Dynare commands, the following conventions are
observed:

919
@itemize
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935

@item
optional arguments or options are indicated between square brackets:
@samp{[]};

@item
repreated arguments are indicated by ellipses: ``@dots{}'';

@item
mutually exclusive arguments are separated by vertical bars: @samp{|};

@item
@var{INTEGER} indicates an integer number;

@item
@var{DOUBLE} indicates a double precision number. The following syntaxes
936
937
are valid: @code{1.1e3}, @code{1.1E3}, @code{1.1d3}, @code{1.1D3}. In
some places, infinite values @code{Inf} and @code{-Inf} are also allowed;
938

Houtan Bastani's avatar
Houtan Bastani committed
939
940
941
942
@item
@var{NUMERICAL_VECTOR} indicates a vector of numbers separated by spaces,
enclosed by square brackets;

943
944
945
946
947
948
949
950
@item
@var{EXPRESSION} indicates a mathematical expression valid outside the
model description (@pxref{Expressions});

@item
@var{MODEL_EXPRESSION} indicates a mathematical expression valid in the
model description (@pxref{Expressions} and @ref{Model declaration});

951
952
953
954
@item
@var{MACRO_EXPRESSION} designates an expression of the macro-processor
(@pxref{Macro expressions});

955
956
957
958
959
960
961
962
963
964
965
@item
@var{VARIABLE_NAME} indicates a variable name starting with an
alphabetical character and can't contain: @samp{()+-*/^=!;:@@#.} or
accentuated characters;

@item
@var{PARAMETER_NAME} indicates a parameter name starting with an
alphabetical character and can't contain: @samp{()+-*/^=!;:@@#.} or
accentuated characters;

@item
966
967
@var{LATEX_NAME} indicates a valid @LaTeX{} expression in math mode
(not including the dollar signs);
968
969
970
971
972
973

@item
@var{FUNCTION_NAME} indicates a valid MATLAB function name;

@item
@var{FILENAME} indicates a filename valid in the underlying operating
974
975
system; it is necessary to put it between quotes when specifying the
extension or if the filename contains a non-alphanumeric character;
976
977
978
979
980
981
982
983
984
985

@end itemize

@node Variable declarations
@section Variable declarations

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

@deffn Command var @var{VARIABLE_NAME} [$@var{LATEX_NAME}$]@dots{};
@deffnx Command var (deflator = @var{MODEL_EXPRESSION}) @var{VARIABLE_NAME} [$@var{LATEX_NAME}$]@dots{};
986
@deffnx Command var (log_deflator = @var{MODEL_EXPRESSION}) @var{VARIABLE_NAME} [$@var{LATEX_NAME}$]@dots{};
987
988
989
990
991

@descriptionhead

This required command declares the endogenous variables in the
model. @xref{Conventions}, for the syntax of @var{VARIABLE_NAME} and
992
993
994
@var{MODEL_EXPRESSION}. Optionally it is possible to give a @LaTeX{}
name to the variable or, if it is nonstationary, provide information
regarding its deflator.
995
996
997
998
999
1000

@code{var} commands can appear several times in the file and Dynare will
concatenate them.

@optionshead