dynare.texi 301 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
119
120
121
122
123
124
125
126
127
128
129
130
* Introduction::                
* Installation and configuration::  
* Running Dynare::              
* The Model file::              
* The Configuration File::      
* Time Series::                 
* 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

137
138
139
* What is Dynare ?::            
* Documentation sources::       
* Citing Dynare in your research::  
140
141
142

Installation and configuration

143
144
145
* Software requirements::       
* Installation of Dynare::      
* Configuration::               
146
147
148

Installation of Dynare

149
150
151
152
* On Windows::                  
* On Debian GNU/Linux and Ubuntu::  
* On Mac OS X::                 
* For other systems::           
153
154
155

Configuration

156
157
158
* For MATLAB::                  
* For GNU Octave::              
* Some words of warning::       
159

160
161
Running Dynare

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

166
167
The Model file

168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
* 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::   
* Verbatim inclusion::          
* Misc commands::               
190
191
192

Expressions

193
194
195
196
* Parameters and variables::    
* Operators::                   
* Functions::                   
* A few words of warning in stochastic context::  
197
198
199

Parameters and variables

200
201
* Inside the model::            
* Outside the model::           
202
203
204

Functions

205
206
* Built-in Functions::          
* External Functions::          
207
208
209

Steady state

210
211
212
* Finding the steady state with Dynare nonlinear solver::  
* Using a steady state file::   
* Replace some equations during steady state computations::  
213
214
215

Stochastic solution and simulation

216
217
218
219
220
* Computing the stochastic solution::  
* Typology and ordering of variables::  
* First order approximation::   
* Second order approximation::  
* Third order approximation::   
221

222
223
Sensitivity and identification analysis

224
225
226
227
228
229
230
* Sampling::                    
* Stability Mapping::           
* Reduced Form Mapping::        
* RMSE::                        
* Screening Analysis::          
* Identification Analysis::     
* Performing Sensitivity and Identification Analysis::  
231

232
233
Macro-processing language

234
235
236
237
* Macro expressions::           
* Macro directives::            
* Typical usages::              
* MATLAB/Octave loops versus macro-processor loops::  
238
239
240

Typical usages

241
242
243
244
* Modularization::              
* Indexed sums or products::    
* Multi-country models::        
* Endogeneizing parameters::    
245

246
247
The Configuration File

248
249
* Dynare Configuration::        
* Parallel Configuration::      
250
251
252
253
254
255
256
257

@end detailmenu
@end menu

@node Introduction
@chapter Introduction

@menu
258
259
260
* What is Dynare ?::            
* Documentation sources::       
* Citing Dynare in your research::  
261
262
263
264
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
@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
323
324
325
326
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é
327
(Université du Maine, Gains and Cepremap), Junior Maih (Norges Bank),
Sébastien Villemot's avatar
Sébastien Villemot committed
328
Ferhat Mihoubi (Université Paris-Est Créteil, Epee and Cepremap), George
329
Perendia, Johannes Pfeifer (University of Mannheim), Marco Ratto (JRC)
Sébastien Villemot's avatar
Sébastien Villemot committed
330
and Sébastien Villemot (Cepremap).
331
332
333
334
335
336
337
338
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.
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362

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

363
364
365
366
367
368
369
@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
370
371
372
373
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
374
375
376
377
378
379
380
381
@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}.

382
383
384
385
@node Installation and configuration
@chapter Installation and configuration

@menu
386
387
388
* Software requirements::       
* Installation of Dynare::      
* Configuration::               
389
390
391
392
393
@end menu

@node Software requirements
@section Software requirements

394
Packaged versions of Dynare are available for Windows XP/Vista/7/8,
395
396
397
398
399
@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.

400
In order to run Dynare, you need one of the following:
401

402
@itemize
403
404

@item
405
MATLAB version 7.3 (R2006b) or above;
406
407

@item
408
GNU Octave version 3.6 or above.
409
410
@end itemize

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

414
415
416
417
418
419
The following optional extensions are also useful to benefit from extra
features, but are in no way required:

@itemize

@item
420
421
If under MATLAB: the optimization toolbox, the statistics toolbox, the
control system toolbox;
422
423
424
425

@item
If under GNU Octave, the following
@uref{http://octave.sourceforge.net/,Octave-Forge} packages: optim,
426
io, java, statistics, control.
427
428
429

@end itemize

430
431
432
433
434
435
436
437
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
438
@file{liboctave-dev}). If you are
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
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
458
459
460
461
* On Windows::                  
* On Debian GNU/Linux and Ubuntu::  
* On Mac OS X::                 
* For other systems::           
462
463
464
465
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
@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
496
@file{dynare-4.@var{x}.@var{y}.pkg} (where
497
498
499
500
501
502
503
504
505
506
507
508
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
509
510
example in @file{/Applications/Dynare}), as long as you correctly
adjust your path settings (@pxref{Some words of warning}).
511
512
513
514
515
516
517
518
519

