2008-07-04 16:30:46 +02:00
\documentclass { beamer}
\usepackage [utf8] { inputenc}
2015-06-08 14:55:05 +02:00
\usepackage [T1] { fontenc}
\usepackage { lmodern}
2008-07-04 16:30:46 +02:00
\usepackage { amsmath}
2015-06-08 14:55:05 +02:00
\usepackage [copyright] { ccicons}
2008-07-04 16:30:46 +02:00
2012-06-13 18:40:03 +02:00
\usetheme { Boadilla}
2008-07-04 16:30:46 +02:00
2018-06-06 15:22:12 +02:00
\title { The Dynare Macro Processor}
\subtitle { Dynare Summer School 2018}
2018-07-09 18:26:19 +02:00
\author { Sébastien Villemot and Houtan Bastani}
2015-06-08 14:55:05 +02:00
%\pgfdeclareimage[height=0.6cm]{logo}{logo-ofce}
2018-06-06 15:22:12 +02:00
\institute { CEPREMAP}
2018-07-09 18:25:39 +02:00
\date { July 9, 2018}
2008-07-04 16:30:46 +02:00
\AtBeginSection []
{
\begin { frame}
\frametitle { Outline}
\tableofcontents [currentsection]
\end { frame}
}
\begin { document}
\begin { frame}
\titlepage
\end { frame}
\begin { frame}
\frametitle { Outline}
\tableofcontents
\end { frame}
\section { Overview}
\begin { frame}
\frametitle { Motivation}
\begin { itemize}
2009-06-24 14:51:58 +02:00
\item The \textbf { Dynare language} (used in MOD files) is well suited for many economic models
2018-06-06 15:22:12 +02:00
\item But it lacks some useful features such as:
2008-07-04 16:30:46 +02:00
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item a loop mechanism for automatically repeating similar blocks of equations (e.g. multi-country models)
2008-07-04 16:30:46 +02:00
\item an operator for indexed sums or products inside equations
2018-06-06 15:22:12 +02:00
\item a mechanism for splitting up large MOD files into smaller, modular files
2008-07-04 16:30:46 +02:00
\item the possibility of conditionally including some equations or some runtime commands
\end { itemize}
\item The \textbf { Dynare Macro-language} was specifically designed to address these issues
\item Being flexible and fairly general, it can also be helpful in other situations
\end { itemize}
\end { frame}
\begin { frame}
\frametitle { Design of the macro-language}
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item The Dynare Macro-language provides a new set of \textbf { macro-commands} which can be used in MOD files
2008-07-04 16:30:46 +02:00
\item Language features include:
\begin { itemize}
\item file inclusion
2009-06-24 14:51:58 +02:00
\item loops (\textit { for} structure)
2012-01-02 17:06:25 +01:00
\item conditional inclusion (\textit { if/else} structures)
2008-07-04 16:30:46 +02:00
\item expression substitution
\end { itemize}
2018-06-06 15:22:12 +02:00
\item The macro processor transforms a MOD file with macro-commands into a MOD file without macro-commands (doing text expansions/inclusions) and then feeds it to the Dynare parser
\item The key point to understand is that the macro processor only does \textbf { text substitution} (like the C preprocessor or the PHP language)
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
\begin { frame}
2013-06-27 14:51:20 +02:00
\frametitle { Design of Dynare}
2008-07-04 16:30:46 +02:00
\includegraphics [width=0.95\linewidth] { new-design.pdf}
\end { frame}
\section { Syntax}
\begin { frame} [fragile=singleslide]
\frametitle { Macro Directives}
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item Directives begin with an at sign followed by a pound sign: \verb +@#+
\item A directive produces no output but gives instructions to the macro processor
2009-06-24 14:51:58 +02:00
\item Main directives are:
\begin { itemize}
\item file inclusion: \verb +@#include+
2018-06-06 15:22:12 +02:00
\item definition of a macro processor variable: \verb +@#define+
\item conditional statements: \verb +@#if/@#ifdef/@#ifndef/@#else/@#endif+
\item loop statements: \verb +@#for/@#endfor+
2009-06-24 14:51:58 +02:00
\end { itemize}
2018-06-06 15:22:12 +02:00
\item Most directives fit on one line. If needed however, two backslashes (i.e. \verb +\\ +) at the end of a line indicate that the directive is continued on the next line.
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
\begin { frame}
\frametitle { Variables}
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item The macro processor has its own list of variables which are different than model variables and MATLAB/Octave variables
2018-07-11 14:59:12 +02:00
\item There are 4 types of macro-variables:
2008-07-04 16:30:46 +02:00
\begin { itemize}
\item integer
2018-06-06 15:22:12 +02:00
\item string (declared between \textit { double} quotes)
\item integer array
\item string array
2018-07-11 14:59:12 +02:00
\end { itemize}
\item Macro-Functions are also supported
\begin { itemize}
\item only accept string aruments
\item must evaluate to a string
2008-07-04 16:30:46 +02:00
\end { itemize}
\item No boolean type:
\begin { itemize}
\item false is represented by integer zero
2018-06-06 15:22:12 +02:00
\item true is any non-zero integer
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Macro-expressions (1/2)}
2018-06-06 15:22:12 +02:00
It is possible to construct macro-expressions using standard operators.
2008-07-04 16:30:46 +02:00
\begin { block} { Operators on integers}
\begin { itemize}
2009-06-24 14:51:58 +02:00
\item arithmetic operators: \texttt { + - * /}
\item comparison operators: \texttt { < > <= >= == !=}
\item logical operators: \verb +& & || !+
2008-07-04 16:30:46 +02:00
\item integer ranges: \texttt { 1:4} is equivalent to integer array \texttt { [1,2,3,4]}
\end { itemize}
\end { block}
\begin { block} { Operators on character strings}
\begin { itemize}
2009-06-24 14:51:58 +02:00
\item comparison operators: \texttt { == !=}
2008-07-04 16:30:46 +02:00
\item concatenation: \texttt { +}
\item extraction of substrings: if \texttt { s} is a string, then one can write \texttt { s[3]} or \texttt { s[4:6]}
\end { itemize}
\end { block}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Macro-expressions (2/2)}
\begin { block} { Operators on arrays}
\begin { itemize}
\item dereferencing: if \texttt { v} is an array, then \texttt { v[2]} is its $ 2 ^ { \textrm { nd } } $ element
\item concatenation: \texttt { +}
\item difference \texttt { -} : returns the first operand from which the elements of the second operand have been removed
\item extraction of sub-arrays: \textit { e.g.} \texttt { v[4:6]}
2010-07-01 15:21:41 +02:00
\item testing membership of an array: \texttt { in} operator \\ (example:
\texttt { "b" in ["a", "b", "c"]} returns \texttt { 1} )
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { block}
2018-06-06 15:22:12 +02:00
Macro-expressions can be used in two places:
2008-07-04 16:30:46 +02:00
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item inside macro directives; no special markup is required
\item in the body of the MOD file, between an at sign and curly braces (like \verb +@{ expr} +); the macro processor will substitute the expression with its value
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Define directive}
The value of a macro-variable can be defined with the \verb +@#define+ directive.
\begin { block} { Syntax}
2018-07-09 18:25:39 +02:00
\verb +@#define +\textit { variable\_ name} \verb + = +\textit { expression} \\
\verb +@#define +\textit { function\_ name} (\textit { arg1} , [\textit { arg2} , ...])\verb + = +\textit { string\_ expression}
2008-07-04 16:30:46 +02:00
\end { block}
\begin { block} { Examples}
\begin { verbatim}
2018-07-09 18:25:39 +02:00
@#define x = 5 // Integer
@#define y = "US" // String
@#define v = [ 1, 2, 4 ] // Integer array
@#define w = [ "US", "EA" ] // String array
@#define z = 3 + v[2] // Equals 5
@#define t = ("US" in w) // Equals 1 (true)
@#define s = "@{ y} " // Equals "US"
@#define f(x) = " + @{ x} + @{ y} " // A function "f(x)" equal
// to " + @{ x} + US"
2008-07-04 16:30:46 +02:00
\end { verbatim}
\end { block}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Expression substitution}
\framesubtitle { Dummy example}
\begin { block} { Before macro-processing}
\begin { verbatim}
@#define x = [ "B", "C" ]
@#define i = 2
2018-07-09 18:25:39 +02:00
@#define f(x) = " + @{ x} "
2008-07-04 16:30:46 +02:00
model;
2018-07-09 18:25:39 +02:00
A = @{ x[i] + f("D")} ;
2008-07-04 16:30:46 +02:00
end;
\end { verbatim}
\end { block}
\begin { block} { After macro-processing}
\begin { verbatim}
model;
2018-07-09 18:25:39 +02:00
A = C + D;
2008-07-04 16:30:46 +02:00
end;
\end { verbatim}
\end { block}
\end { frame}
2017-06-28 18:19:10 +02:00
\begin { frame} [fragile=singleslide]
\frametitle { Inclusion directive (1/2)}
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item This directive simply inserts the text of another file in its place
2017-06-28 18:19:10 +02:00
\begin { block} { Syntax}
\verb +@#include "+\textit { filename} \verb +"+
\end { block}
\begin { block} { Example}
\begin { verbatim}
@#include "modelcomponent.mod"
\end { verbatim}
\end { block}
2018-06-06 15:22:12 +02:00
\item Equivalent to a copy/paste of the content of the included file
2017-06-28 18:19:10 +02:00
\item Note that it is possible to nest includes (\textit { i.e.} to include a
2018-06-06 15:22:12 +02:00
file with an included file)
2017-06-28 18:19:10 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Inclusion directive (2/2)}
\begin { itemize}
\item The filename can be given by a macro-variable (useful in loops):
\begin { block} { Example with variable}
\begin { verbatim}
@#define fname = "modelcomponent.mod"
@#include fname
\end { verbatim}
\end { block}
\item Files to include are searched for in current directory. Other directories can
be added with
\texttt { @includepath} directive, \texttt { -I} command line option or
\texttt { [paths]} section in config file.
\end { itemize}
\end { frame}
2008-07-04 16:30:46 +02:00
\begin { frame} [fragile=singleslide]
\frametitle { Loop directive}
\begin { block} { Syntax}
\verb +@#for +\textit { variable\_ name} \verb + in +\textit { array\_ expr} \\
\verb + +\textit { loop\_ body} \\
\verb +@#endfor+
\end { block}
\begin { block} { Example: before macro-processing}
\small
\begin { verbatim}
model;
@#for country in [ "home", "foreign" ]
2009-06-24 14:51:58 +02:00
GDP_ @{ country} = A * K_ @{ country} ^ a * L_ @{ country} ^ (1-a);
2008-07-04 16:30:46 +02:00
@#endfor
end;
\end { verbatim}
\normalsize
\end { block}
\begin { block} { Example: after macro-processing}
\small
\begin { verbatim}
model;
2009-06-24 14:51:58 +02:00
GDP_ home = A * K_ home^ a * L_ home^ (1-a);
GDP_ foreign = A * K_ foreign^ a * L_ foreign^ (1-a);
2008-07-04 16:30:46 +02:00
end;
\end { verbatim}
\normalsize
\end { block}
\end { frame}
\begin { frame} [fragile=singleslide]
2012-06-13 18:40:03 +02:00
\frametitle { Conditional inclusion directives (1/2)}
2008-07-04 16:30:46 +02:00
\begin { columns} [T]
\column { 0.47\linewidth }
\begin { block} { Syntax 1}
\verb +@#if +\textit { integer\_ expr} \\
\verb + +\textit { body included if expr != 0} \\
\verb +@#endif+
\end { block}
\column { 0.47\linewidth }
\begin { block} { Syntax 2}
\verb +@#if +\textit { integer\_ expr} \\
\verb + +\textit { body included if expr != 0} \\
\verb +@#else+ \\
\verb + +\textit { body included if expr == 0} \\
\verb +@#endif+
\end { block}
\end { columns}
\begin { block} { Example: alternative monetary policy rules}
\scriptsize
\begin { verbatim}
2009-06-24 14:51:58 +02:00
@#define linear_ mon_ pol = 0 // or 1
2008-07-04 16:30:46 +02:00
...
model;
@#if linear_ mon_ pol
2009-04-27 15:39:52 +02:00
i = w*i(-1) + (1-w)*i_ ss + w2*(pie-piestar);
2008-07-04 16:30:46 +02:00
@#else
2009-04-27 15:39:52 +02:00
i = i(-1)^ w * i_ ss^ (1-w) * (pie/piestar)^ w2;
2008-07-04 16:30:46 +02:00
@#endif
...
end;
\end { verbatim}
\scriptsize
\end { block}
\end { frame}
2012-06-13 18:40:03 +02:00
\begin { frame} [fragile=singleslide]
\frametitle { Conditional inclusion directives (2/2)}
\begin { columns} [T]
\column { 0.47\linewidth }
\begin { block} { Syntax 1}
\verb +@#ifdef +\textit { variable\_ name} \\
\verb + +\textit { body included if variable defined} \\
\verb +@#endif+
\end { block}
\column { 0.47\linewidth }
\begin { block} { Syntax 2}
\verb +@#ifdef +\textit { variable\_ name} \\
\verb + +\textit { body included if variable defined} \\
\verb +@#else+ \\
\verb + +\textit { body included if variable not defined} \\
\verb +@#endif+
\end { block}
\end { columns}
2013-06-27 14:51:20 +02:00
\bigskip
There is also \verb +@#ifndef+, which is the opposite of \verb +@#ifdef+
(\textit { i.e.} it tests whether a variable is \emph { not} defined).
2012-06-13 18:40:03 +02:00
\end { frame}
2008-07-04 16:30:46 +02:00
\begin { frame} [fragile=singleslide]
\frametitle { Echo and error directives}
\begin { itemize}
\item The echo directive will simply display a message on standard output
\item The error directive will display the message and make Dynare stop (only makes sense inside a conditional inclusion directive)
\end { itemize}
\begin { block} { Syntax}
\verb +@#echo +\textit { string\_ expr} \\
\verb +@#error +\textit { string\_ expr}
\end { block}
\begin { block} { Examples}
\begin { verbatim}
@#echo "Information message."
@#error "Error message!"
\end { verbatim}
\end { block}
\end { frame}
\begin { frame}
\frametitle { Saving the macro-expanded MOD file}
\begin { itemize}
2018-06-06 15:22:12 +02:00
\item For \textbf { debugging or learning} purposes, it is possible to save the output of the macro processor
2009-06-24 14:51:58 +02:00
\item This output is a valid MOD file, obtained after processing the macro-commands of the original MOD file
\item Just add the \texttt { savemacro} option on the Dynare command line (after the name of your MOD file)
2008-07-04 16:30:46 +02:00
\item If MOD file is \texttt { filename.mod} , then the macro-expanded version will be saved in \texttt { filename-macroexp.mod}
2010-07-01 15:21:41 +02:00
\item You can specify the filename for the macro-expanded version with the syntax \texttt { savemacro=mymacroexp.mod}
2018-06-06 15:22:12 +02:00
\item To end processing when macro processing is finished, add the option \texttt { onlymacro} to the Dynare command line
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
2018-06-06 15:22:12 +02:00
\section { Common uses}
2008-07-04 16:30:46 +02:00
\begin { frame} [fragile=singleslide]
\frametitle { Modularization}
\begin { itemize}
2009-06-24 14:51:58 +02:00
\item The \verb +@#include+ directive can be used to split MOD files into several modular components
2008-07-04 16:30:46 +02:00
\item Example setup:
2009-06-24 14:51:58 +02:00
\begin { description}
\item [\texttt{modeldesc.mod}:] contains variable declarations, model equations and shocks declarations
2012-10-31 16:49:09 +01:00
\item [\texttt{simulate.mod}:] includes \texttt { modeldesc.mod} , calibrates parameters and runs stochastic simulations
2009-06-24 14:51:58 +02:00
\item [\texttt{estim.mod}:] includes \texttt { modeldesc.mod} , declares priors on parameters and runs bayesian estimation
\end { description}
2012-10-31 16:49:09 +01:00
\item Dynare can be called on \texttt { simulate.mod} and \texttt { estim.mod}
2009-06-24 14:51:58 +02:00
\item But it makes no sense to run it on \texttt { modeldesc.mod}
\item Advantage: no need to manually copy/paste the whole model (at the beginning) or changes to the model (during development)
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Indexed sums or products}
\framesubtitle { Example: moving average}
\begin { columns} [T]
\column { 0.47\linewidth }
\begin { block} { Before macro-processing}
\begin { verbatim}
@#define window = 2
var x MA_ x;
...
model;
...
MA_ x = 1/@{ 2*window+1} *(
@#for i in -window:window
+x(@{ i} )
@#endfor
);
...
end;
\end { verbatim}
\end { block}
\column { 0.47\linewidth }
\begin { block} { After macro-processing}
\begin { verbatim}
var x MA_ x;
...
model;
...
MA_ x = 1/5*(
+x(-2)
+x(-1)
+x(0)
+x(1)
+x(2)
);
...
end;
\end { verbatim}
\end { block}
\end { columns}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Multi-country models}
2009-06-24 14:51:58 +02:00
\framesubtitle { MOD file skeleton example}
2008-07-04 16:30:46 +02:00
\scriptsize
\begin { verbatim}
2009-06-24 14:51:58 +02:00
@#define countries = [ "US", "EA", "AS", "JP", "RC" ]
2008-07-04 16:30:46 +02:00
@#define nth_ co = "US"
@#for co in countries
var Y_ @{ co} K_ @{ co} L_ @{ co} i_ @{ co} E_ @{ co} ...;
parameters a_ @{ co} ...;
varexo ...;
@#endfor
model;
@#for co in countries
Y_ @{ co} = K_ @{ co} ^ a_ @{ co} * L_ @{ co} ^ (1-a_ @{ co} );
...
@# if co != nth_ co
(1+i_ @{ co} ) = (1+i_ @{ nth_ co} ) * E_ @{ co} (+1) / E_ @{ co} ; // UIP relation
@# else
E_ @{ co} = 1;
@# endif
@#endfor
end;
\end { verbatim}
\normalsize
\end { frame}
\begin { frame}
2009-03-13 17:34:56 +01:00
\frametitle { Endogeneizing parameters (1/4)}
2008-07-04 16:30:46 +02:00
\begin { itemize}
\item When doing the steady-state calibration of the model, it may be useful to consider a parameter as an endogenous (and vice-versa)
\item Example:
\begin { gather*}
y = \left (\alpha ^ { \frac { 1} { \xi } } \ell ^ { 1-\frac { 1} { \xi } } + (1-\alpha )^ { \frac { 1} { \xi } } k^ { 1-\frac { 1} { \xi } } \right )^ { \frac { \xi } { \xi - 1} } \\
lab\_ rat = \frac { w \ell } { p y}
\end { gather*}
2009-03-13 17:34:56 +01:00
\item In the model, $ \alpha $ is a (share) parameter, and $ lab \_ rat $ is an endogenous variable
\item We observe that:
\begin { itemize}
\item calibrating $ \alpha $ is not straigthforward!
\item on the contrary, we have real world data for $ lab \_ rat $
\item it is clear that these two variables are economically linked
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Endogeneizing parameters (2/4)}
\begin { itemize}
\item Therefore, when computing the steady state:
\begin { itemize}
\item we make $ \alpha $ an endogenous variable and $ lab \_ rat $ a parameter
\item we impose an economically relevant value for $ lab \_ rat $
\item the solution algorithm deduces the implied value for $ \alpha $
\end { itemize}
\item We call this method ``variable flipping''
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
2009-03-13 17:34:56 +01:00
\frametitle { Endogeneizing parameters (3/4)}
\framesubtitle { Example implementation}
2008-07-04 16:30:46 +02:00
\begin { itemize}
2009-03-13 17:34:56 +01:00
\item File \texttt { modeqs.mod} :
\begin { itemize}
\item contains variable declarations and model equations
\item For declaration of \texttt { alpha} and \texttt { lab\_ rat} :
2008-07-04 16:30:46 +02:00
\footnotesize
\begin { verbatim}
@#if steady
var alpha;
parameter lab_ rat;
@#else
parameter alpha;
var lab_ rat;
@#endif
\end { verbatim}
\normalsize
\end { itemize}
2009-03-13 17:34:56 +01:00
2008-07-04 16:30:46 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
2009-03-13 17:34:56 +01:00
\frametitle { Endogeneizing parameters (4/4)}
\framesubtitle { Example implementation}
2008-07-04 16:30:46 +02:00
\begin { itemize}
2012-10-31 16:49:09 +01:00
\item File \texttt { steadystate.mod} :
2009-03-13 17:34:56 +01:00
\begin { itemize}
\item begins with \verb +@#define steady = 1+
\item then with \verb +@#include "modeqs.mod"+
\item initializes parameters (including \texttt { lab\_ rat} , excluding \texttt { alpha} )
\item computes steady state (using guess values for endogenous, including \texttt { alpha} )
2009-06-24 14:51:58 +02:00
\item saves values of parameters and endogenous at steady-state in a file, using the \texttt { save\_ params\_ and\_ steady\_ state} command
2009-03-13 17:34:56 +01:00
\end { itemize}
2012-10-31 16:49:09 +01:00
\item File \texttt { simulate.mod} :
2008-07-04 16:30:46 +02:00
\begin { itemize}
\item begins with \verb +@#define steady = 0+
\item then with \verb +@#include "modeqs.mod"+
2009-06-24 14:51:58 +02:00
\item loads values of parameters and endogenous at steady-state from file, using the \texttt { load\_ params\_ and\_ steady\_ state} command
2008-07-04 16:30:46 +02:00
\item computes simulations
\end { itemize}
\end { itemize}
\end { frame}
2010-07-01 15:21:41 +02:00
\begin { frame} [fragile=singleslide]
2018-06-06 15:22:12 +02:00
\frametitle { MATLAB/Octave loops vs macro processor loops (1/3)}
2010-07-01 15:21:41 +02:00
Suppose you have a model with a parameter $ \rho $ , and you want to make
simulations for three values: $ \rho = 0 . 8 , 0 . 9 , 1 $ . There are
several ways of doing this:
2015-06-08 14:55:05 +02:00
\begin { block} { With a MATLAB/Octave loop}
2010-07-01 15:21:41 +02:00
\begin { verbatim}
rhos = [ 0.8, 0.9, 1];
for i = 1:length(rhos)
rho = rhos(i);
stoch_ simul(order=1);
end
\end { verbatim}
\end { block}
\begin { itemize}
\item The loop is not unrolled
2015-06-08 14:55:05 +02:00
\item MATLAB/Octave manages the iterations
2010-07-01 15:21:41 +02:00
\item Interesting when there are a lot of iterations
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
2018-06-06 15:22:12 +02:00
\frametitle { MATLAB/Octave loops vs macro processor loops (2/3)}
\begin { block} { With a macro processor loop (case 1)}
2010-07-01 15:21:41 +02:00
\begin { verbatim}
rhos = [ 0.8, 0.9, 1];
@#for i in 1:3
rho = rhos(@{ i} );
stoch_ simul(order=1);
@#endfor
\end { verbatim}
\end { block}
\begin { itemize}
\item Very similar to previous example
\item Loop is unrolled
2018-06-06 15:22:12 +02:00
\item Dynare macro processor manages the loop index but not the data array (\texttt { rhos} )
2010-07-01 15:21:41 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile=singleslide]
2018-06-06 15:22:12 +02:00
\frametitle { MATLAB/Octave loops vs macro processor loops (3/3)}
\begin { block} { With a macro processor loop (case 2)}
2010-07-01 15:21:41 +02:00
\begin { verbatim}
@#for rho_ val in [ "0.8", "0.9", "1"]
rho = @{ rho_ val} ;
stoch_ simul(order=1);
@#endfor
\end { verbatim}
\end { block}
\begin { itemize}
\item Advantage: shorter syntax, since list of values directly given in the loop construct
2018-06-06 15:22:12 +02:00
\item Note that values are given as character strings (the macro processor does not
2010-07-01 15:21:41 +02:00
know floating point values)
2015-06-08 14:55:05 +02:00
\item Inconvenient: can not reuse an array stored in a MATLAB/Octave variable
2010-07-01 15:21:41 +02:00
\end { itemize}
\end { frame}
2008-07-04 16:30:46 +02:00
2011-06-16 16:15:02 +02:00
% \begin{frame}[fragile=singleslide]
% \frametitle{Possible future developments}
% \begin{itemize}
% \item Find a nicer syntax for indexed sums/products
% \item Implement other control structures: \texttt{elsif}, \texttt{switch/case}, \texttt{while/until} loops
% \item Implement macro-functions (or templates), with a syntax like:
% \small
% \verb+@#define QUADRATIC_COST(x, x_ss, phi) = phi/2*(x/x_ss-1)^2+
% \normalsize
% \end{itemize}
% \end{frame}
2008-07-04 16:30:46 +02:00
2015-06-08 14:55:05 +02:00
\begin { frame}
\begin { center}
\vfill { \LARGE Thanks for your attention!} \vfill
{ \LARGE Questions?}
\vfill
\end { center}
\vfill
\begin { columns} [T]
\column { 0.2\textwidth }
\column { 0.09\textwidth }
\ccbysa
\column { 0.71\textwidth }
\tiny
2017-06-28 18:19:10 +02:00
Copyright © 2008--2017 Dynare Team \\
2015-06-08 14:55:05 +02:00
Licence: \href { http://creativecommons.org/licenses/by-sa/4.0/} { Creative
Commons Attribution-ShareAlike 4.0}
\end { columns}
\end { frame}
2008-07-04 16:30:46 +02:00
\end { document}