@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
520
@uref{https://github.com/DynareTeam/dynare/blob/master/README.md,README.md}.
521
522
523
524
525

@node Configuration
@section Configuration

@menu
526
527
528
* For MATLAB::                  
* For GNU Octave::              
* Some words of warning::       
529
530
531
532
533
534
535
536
@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:

537
@itemize
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560

@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
561
addpath /Applications/Dynare/4.@var{x}.@var{y}/matlab
562
563
564
565
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
@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
605
(under Windows this will generally be @file{c:\Documents and
606
607
Settings\USERNAME\} while under Mac OS X it is @file{/Users/USERNAME/}).
This file is run by Octave at every startup.
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623

@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
624
625
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
626
627
Dynare unusable.

628
629
@node Running Dynare
@chapter Running Dynare
630
631
632
633
634
635

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

636
@menu
637
638
639
* Dynare invocation::           
* Dynare hooks::                
* Understanding Preprocessor Error Messages::  
640
641
642
643
644
@end menu

@node Dynare invocation
@section Dynare invocation

645
646
647
648
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
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
Johannes Pfeifer's avatar
Johannes Pfeifer committed
674
675
676
@vindex M_.lead_lag_incidence
Contains the dynamic model equations. Note that Dynare might introduce auxiliary equations and variables (@pxref{Auxiliary variables}). Outputs are the residuals of the dynamic model equations in the order the equations were declared and the Jacobian of the dynamic model equations. For higher order approximations also the Hessian and the third-order derivates are provided. When computing the Jacobian of the dynamic model, the order of the endogenous variables in the columns is stored in @code{M_.lead_lag_incidence}. The rows of this matrix represent time periods: the first row denotes a lagged (time t-1) variable, the second row a contemporaneous (time t) variable, and the third row a leaded (time t+1) variable. The colums of the matrix represent the endogenous variables in their order of declaration. A zero in the matrix means that this endogenous does not appear in the model in this time period. The value in the @code{M_.lead_lag_incidence} matrix corresponds to the column of that variable in the Jacobian of the dynamic model. Example: Let the second declared variable be @code{c} and the @code{(3,2)} entry of @code{M_.lead_lag_incidence} be @code{15}. Then the @code{15}th column of the Jacobian is the derivative with respect to @code{y(+1)}. 
 
677
@item @var{FILENAME}_static.m
Johannes Pfeifer's avatar
Johannes Pfeifer committed
678
Contains the long run static model equations. Note that Dynare might introduce auxiliary equations and variables (@pxref{Auxiliary variables}). Outputs are the residuals of the static model equations in the order the equations were declared and the Jacobian of the static equations. Entry @code{(i,j)} of the Jacobian represents the derivative of the @code{i}th static model equation with respect to the @code{j}th model variable in declaration order. 
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
@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.

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

727
728
729
@item nowarn
Suppresses all warnings.

730
731
732
733
734
735
736
737
738
@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
739
740
741
Activate console mode. In addition to the behavior of
@code{nodisplay}, Dynare will not use graphical waitbars for long
computations.
742

743
744
745
746
@item nograph
Activate the @code{nograph} option (@xref{nograph}), so that Dynare will not produce any
graph

747
748
749
@item nointeractive
Instructs Dynare to not request user input

750
751
752
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
@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.
782
783
784
785

@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}).
786
787

@item nostrict
788
789
790
Allows Dynare to issue a warning and continue processing when
@enumerate
@item there are more endogenous variables than equations
791
@item an undeclared symbol is assigned in @code{initval} or @code{endval}
792
@end enumerate
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
@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
809
dynare ramst.mod savemacro
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
@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

830
831
832
833
834
835
836
837
838
839

@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
840
pre and/or post dynare preprocessor hooks are executed if and only if the aforementioned scripts
841
842
843
are detected in the same folder as the the model file, @file{@var{FILENAME}.mod}.


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
878
879
880
881
@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.

882
883
884
885
@node The Model file
@chapter The Model file

@menu
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
* 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::   
* Verbatim inclusion::          
* Misc commands::               
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
@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:

924
@itemize
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940

@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
941
942
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;
943

Houtan Bastani's avatar
Houtan Bastani committed
944
945
946
947
@item
@var{NUMERICAL_VECTOR} indicates a vector of numbers separated by spaces,
enclosed by square brackets;

948
949
950
951
952
953
954
955
@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});

956
957
958
959
@item
@var{MACRO_EXPRESSION} designates an expression of the macro-processor
(@pxref{Macro expressions});

960
961
962
963
964
965
966
967
968
969
970
@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
971
972
@var{LATEX_NAME} indicates a valid @LaTeX{} expression in math mode
(not including the dollar signs);
973
974
975
976
977
978

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

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

@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{};
991
@deffnx Command var (log_deflator = @var{MODEL_EXPRESSION}) @var{VARIABLE_NAME} [$@var{LATEX_NAME}$]@dots{};
992
993
994
995
996

@descriptionhead

This required command declares the endogenous variables in the
model. @xref{Conventions}, for the syntax of @var{VARIABLE_NAME} and
997
998
999
@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.
1000