Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
  • chskcau/dynare-doc-fixes
27 results
Select Git revision
Show changes
Showing
with 23643 additions and 6462 deletions
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usetheme{Boadilla}
\title{The Dynare Macro-processor}
\subtitle{Dynare Summer School 2013}
\author{Sébastien Villemot}
\institute{CEPREMAP}
\date{June 28, 2013}
\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}
\item The \textbf{Dynare language} (used in MOD files) is well suited for many economic models
\item However, as such, it lacks some useful features, such as:
\begin{itemize}
\item a loop mechanism for automatically repeating similar blocks of equations (such as in multi-country models)
\item an operator for indexed sums or products inside equations
\item a mechanism for splitting large MOD files in smaller modular files
\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}
\item The Dynare Macro-language provides a new set of \textbf{macro-commands} which can be inserted inside MOD files
\item Language features include:
\begin{itemize}
\item file inclusion
\item loops (\textit{for} structure)
\item conditional inclusion (\textit{if/else} structures)
\item expression substitution
\end{itemize}
\item Implemented in Dynare starting from version 4.0
\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)
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Design of Dynare}
\includegraphics[width=0.95\linewidth]{new-design.pdf}
\end{frame}
\section{Syntax}
\begin{frame}[fragile=singleslide]
\frametitle{Macro Directives}
\begin{itemize}
\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
\item Main directives are:
\begin{itemize}
\item file inclusion: \verb+@#include+
\item definition a variable of the macro-processor: \verb+@#define+
\item conditional statements (\verb+@#if/@#ifdef/@#ifndef/@#else/@#endif+)
\item loop statements (\verb+@#for/@#endfor+)
\end{itemize}
\item In most cases, directives occupy exactly one line of text. In case of need, two anti-slashes (\verb+\\+) at the end of the line indicates that the directive is continued on the next line.
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Inclusion directive}
\begin{itemize}
\item This directive simply includes the content of another file at the place where it is inserted.
\begin{block}{Syntax}
\verb+@#include "+\textit{filename}\verb+"+
\end{block}
\begin{block}{Example}
\begin{verbatim}
@#include "modelcomponent.mod"
\end{verbatim}
\end{block}
\item Exactly equivalent to a copy/paste of the content of the included file
\item Note that it is possible to nest includes (\textit{i.e.} to include a file from an included file)
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Variables}
\begin{itemize}
\item The macro processor maintains its own list of variables (distinct of model variables and of MATLAB variables)
\item Macro-variables can be of four types:
\begin{itemize}
\item integer
\item character string (declared between \textit{double} quotes)
\item array of integers
\item array of strings
\end{itemize}
\item No boolean type:
\begin{itemize}
\item false is represented by integer zero
\item true is any non-null integer
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Macro-expressions (1/2)}
It is possible to construct macro-expressions, using standard operators.
\begin{block}{Operators on integers}
\begin{itemize}
\item arithmetic operators: \texttt{+ - * /}
\item comparison operators: \texttt{< > <= >= == !=}
\item logical operators: \verb+&& || !+
\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}
\item comparison operators: \texttt{== !=}
\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]}
\item testing membership of an array: \texttt{in} operator \\ (example:
\texttt{"b" in ["a", "b", "c"]} returns \texttt{1})
\end{itemize}
\end{block}
Macro-expressions can be used at two places:
\begin{itemize}
\item inside macro directives, directly
\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
\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}
\verb+@#define +\textit{variable\_name}\verb+ = +\textit{expression}
\end{block}
\begin{block}{Examples}
\begin{verbatim}
@#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)
\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
model;
A = @{x[i]};
end;
\end{verbatim}
\end{block}
\begin{block}{After macro-processing}
\begin{verbatim}
model;
A = C;
end;
\end{verbatim}
\end{block}
\end{frame}
\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" ]
GDP_@{country} = A * K_@{country}^a * L_@{country}^(1-a);
@#endfor
end;
\end{verbatim}
\normalsize
\end{block}
\begin{block}{Example: after macro-processing}
\small
\begin{verbatim}
model;
GDP_home = A * K_home^a * L_home^(1-a);
GDP_foreign = A * K_foreign^a * L_foreign^(1-a);
end;
\end{verbatim}
\normalsize
\end{block}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Conditional inclusion directives (1/2)}
\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}
@#define linear_mon_pol = 0 // or 1
...
model;
@#if linear_mon_pol
i = w*i(-1) + (1-w)*i_ss + w2*(pie-piestar);
@#else
i = i(-1)^w * i_ss^(1-w) * (pie/piestar)^w2;
@#endif
...
end;
\end{verbatim}
\scriptsize
\end{block}
\end{frame}
\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}
\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).
\end{frame}
\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}
\item For \textbf{debugging or learning} purposes, it is possible to save the output of the macro-processor
\item This output is a valid MOD file, obtained after processing the macro-commands of the original MOD file
% \item Useful to understand how the macro-processor works
\item Just add the \texttt{savemacro} option on the Dynare command line (after the name of your MOD file)
\item If MOD file is \texttt{filename.mod}, then the macro-expanded version will be saved in \texttt{filename-macroexp.mod}
\item You can specify the filename for the macro-expanded version with the syntax \texttt{savemacro=mymacroexp.mod}
\end{itemize}
\end{frame}
% \begin{frame}
% \frametitle{Note on error messages}
% \end{frame}
\section{Typical usages}
\begin{frame}[fragile=singleslide]
\frametitle{Modularization}
\begin{itemize}
\item The \verb+@#include+ directive can be used to split MOD files into several modular components
\item Example setup:
\begin{description}
\item[\texttt{modeldesc.mod}:] contains variable declarations, model equations and shocks declarations
\item[\texttt{simulate.mod}:] includes \texttt{modeldesc.mod}, calibrates parameters and runs stochastic simulations
\item[\texttt{estim.mod}:] includes \texttt{modeldesc.mod}, declares priors on parameters and runs bayesian estimation
\end{description}
\item Dynare can be called on \texttt{simulate.mod} and \texttt{estim.mod}
\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)
\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}
\framesubtitle{MOD file skeleton example}
\scriptsize
\begin{verbatim}
@#define countries = [ "US", "EA", "AS", "JP", "RC" ]
@#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}
\frametitle{Endogeneizing parameters (1/4)}
\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*}
\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''
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (3/4)}
\framesubtitle{Example implementation}
\begin{itemize}
\item File \texttt{modeqs.mod}:
\begin{itemize}
\item contains variable declarations and model equations
\item For declaration of \texttt{alpha} and \texttt{lab\_rat}:
\footnotesize
\begin{verbatim}
@#if steady
var alpha;
parameter lab_rat;
@#else
parameter alpha;
var lab_rat;
@#endif
\end{verbatim}
\normalsize
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (4/4)}
\framesubtitle{Example implementation}
\begin{itemize}
\item File \texttt{steadystate.mod}:
\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})
\item saves values of parameters and endogenous at steady-state in a file, using the \texttt{save\_params\_and\_steady\_state} command
\end{itemize}
\item File \texttt{simulate.mod}:
\begin{itemize}
\item begins with \verb+@#define steady = 0+
\item then with \verb+@#include "modeqs.mod"+
\item loads values of parameters and endogenous at steady-state from file, using the \texttt{load\_params\_and\_steady\_state} command
\item computes simulations
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{MATLAB loops vs macro-processor loops (1/3)}
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:
\begin{block}{With a MATLAB loop}
\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
\item MATLAB manages the iterations
\item Interesting when there are a lot of iterations
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{MATLAB loops vs macro-processor loops (2/3)}
\begin{block}{With a macro-processor loop (case 1)}
\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
\item Dynare macro-processor manages the loop index but not the data array (\texttt{rhos})
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{MATLAB loops vs macro-processor loops (3/3)}
\begin{block}{With a macro-processor loop (case 2)}
\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
\item Note that values are given as character strings (the macro-processor does not
know floating point values)
\item Inconvenient: can not reuse an array stored in a MATLAB variable
\end{itemize}
\end{frame}
% \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}
\end{document}
File deleted
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="862.10712"
height="382.82141"
id="svg5540"
sodipodi:version="0.32"
inkscape:version="0.45.1"
version="1.0"
sodipodi:docbase="K:\Commun\Villemot\Macroprocessor"
sodipodi:docname="new-design.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="K:\Commun\Villemot\Macroprocessor\new-design.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs5542">
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0"
refX="0"
id="Arrow1Lend"
style="overflow:visible">
<path
id="path3243"
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="488.94636"
inkscape:cy="380.52134"
inkscape:document-units="px"
inkscape:current-layer="layer1"
width="1052.3622px"
height="744.09448px"
inkscape:window-width="1024"
inkscape:window-height="712"
inkscape:window-x="-4"
inkscape:window-y="-4" />
<metadata
id="metadata5545">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-78.642861,-39.058769)">
<g
id="g4418"
transform="translate(467.50002,289.64286)">
<text
sodipodi:linespacing="125%"
id="text4420"
y="56.6479"
x="361.42862"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
id="tspan4422"
y="56.6479"
x="361.42862"
sodipodi:role="line">Matlab files</tspan><tspan
id="tspan4424"
y="81.6479"
x="361.42862"
sodipodi:role="line">representing</tspan><tspan
id="tspan4426"
y="106.6479"
x="361.42862"
sodipodi:role="line">the model</tspan></text>
<path
transform="matrix(1.0528522,0,0,1.0682674,-22.862484,-9.0197689)"
d="M 431.42857 79.808769 A 66.428574 51.42857 0 1 1 298.57143,79.808769 A 66.428574 51.42857 0 1 1 431.42857 79.808769 z"
sodipodi:ry="51.42857"
sodipodi:rx="66.428574"
sodipodi:cy="79.808769"
sodipodi:cx="365"
id="path4428"
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
</g>
<g
id="g4430"
transform="translate(-555.35711,282.49999)">
<text
sodipodi:linespacing="125%"
id="text4432"
y="65.21933"
x="691.42859"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
y="65.21933"
x="691.42859"
id="tspan4434"
sodipodi:role="line">Output:</tspan><tspan
id="tspan4436"
y="90.21933"
x="691.42859"
sodipodi:role="line">Results,</tspan><tspan
id="tspan4438"
y="115.21933"
x="691.42859"
sodipodi:role="line">Graphics</tspan></text>
<path
d="M 747.14283 85.523056 A 54.285713 51.42857 0 1 1 638.5714,85.523056 A 54.285713 51.42857 0 1 1 747.14283 85.523056 z"
sodipodi:ry="51.42857"
sodipodi:rx="54.285713"
sodipodi:cy="85.523056"
sodipodi:cx="692.85712"
id="path4440"
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
</g>
<g
id="g4452"
transform="translate(-25.357118,291.07143)">
<text
sodipodi:linespacing="125%"
id="text4454"
y="68.076462"
x="525.71436"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
y="68.076462"
x="525.71436"
id="tspan4456"
sodipodi:role="line">Dynare</tspan><tspan
id="tspan4458"
y="93.076462"
x="525.71436"
sodipodi:role="line">Matlab routines</tspan></text>
<rect
y="36.951626"
x="448.57144"
height="75.714287"
width="152.85715"
id="rect4460"
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 757.92859,365.8802 L 577.07147,365.8802"
id="path4466"
inkscape:connector-type="polyline"
inkscape:connection-end="#g4452"
inkscape:connection-start="#g4418" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 422.21432,366.33835 L 192.78572,367.69591"
id="path4468"
inkscape:connector-type="polyline"
inkscape:connection-start="#g4452"
inkscape:connection-end="#g4430" />
<g
id="g6668">
<text
sodipodi:linespacing="125%"
id="text4470"
y="117.30877"
x="143.92857"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
y="117.30877"
x="143.92857"
id="tspan4472"
sodipodi:role="line">MOD file</tspan><tspan
id="tspan4474"
y="142.30877"
x="143.92857"
sodipodi:role="line">with macro</tspan><tspan
id="tspan4482"
y="167.30877"
x="143.92857"
sodipodi:role="line">commands</tspan></text>
<path
transform="matrix(1.0725676,0,0,0.999374,99.5973,-252.25554)"
d="M 98.57143 390.52304 A 58.57143 56.42857 0 1 1 -18.57143,390.52304 A 58.57143 56.42857 0 1 1 98.57143 390.52304 z"
sodipodi:ry="56.42857"
sodipodi:rx="58.57143"
sodipodi:cy="390.52304"
sodipodi:cx="40"
id="path4504"
style="color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
</g>
<g
id="g5516"
transform="translate(316.78572,-245.35715)">
<text
sodipodi:linespacing="125%"
id="text4476"
y="368.38019"
x="307.14285"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
y="368.38019"
x="307.14285"
id="tspan4478"
sodipodi:role="line">MOD file</tspan><tspan
id="tspan4480"
y="393.38019"
x="307.14285"
sodipodi:role="line">without macro</tspan><tspan
id="tspan4484"
y="418.38019"
x="307.14285"
sodipodi:role="line">commands</tspan></text>
<path
transform="translate(-8.5714286,-4.2857143)"
d="M 389.99999 391.95163 A 72.85714 65 0 1 1 244.28571,391.95163 A 72.85714 65 0 1 1 389.99999 391.95163 z"
sodipodi:ry="65"
sodipodi:rx="72.85714"
sodipodi:cy="391.95163"
sodipodi:cx="317.14285"
id="path5475"
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
</g>
<g
id="g5510"
transform="translate(243.92858,-236.78572)">
<text
sodipodi:linespacing="125%"
id="text4486"
y="372.66592"
x="165.71428"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
id="tspan4490"
y="372.66592"
x="165.71428"
sodipodi:role="line">Macro</tspan><tspan
id="tspan4492"
y="397.66592"
x="165.71428"
sodipodi:role="line">Processor</tspan></text>
<rect
y="339.80878"
x="110"
height="72.85714"
width="115.71429"
id="rect5477"
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
<g
id="g5523"
transform="translate(372.5,-249.64286)">
<text
sodipodi:linespacing="125%"
id="text4494"
y="368.38019"
x="455.71426"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
xml:space="preserve"><tspan
y="368.38019"
x="455.71426"
id="tspan4496"
sodipodi:role="line">Parser,</tspan><tspan
id="tspan4498"
y="393.38019"
x="455.71426"
sodipodi:role="line">Analytical</tspan><tspan
id="tspan4500"
y="418.38019"
x="455.71426"
sodipodi:role="line">derivator...</tspan></text>
<rect
y="339.80878"
x="395.71429"
height="94.285713"
width="120"
id="rect5479"
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 206.35715,138.3618 L 352.92858,139.13938"
id="path5532"
inkscape:connector-type="polyline"
inkscape:connection-end="#g5510"
inkscape:connection-start="#g6668" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 470.64287,140.23901 L 551.5,141.32071"
id="path5534"
inkscape:connector-type="polyline"
inkscape:connection-start="#g5510"
inkscape:connection-end="#g5516" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 699.21428,140.48835 L 767.21429,138.81229"
id="path5536"
inkscape:connector-type="polyline"
inkscape:connection-start="#g5516"
inkscape:connection-end="#g5523" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 828.36474,185.45163 L 828.75359,309.8802"
id="path5538"
inkscape:connector-type="polyline"
inkscape:connection-end="#g4418"
inkscape:connection-start="#g5523" />
<rect
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1.5, 4.5;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect5596"
width="634.28571"
height="201.42857"
x="305.71429"
y="39.808769" />
<text
xml:space="preserve"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
x="404.28574"
y="232.66591"
id="text6567"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan6569"
x="404.28574"
y="232.66591">Dynare preprocessor</tspan></text>
</g>
</svg>
div.sphinxsidebar {
float: left;
width: 230px;
font-size: 90%;
word-wrap: break-word;
overflow-wrap : break-word;
overflow-y: scroll;
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE 10+ */
top: 0;
bottom: 0;
}
div.sphinxsidebar::-webkit-scrollbar { /* WebKit */
width: 0px;
}
div.sphinxsidebarwrapper p.logo {
padding: 0;
margin: -10px 0 0 0px;
text-align: left;
}
div.body {
min-width: 450px;
max-width: 90%;
}
.property{
display:inline-block;
text-decoration: underline;
text-decoration-style: double;
padding-right: 10px;
padding-top: 0px;
}
blockquote {
margin: 0 0 15px 30px;
padding: 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="87.89pt" height="34.182pt" viewBox="0 0 87.89 34.182" version="1.1">
<defs>
<g>
<symbol overflow="visible" id="glyph0-0">
<path style="stroke:none;" d="M 3.09375 -14.140625 L 3.6875 -13.203125 C 3.78125 -13.015625 3.921875 -12.921875 4.140625 -12.921875 C 4.21875 -12.921875 4.34375 -12.953125 4.453125 -13.03125 C 4.5625 -13.109375 4.703125 -13.203125 4.875 -13.28125 C 5.03125 -13.375 5.234375 -13.453125 5.46875 -13.53125 C 5.703125 -13.609375 5.984375 -13.640625 6.3125 -13.640625 C 6.796875 -13.640625 7.171875 -13.515625 7.484375 -13.265625 C 7.78125 -13.015625 7.9375 -12.6875 7.9375 -12.265625 C 7.9375 -11.9375 7.875 -11.640625 7.734375 -11.40625 C 7.59375 -11.171875 7.4375 -10.953125 7.234375 -10.765625 C 7.03125 -10.578125 6.828125 -10.390625 6.59375 -10.234375 C 6.375 -10.078125 6.171875 -9.90625 5.96875 -9.71875 C 5.796875 -9.546875 5.65625 -9.34375 5.53125 -9.140625 C 5.421875 -8.921875 5.390625 -8.6875 5.421875 -8.40625 L 5.578125 -6.953125 L 7.09375 -6.953125 L 7.296875 -8.25 C 7.328125 -8.4375 7.421875 -8.609375 7.5625 -8.765625 C 7.703125 -8.921875 7.875 -9.0625 8.078125 -9.234375 C 8.28125 -9.390625 8.484375 -9.546875 8.703125 -9.734375 C 8.9375 -9.90625 9.140625 -10.125 9.3125 -10.359375 C 9.515625 -10.609375 9.671875 -10.890625 9.78125 -11.21875 C 9.90625 -11.5625 9.96875 -11.9375 9.96875 -12.40625 C 9.96875 -12.859375 9.890625 -13.28125 9.71875 -13.65625 C 9.546875 -14.03125 9.3125 -14.359375 9.015625 -14.625 C 8.703125 -14.875 8.34375 -15.09375 7.9375 -15.234375 C 7.5 -15.375 7.03125 -15.453125 6.5 -15.453125 C 6.125 -15.453125 5.78125 -15.40625 5.453125 -15.34375 C 5.125 -15.28125 4.8125 -15.171875 4.53125 -15.0625 C 4.25 -14.9375 3.984375 -14.8125 3.765625 -14.640625 C 3.515625 -14.484375 3.3125 -14.328125 3.09375 -14.140625 Z M 4.90625 -3.625 C 4.90625 -3.234375 5.03125 -2.90625 5.296875 -2.65625 C 5.546875 -2.375 5.875 -2.25 6.265625 -2.25 C 6.453125 -2.25 6.625 -2.296875 6.796875 -2.359375 C 6.953125 -2.421875 7.09375 -2.53125 7.21875 -2.65625 C 7.328125 -2.78125 7.4375 -2.921875 7.515625 -3.078125 C 7.578125 -3.25 7.609375 -3.4375 7.609375 -3.625 C 7.609375 -3.796875 7.578125 -3.984375 7.515625 -4.15625 C 7.4375 -4.328125 7.328125 -4.46875 7.21875 -4.59375 C 7.09375 -4.71875 6.953125 -4.8125 6.796875 -4.875 C 6.625 -4.953125 6.453125 -5 6.265625 -5 C 5.875 -5 5.546875 -4.859375 5.296875 -4.59375 C 5.03125 -4.34375 4.90625 -4 4.90625 -3.625 Z M 0.5625 -17.75 L 0.5625 0 L 12.625 0 L 12.625 -17.75 Z M 1.171875 -0.671875 L 1.171875 -17.078125 L 11.921875 -17.078125 L 11.921875 -0.671875 Z M 1.171875 -0.671875 "/>
</symbol>
<symbol overflow="visible" id="glyph0-1">
<path style="stroke:none;" d="M 17.546875 -8.875 C 17.546875 -10.203125 17.328125 -11.40625 16.90625 -12.5 C 16.484375 -13.59375 15.890625 -14.515625 15.125 -15.3125 C 14.359375 -16.078125 13.4375 -16.6875 12.359375 -17.125 C 11.28125 -17.546875 10.09375 -17.75 8.796875 -17.75 L 2.15625 -17.75 L 2.15625 0 L 8.796875 0 C 10.09375 0 11.28125 -0.203125 12.359375 -0.640625 C 13.4375 -1.0625 14.359375 -1.65625 15.125 -2.4375 C 15.890625 -3.21875 16.484375 -4.15625 16.90625 -5.234375 C 17.328125 -6.328125 17.546875 -7.546875 17.546875 -8.875 Z M 15.078125 -8.875 C 15.078125 -7.78125 14.9375 -6.796875 14.640625 -5.953125 C 14.34375 -5.09375 13.921875 -4.359375 13.375 -3.765625 C 12.828125 -3.1875 12.171875 -2.71875 11.390625 -2.421875 C 10.609375 -2.109375 9.75 -1.953125 8.796875 -1.953125 L 4.578125 -1.953125 L 4.578125 -15.8125 L 8.796875 -15.8125 C 9.75 -15.8125 10.609375 -15.65625 11.390625 -15.34375 C 12.171875 -15.03125 12.828125 -14.578125 13.375 -13.984375 C 13.921875 -13.375 14.34375 -12.65625 14.640625 -11.796875 C 14.9375 -10.9375 15.078125 -9.96875 15.078125 -8.875 Z M 15.078125 -8.875 "/>
</symbol>
<symbol overflow="visible" id="glyph0-2">
<path style="stroke:none;" d="M 5.484375 3.703125 L 12.484375 -12.546875 L 10.734375 -12.546875 C 10.59375 -12.546875 10.453125 -12.515625 10.328125 -12.421875 C 10.21875 -12.34375 10.140625 -12.234375 10.09375 -12.09375 L 6.828125 -4.203125 C 6.75 -4.015625 6.6875 -3.828125 6.625 -3.640625 C 6.5625 -3.453125 6.515625 -3.265625 6.453125 -3.078125 C 6.421875 -3.265625 6.375 -3.453125 6.3125 -3.640625 C 6.25 -3.828125 6.1875 -4 6.125 -4.1875 L 2.765625 -12.09375 C 2.71875 -12.203125 2.640625 -12.3125 2.53125 -12.421875 C 2.421875 -12.5 2.265625 -12.546875 2.078125 -12.546875 L 0.171875 -12.546875 L 5.359375 -0.734375 L 3.0625 4.25 L 4.703125 4.25 C 4.9375 4.25 5.109375 4.203125 5.203125 4.09375 C 5.328125 4 5.421875 3.859375 5.484375 3.703125 Z M 5.484375 3.703125 "/>
</symbol>
<symbol overflow="visible" id="glyph0-3">
<path style="stroke:none;" d="M 1.8125 0 L 4.015625 0 L 4.015625 -9.25 C 4.5 -9.78125 5.015625 -10.203125 5.578125 -10.515625 C 6.140625 -10.828125 6.75 -10.984375 7.40625 -10.984375 C 8.296875 -10.984375 8.96875 -10.734375 9.390625 -10.203125 C 9.84375 -9.671875 10.046875 -8.953125 10.046875 -7.984375 L 10.046875 0 L 12.25 0 L 12.25 -7.984375 C 12.25 -8.703125 12.171875 -9.359375 11.984375 -9.9375 C 11.796875 -10.515625 11.53125 -11.03125 11.171875 -11.453125 C 10.828125 -11.859375 10.390625 -12.1875 9.859375 -12.421875 C 9.34375 -12.640625 8.734375 -12.75 8.046875 -12.75 C 7.171875 -12.75 6.390625 -12.5625 5.71875 -12.1875 C 5.046875 -11.828125 4.4375 -11.34375 3.890625 -10.734375 L 3.71875 -12.09375 C 3.625 -12.40625 3.4375 -12.546875 3.125 -12.546875 L 1.8125 -12.546875 Z M 1.8125 0 "/>
</symbol>
<symbol overflow="visible" id="glyph0-4">
<path style="stroke:none;" d="M 11.03125 0 L 11.03125 -8.03125 C 11.03125 -8.734375 10.921875 -9.375 10.75 -9.96875 C 10.5625 -10.546875 10.265625 -11.046875 9.90625 -11.46875 C 9.53125 -11.875 9.0625 -12.1875 8.53125 -12.421875 C 7.984375 -12.65625 7.359375 -12.78125 6.65625 -12.78125 C 5.671875 -12.78125 4.796875 -12.609375 3.984375 -12.28125 C 3.1875 -11.9375 2.4375 -11.453125 1.75 -10.78125 L 2.140625 -10.078125 C 2.203125 -9.96875 2.296875 -9.859375 2.40625 -9.78125 C 2.53125 -9.703125 2.65625 -9.671875 2.796875 -9.671875 C 2.984375 -9.671875 3.1875 -9.734375 3.375 -9.859375 C 3.5625 -10.015625 3.796875 -10.15625 4.0625 -10.328125 C 4.34375 -10.5 4.65625 -10.65625 5.03125 -10.78125 C 5.390625 -10.921875 5.84375 -10.984375 6.375 -10.984375 C 7.203125 -10.984375 7.8125 -10.75 8.234375 -10.234375 C 8.65625 -9.734375 8.859375 -9.015625 8.859375 -8.03125 L 8.859375 -7.046875 C 7.4375 -7.015625 6.234375 -6.890625 5.25 -6.671875 C 4.28125 -6.4375 3.46875 -6.140625 2.875 -5.78125 C 2.25 -5.421875 1.828125 -5.03125 1.546875 -4.5625 C 1.28125 -4.109375 1.140625 -3.625 1.140625 -3.140625 C 1.140625 -2.5625 1.234375 -2.0625 1.40625 -1.65625 C 1.609375 -1.234375 1.859375 -0.890625 2.171875 -0.625 C 2.484375 -0.34375 2.84375 -0.15625 3.265625 0 C 3.703125 0.125 4.15625 0.203125 4.640625 0.203125 C 5.125 0.203125 5.5625 0.15625 5.953125 0.078125 C 6.34375 -0.015625 6.71875 -0.125 7.0625 -0.296875 C 7.40625 -0.453125 7.75 -0.640625 8.046875 -0.890625 C 8.359375 -1.109375 8.6875 -1.390625 9.015625 -1.6875 L 9.265625 -0.515625 C 9.3125 -0.3125 9.390625 -0.15625 9.53125 -0.09375 C 9.671875 -0.03125 9.84375 0 10.046875 0 Z M 5.296875 -1.34375 C 5.015625 -1.34375 4.75 -1.390625 4.5 -1.46875 C 4.25 -1.53125 4.046875 -1.640625 3.859375 -1.78125 C 3.671875 -1.953125 3.53125 -2.140625 3.421875 -2.375 C 3.3125 -2.609375 3.265625 -2.90625 3.265625 -3.234375 C 3.265625 -3.578125 3.359375 -3.890625 3.5625 -4.171875 C 3.765625 -4.453125 4.09375 -4.703125 4.53125 -4.90625 C 4.984375 -5.125 5.5625 -5.28125 6.265625 -5.40625 C 6.96875 -5.53125 7.84375 -5.609375 8.859375 -5.65625 L 8.859375 -3.03125 C 8.609375 -2.78125 8.34375 -2.546875 8.109375 -2.328125 C 7.828125 -2.125 7.5625 -1.953125 7.28125 -1.8125 C 6.984375 -1.65625 6.6875 -1.546875 6.375 -1.46875 C 6.046875 -1.390625 5.6875 -1.34375 5.296875 -1.34375 Z M 5.296875 -1.34375 "/>
</symbol>
<symbol overflow="visible" id="glyph0-5">
<path style="stroke:none;" d="M 1.8125 0 L 4.015625 0 L 4.015625 -7.984375 C 4.359375 -8.84375 4.796875 -9.484375 5.296875 -9.9375 C 5.828125 -10.390625 6.46875 -10.609375 7.234375 -10.609375 C 7.671875 -10.609375 8 -10.5625 8.234375 -10.484375 C 8.46875 -10.40625 8.65625 -10.375 8.765625 -10.375 C 8.96875 -10.375 9.09375 -10.46875 9.15625 -10.6875 L 9.4375 -12.328125 C 9.203125 -12.46875 8.953125 -12.578125 8.65625 -12.65625 C 8.375 -12.734375 8.0625 -12.78125 7.71875 -12.78125 C 6.859375 -12.78125 6.125 -12.53125 5.5 -12.046875 C 4.859375 -11.546875 4.34375 -10.859375 3.90625 -9.984375 L 3.75 -11.9375 C 3.71875 -12.171875 3.65625 -12.328125 3.5625 -12.421875 C 3.484375 -12.5 3.3125 -12.546875 3.078125 -12.546875 L 1.8125 -12.546875 Z M 1.8125 0 "/>
</symbol>
<symbol overflow="visible" id="glyph0-6">
<path style="stroke:none;" d="M 6.78125 -12.75 C 5.875 -12.75 5.0625 -12.59375 4.328125 -12.265625 C 3.59375 -11.953125 2.984375 -11.515625 2.484375 -10.953125 C 1.96875 -10.40625 1.59375 -9.734375 1.3125 -8.984375 C 1.046875 -8.234375 0.921875 -7.40625 0.921875 -6.53125 C 0.921875 -5.453125 1.0625 -4.484375 1.359375 -3.65625 C 1.65625 -2.828125 2.078125 -2.125 2.609375 -1.5625 C 3.140625 -0.984375 3.765625 -0.5625 4.515625 -0.265625 C 5.234375 0.03125 6.03125 0.171875 6.90625 0.171875 C 7.359375 0.171875 7.8125 0.140625 8.28125 0.046875 C 8.734375 -0.03125 9.1875 -0.140625 9.609375 -0.296875 C 10.0625 -0.453125 10.453125 -0.65625 10.84375 -0.890625 C 11.21875 -1.140625 11.546875 -1.421875 11.828125 -1.765625 L 11.203125 -2.5625 C 11.109375 -2.703125 10.96875 -2.78125 10.78125 -2.78125 C 10.640625 -2.78125 10.46875 -2.71875 10.28125 -2.578125 C 10.09375 -2.453125 9.84375 -2.3125 9.546875 -2.171875 C 9.265625 -2.015625 8.921875 -1.890625 8.53125 -1.765625 C 8.109375 -1.625 7.640625 -1.5625 7.09375 -1.5625 C 6.5 -1.5625 5.953125 -1.65625 5.484375 -1.859375 C 5 -2.046875 4.578125 -2.34375 4.234375 -2.71875 C 3.890625 -3.125 3.625 -3.625 3.421875 -4.203125 C 3.21875 -4.78125 3.109375 -5.484375 3.09375 -6.265625 L 11.453125 -6.265625 C 11.65625 -6.265625 11.796875 -6.328125 11.875 -6.4375 C 11.9375 -6.546875 11.984375 -6.796875 11.984375 -7.140625 C 11.984375 -8.03125 11.84375 -8.828125 11.59375 -9.515625 C 11.328125 -10.21875 10.96875 -10.796875 10.5 -11.28125 C 10.046875 -11.765625 9.484375 -12.125 8.859375 -12.359375 C 8.234375 -12.625 7.53125 -12.75 6.78125 -12.75 Z M 6.828125 -11.125 C 7.328125 -11.125 7.78125 -11.046875 8.171875 -10.875 C 8.5625 -10.703125 8.890625 -10.453125 9.171875 -10.15625 C 9.4375 -9.84375 9.65625 -9.484375 9.78125 -9.046875 C 9.921875 -8.625 10 -8.15625 10 -7.640625 L 3.171875 -7.640625 C 3.328125 -8.734375 3.703125 -9.59375 4.3125 -10.203125 C 4.921875 -10.8125 5.765625 -11.125 6.828125 -11.125 Z M 6.828125 -11.125 "/>
</symbol>
</g>
<clipPath id="clip1">
<path d="M 0 6 L 22 6 L 22 34.183594 L 0 34.183594 Z M 0 6 "/>
</clipPath>
</defs>
<g id="surface1">
<g style="fill:rgb(67.059326%,70.196533%,72.941589%);fill-opacity:1;">
<use xlink:href="#glyph0-1" x="3.321" y="24.097"/>
<use xlink:href="#glyph0-2" x="21.985686" y="24.097"/>
<use xlink:href="#glyph0-3" x="34.676682" y="24.097"/>
<use xlink:href="#glyph0-4" x="48.458309" y="24.097"/>
<use xlink:href="#glyph0-5" x="61.025369" y="24.097"/>
<use xlink:href="#glyph0-6" x="71.01457" y="24.097"/>
</g>
<path style="fill:none;stroke-width:0.79701;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,49.804688%,39.99939%);stroke-opacity:1;stroke-miterlimit:10;" d="M -13.323406 -17.010156 C -13.323406 -17.010156 0.785969 14.802344 5.387531 15.591406 C 9.989094 16.376563 16.891437 -8.35 19.844562 -11.338281 C 22.793781 -14.326562 24.797687 -6.029687 26.645344 -5.951562 C 28.493 -5.873437 31.434406 -10.455469 33.164875 -10.771875 C 34.895344 -11.088281 37.504719 -8.299219 39.118 -8.221094 C 40.731281 -8.142969 43.215656 -10.127344 44.789875 -10.205469 C 46.360187 -10.283594 48.883625 -8.865625 50.457844 -8.7875 C 52.032062 -8.709375 54.551594 -9.6 56.125812 -9.639062 C 57.700031 -9.678125 60.301594 -9.111719 61.797687 -9.072656 C 63.289875 -9.033594 66.89925 -9.353906 66.89925 -9.353906 " transform="matrix(1,0,0,-1,15.882,16.775)"/>
<g style="fill:rgb(12.940979%,52.157593%,77.253723%);fill-opacity:1;">
<use xlink:href="#glyph0-1" x="3.888" y="23.53"/>
<use xlink:href="#glyph0-2" x="22.552686" y="23.53"/>
<use xlink:href="#glyph0-3" x="35.243681" y="23.53"/>
<use xlink:href="#glyph0-4" x="49.025309" y="23.53"/>
<use xlink:href="#glyph0-5" x="61.592369" y="23.53"/>
<use xlink:href="#glyph0-6" x="71.58157" y="23.53"/>
</g>
<g clip-path="url(#clip1)" clip-rule="nonzero">
<path style="fill:none;stroke-width:0.79701;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,49.804688%,39.99939%);stroke-opacity:1;stroke-miterlimit:10;" d="M -9.128094 -7.935937 C -9.128094 -7.935937 -5.753094 -1.135156 -5.753094 -1.135156 " transform="matrix(1,0,0,-1,15.882,16.775)"/>
</g>
</g>
</svg>
doc/manual/source/_static/report.png

87 KiB

{% if theme_logo %}
<p class="logo">
<a href="{{ pathto(master_doc) }}">
<img class="logo" src="{{ pathto('_static/' ~ theme_logo, 1) }}" alt="Logo" width=143/>
{% if theme_logo_name|lower == 'true' %}
<h1 class="logo logo-name">{{ project }}</h1>
{% endif %}
</a>
</p>
{% else %}
<h1 class="logo"><a href="{{ pathto(master_doc) }}">{{ project }}</a></h1>
{% endif %}
{% if theme_description %}
<p class="blurb">{{ theme_description }}</p>
{% endif %}
{% if theme_github_user and theme_github_repo %}
{% if theme_github_button|lower == 'true' %}
<p>
<iframe src="https://ghbtns.com/github-btn.html?user={{ theme_github_user }}&repo={{ theme_github_repo }}&type={{ theme_github_type }}&count={{ theme_github_count }}&size=large&v=2"
allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>
</p>
{% endif %}
{% endif %}
{% if theme_travis_button|lower != 'false' %}
{% if theme_travis_button|lower == 'true' %}
{% set path = theme_github_user + '/' + theme_github_repo %}
{% else %}
{% set path = theme_travis_button %}
{% endif %}
<p>
<a class="badge" href="https://travis-ci.org/{{ path }}">
<img
alt="https://secure.travis-ci.org/{{ path }}.svg?branch={{ theme_badge_branch }}"
src="https://secure.travis-ci.org/{{ path }}.svg?branch={{ theme_badge_branch }}"
/>
</a>
</p>
{% endif %}
{% if theme_codecov_button|lower != 'false' %}
{% if theme_codecov_button|lower == 'true' %}
{% set path = theme_github_user + '/' + theme_github_repo %}
{% else %}
{% set path = theme_codecov_button %}
{% endif %}
<p>
<a class="badge" href="https://codecov.io/github/{{ path }}">
<img
alt="https://codecov.io/github/{{ path }}/coverage.svg?branch={{ theme_badge_branch }}"
src="https://codecov.io/github/{{ path }}/coverage.svg?branch={{ theme_badge_branch }}"
/>
</a>
</p>
{% endif %}
<br style="line-height:16px">
<h3>{{ _('Navigation') }}</h3>
{{ toctree(includehidden=theme_sidebar_includehidden, collapse=theme_sidebar_collapse) }}
{% if theme_extra_nav_links %}
<hr />
<ul>
{% for text, uri in theme_extra_nav_links.items() %}
<li class="toctree-l1"><a href="{{ uri }}">{{ text }}</a></li>
{% endfor %}
</ul>
{% endif %}
<hr />
<ul>
<li class="toctree-l1"><a href="{{pathto('genindex.html', 1)}}">Index</a></li>
</ul>
.. default-domain:: dynare
############
Bibliography
############
* Abramowitz, Milton and Irene A. Stegun (1964): “Handbook of Mathematical Functions”, Courier Dover Publications.
* Adjemian, Stéphane, Matthieu Darracq Parriès and Stéphane Moyen (2008): “Towards a monetary policy evaluation framework”, *European Central Bank Working Paper*, 942.
* Adjemian, Stéphane and Michel Juillard (2025): “Stochastic Extended Path”, *Dynare Working Papers*, 84, CEPREMAP.
* Aguiar, Mark and Gopinath, Gita (2004): “Emerging Market Business Cycles: The Cycle is the Trend,” *NBER* Working Paper, 10734.
* Amisano, Gianni and Tristani, Oreste (2010): “Euro area inflation persistence in an estimated nonlinear DSGE model”, *Journal of Economic Dynamics and Control*, 34(10), 1837–1858.
* Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2018): “The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,” *Review of Economic Studies*, 85(1), 1-49.
* Andrle, Michal and Miroslav Plašil (2018): “Econometrics with system priors,” *Economics Letters*, 172, 134-137.
* Andrews, Donald W.K (1991): “Heteroskedasticity and autocorrelation consistent covariance matrix estimation”, *Econometrica*, 59(3), 817–858.
* Backus, David K., Patrick J. Kehoe, and Finn E. Kydland (1992): “International Real Business Cycles,” *Journal of Political Economy*, 100(4), 745–775.
* Baxter, Marianne and Robert G. King (1999): “Measuring Business Cycles: Approximate Band-pass Filters for Economic Time Series,” *Review of Economics and Statistics*, 81(4), 575–593.
* Bini, Dario A., Guy Latouche, and Beatrice Meini (2002): “Solving matrix polynomial equations arising in queueing problems,” *Linear Algebra and its Applications*, 340, 225–244.
* Boehl, Gregor (2022): “DIME MCMC: A Swiss Army Knife for Bayesian Inference”, *SSRN No. 4250395*
* Born, Benjamin and Johannes Pfeifer (2014): “Policy risk and the business cycle”, *Journal of Monetary Economics*, 68, 68-85.
* Boucekkine, Raouf (1995): “An alternative methodology for solving nonlinear forward-looking models,” *Journal of Economic Dynamics and Control*, 19, 711–734.
* Brayton, Flint and Peter Tinsley (1996): “A Guide to FRB/US: A Macroeconomic Model of the United States,” *Finance and Economics Discussion Series*, 1996-42.
* Brayton, Flint, Morris Davis and Peter Tulip (2000): “Polynomial Adjustment Costs in FRB/US,” *Unpublished manuscript*.
* Brooks, Stephen P., and Andrew Gelman (1998): “General methods for monitoring convergence of iterative simulations,” *Journal of Computational and Graphical Statistics*, 7, pp. 434–455.
* Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): “The simplex simulated annealing approach to continuous non-linear optimization,” *Computers & Chemical Engineering*, 20(9), 1065-1080.
* Chib, Siddhartha and Srikanth Ramamurthy (2010): “Tailored randomized block MCMC methods with application to DSGE models,” *Journal of Econometrics*, 155, 19–38.
* Christiano, Lawrence J., Martin Eichenbaum and Charles L. Evans (2005): “Nominal Rigidities and the Dynamic Effects of a Shock to Monetary Policy,” *Journal of Political Economy*, 113(1), 1–45.
* Christiano, Lawrence J., Mathias Trabandt, and Karl Walentin (2010): “DSGE Models for Monetary Policy Analysis,” In: *Handbook of Monetary Economics 3*, 285–367.
* Christiano, Lawrence J., Mathias Trabandt and Karl Walentin (2011): “Introducing financial frictions and unemployment into a small open economy model,” *Journal of Economic Dynamics and Control*, 35(12), 1999–2041.
* Christoffel, Kai, Günter Coenen and Anders Warne (2010): “Forecasting with DSGE models,” *ECB Working Paper Series*, 1185.
* Collard, Fabrice (2001): “Stochastic simulations with Dynare: A practical guide”.
* Collard, Fabrice and Michel Juillard (2001a): “Accuracy of stochastic perturbation methods: The case of asset pricing models,” *Journal of Economic Dynamics and Control*, 25, 979–999.
* Collard, Fabrice and Michel Juillard (2001b): “A Higher-Order Taylor Expansion Approach to Simulation of Stochastic Forward-Looking Models with an Application to a Non-Linear Phillips Curve,” *Computational Economics*, 17, 125–139.
* Corana, Angelo, M. Marchesi, Claudio Martini, and Sandro Ridella (1987): “Minimizing multimodal functions of continuous variables with the “simulated annealing” algorithm”, *ACM Transactions on Mathematical Software*, 13(3), 262–280.
* Cuba-Borda, Pablo, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong (2019): “Likelihood evaluation of models with occasionally binding constraints,” Journal of Applied Econometrics, 34(7), 1073-1085
* Del Negro, Marco and Frank Schorfheide (2004): “Priors from General Equilibrium Models for VARs”, *International Economic Review*, 45(2), 643–673.
* Dennis, Richard (2007): “Optimal Policy In Rational Expectations Models: New Solution Algorithms”, *Macroeconomic Dynamics*, 11(1), 31–55.
* Duffie, Darrel and Kenneth J. Singleton (1993): “Simulated Moments Estimation of Markov Models of Asset Prices”, *Econometrica*, 61(4), 929-952.
* Durbin, J. and S. J. Koopman (2012), *Time Series Analysis by State Space Methods*, Second Revised Edition, Oxford University Press.
* Fair, Ray and John Taylor (1983): “Solution and Maximum Likelihood Estimation of Dynamic Nonlinear Rational Expectation Models,” *Econometrica*, 51, 1169–1185.
* Fernández-Villaverde, Jesús (2010): “The econometrics of DSGE models,” *SERIEs*, 1, 3–49.
* Fernández-Villaverde, Jesús and Juan Rubio-Ramírez (2004): “Comparing Dynamic Equilibrium Economies to Data: A Bayesian Approach,” *Journal of Econometrics*, 123, 153–187.
* Fernández-Villaverde, Jesús and Juan Rubio-Ramírez (2005): “Estimating Dynamic Equilibrium Economies: Linear versus Nonlinear Likelihood,” *Journal of Applied Econometrics*, 20, 891–910.
* Ferris, Michael C. and Todd S. Munson (1999): “Interfaces to PATH 3.0: Design, Implementation and Usage”, *Computational Optimization and Applications*, 12(1), 207–227.
* Galí, Jordi (2015): “Monetary Policy, Inflation, and the Business Cycle,” 2nd Edition, Princeton University Press, Princeton.
* Geweke, John (1992): “Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,” in J.O. Berger, J.M. Bernardo, A.P. Dawid, and A.F.M. Smith (eds.) Proceedings of the Fourth Valencia International Meeting on Bayesian Statistics, pp. 169–194, Oxford University Press.
* Geweke, John (1999): “Using simulation methods for Bayesian econometric models: Inference, development and communication,” *Econometric Reviews*, 18(1), 1–73.
* Giovannini, Massimo, Philipp Pfeiffer, and Marco Ratto (2021), “Efficient and robust inference of models with occasionally binding constraints,” Working Papers 2021-03, Joint Research Centre, European Commission
* Giordani, Paolo, Michael Pitt, and Robert Kohn (2011): “Bayesian Inference for Time Series State Space Models” in: *The Oxford Handbook of Bayesian Econometrics*, ed. by John Geweke, Gary Koop, and Herman van Dijk, Oxford University Press, 61–124.
* Guerrieri, Luca and Matteo Iacoviello (2015): “OccBin: A toolkit for solving dynamic models with occasionally binding constraints easily,” *Journal of Monetary Economics*, 70, 22–38.
* Goffe, William L., Gary D. Ferrier, and John Rogers (1994): “Global Optimization of Statistical Functions with Simulated Annealing,” *Journal of Econometrics*, 60(1/2), 65–100.
* Hansen, Lars P. (1982): “Large sample properties of generalized method of moments estimators,” Econometrica, 50(4), 1029–1054.
* Hansen, Nikolaus and Stefan Kern (2004): “Evaluating the CMA Evolution Strategy on Multimodal Test Functions”. In: *Eighth International Conference on Parallel Problem Solving from Nature PPSN VIII*, Proceedings, Berlin: Springer, 282–291.
* Harvey, Andrew C. and Garry D.A. Phillips (1979): “Maximum likelihood estimation of regression models with autoregressive-moving average disturbances,” *Biometrika*, 66(1), 49–58.
* Herbst, Edward and Schorfheide, Frank (2014): “Sequential Monte Carlo Sampling for DSGE Models,” *Journal of Applied Econometrics*, 29, 1073-1098.
* Herbst, Edward (2015): “Using the “Chandrasekhar Recursions” for Likelihood Evaluation of DSGE Models,” *Computational Economics*, 45(4), 693–705.
* Ireland, Peter (2004): “A Method for Taking Models to the Data,” *Journal of Economic Dynamics and Control*, 28, 1205–26.
* Iskrev, Nikolay (2010): “Local identification in DSGE models,” *Journal of Monetary Economics*, 57(2), 189–202.
* Judd, Kenneth (1996): “Approximation, Perturbation, and Projection Methods in Economic Analysis”, in *Handbook of Computational Economics*, ed. by Hans Amman, David Kendrick, and John Rust, North Holland Press, 511–585.
* Juillard, Michel (1996): “Dynare: A program for the resolution and simulation of dynamic models with forward variables through the use of a relaxation algorithm,” CEPREMAP, *Couverture Orange*, 9602.
* Kanzow, Christian and Stefania Petra (2004): “On a semismooth least squares formulation of complementarity problems with gap reduction,” *Optimization Methods and Software*, 19, 507–525.
* Kim, Jinill and Sunghyun Kim (2003): “Spurious welfare reversals in international business cycle models,” *Journal of International Economics*, 60, 471–500.
* Kim, Jinill, Sunghyun Kim, Ernst Schaumburg, and Christopher A. Sims (2008): “Calculating and using second-order accurate solutions of discrete time dynamic equilibrium models,” *Journal of Economic Dynamics and Control*, 32(11), 3397–3414.
* Komunjer, Ivana and Ng, Serena (2011): ”Dynamic identification of dynamic stochastic general equilibrium models”, *Econometrica*, 79, 1995–2032.
* Koop, Gary (2003), *Bayesian Econometrics*, John Wiley & Sons.
* Koopman, S. J. and J. Durbin (2000): “Fast Filtering and Smoothing for Multivariate State Space Models,” *Journal of Time Series Analysis*, 21(3), 281–296.
* Koopman, S. J. and J. Durbin (2003): “Filtering and Smoothing of State Vector for Diffuse State Space Models,” *Journal of Time Series Analysis*, 24(1), 85–98.
* Kuntsevich, Alexei V. and Franz Kappel (1997): “SolvOpt - The solver for local nonlinear optimization problems (version 1.1, Matlab, C, FORTRAN)”, University of Graz, Graz, Austria.
* Laffargue, Jean-Pierre (1990): “Résolution d’un modèle macroéconomique avec anticipations rationnelles”, *Annales d’Économie et Statistique*, 17, 97–119.
* Liu, Jane and Mike West (2001): “Combined parameter and state estimation in simulation-based filtering”, in *Sequential Monte Carlo Methods in Practice*, Eds. Doucet, Freitas and Gordon, Springer Verlag, Chapter 10, 197-223.
* Murray, Lawrence M., Emlyn M. Jones and John Parslow (2013): “On Disturbance State-Space Models and the Particle Marginal Metropolis-Hastings Sampler”, *SIAM/ASA Journal on Uncertainty Quantification*, 1, 494–521.
* Mutschler, Willi (2015): “Identification of DSGE models - The effect of higher-order approximation and pruning“, *Journal of Economic Dynamics & Control*, 56, 34-54.
* Mutschler, Willi (2018): “Higher-order statistics for DSGE models”, *Econometrics and Statistics*, 6(C), 44-56.
* Pearlman, Joseph, David Currie, and Paul Levine (1986): “Rational expectations models with partial information,” *Economic Modelling*, 3(2), 90–105.
* Planas, Christophe, Marco Ratto and Alessandro Rossi (2015): “Slice sampling in Bayesian estimation of DSGE models”.
* Pfeifer, Johannes (2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”.
* Pfeifer, Johannes (2014): “An Introduction to Graphs in Dynare”.
* Qu, Zhongjun and Tkachenko, Denis (2012): “Identification and frequency domain quasi-maximum likelihood estimation of linearized dynamic stochastic general equilibrium models“, *Quantitative Economics*, 3, 95–132.
* Rabanal, Pau and Juan Rubio-Ramírez (2003): “Comparing New Keynesian Models of the Business Cycle: A Bayesian Approach,” Federal Reserve of Atlanta, *Working Paper Series*, 2003-30.
* Raftery, Adrian E. and Steven Lewis (1992): “How many iterations in the Gibbs sampler?,” in *Bayesian Statistics, Vol. 4*, ed. J.O. Berger, J.M. Bernardo, A.P. * Dawid, and A.F.M. Smith, Clarendon Press: Oxford, pp. 763-773.
* Ratto, Marco (2008): “Analysing DSGE models with global sensitivity analysis”, *Computational Economics*, 31, 115–139.
* Ratto, Marco and Iskrev, Nikolay (2011): “Identification Analysis of DSGE Models with DYNARE.“, *MONFISPOL* 225149.
* Ruge-Murcia, Francisco J. (2012): “Estimating nonlinear DSGE models by the simulated method of moments: With an application to business cycles“, *Journal of Economic Dynamics and Control*, 36, 914-938.
* Schmitt-Grohé, Stephanie and Martin Uríbe (2004): “Solving Dynamic General Equilibrium Models Using a Second-Order Approximation to the Policy Function,” *Journal of Economic Dynamics and Control*, 28(4), 755–775.
* Schnabel, Robert B. and Elizabeth Eskow (1990): “A new modified Cholesky algorithm,” *SIAM Journal of Scientific and Statistical Computing*, 11, 1136–1158.
* Schorfheide, Frank (2000): “Loss Function-based evaluation of DSGE models,” *Journal of Applied Econometrics*, 15(6), 645–670.
* Sims, Christopher A., Daniel F. Waggoner and Tao Zha (2008): “Methods for inference in large multiple-equation Markov-switching models,” *Journal of Econometrics*, 146, 255–274.
* Skoeld, Martin and Gareth O. Roberts (2003): “Density Estimation for the Metropolis-Hastings Algorithm,” *Scandinavian Journal of Statistics*, 30, 699–718.
* Smets, Frank and Rafael Wouters (2003): “An Estimated Dynamic Stochastic General Equilibrium Model of the Euro Area,” *Journal of the European Economic Association*, 1(5), 1123–1175.
* Stock, James H. and Mark W. Watson (1999). “Forecasting Inflation,”, *Journal of Monetary Economics*, 44(2), 293–335.
* Uhlig, Harald (2001): “A Toolkit for Analysing Nonlinear Dynamic Stochastic Models Easily,” in *Computational Methods for the Study of Dynamic Economies*, Eds. Ramon Marimon and Andrew Scott, Oxford University Press, 30–61.
* U.S. Census Bureau (2020): “X-13 ARIMA-SEATS Reference Manual, Version 1.1”, Center for Statistical Research and Methodology, U.S. Census Bureau, https://www.census.gov/data/software/x13as.html
* Villemot, Sébastien (2011): “Solving rational expectations models at first order: what Dynare does,” *Dynare Working Papers*, 2, CEPREMAP.
# -*- coding: utf-8 -*-
# Copyright © 2018-2025 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <https://www.gnu.org/licenses/>.
import os
import sys
sys.path.insert(0, os.path.abspath('../utils'))
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.mathjax']
source_suffix = '.rst'
templates_path = ['_templates']
html_static_path = ['_static']
master_doc = 'index'
project = u'Dynare'
copyright = u'1996–2025 Dynare Team'
author = u'Dynare Team'
add_function_parentheses = False
language = 'en'
exclude_patterns = []
highlight_language = 'dynare'
todo_include_todos = False
html_theme = 'alabaster'
html_sidebars = {
"**": [
"about.html",
"searchbox.html",
"navigation.html",
]
}
html_theme_options = {
'logo': 'dlogo.svg',
'logo_name': False,
'fixed_sidebar': True,
'page_width': '100%',
}
htmlhelp_basename = 'Dynaremanual'
latex_elements = {
'sphinxsetup': 'VerbatimBorderColor={rgb}{1,1,1},VerbatimColor={RGB}{240,240,240}, \
warningBorderColor={RGB}{255,50,50},OuterLinkColor={RGB}{34,139,34}, \
InnerLinkColor={RGB}{51,51,255},TitleColor={RGB}{51,51,255}',
'papersize': 'a4paper',
# Add support for the perpendicular symbol input as UTF-8
'preamble': r'''
\DeclareUnicodeCharacter{27C2}{\ensuremath{\perp}}
'''
}
latex_documents = [
(master_doc, 'dynare-manual.tex', u'Dynare Reference Manual',
u'Dynare Team', 'manual'),
]
man_pages = [
(master_doc, 'dynare', u'Dynare Reference Manual',
[author], 1)
]
def setup(app):
from dynare_dom import DynareDomain
from dynare_lex import DynareLexer
app.add_lexer("dynare", DynareLexer)
app.add_domain(DynareDomain)
.. default-domain:: dynare
.. |br| raw:: html
<br>
####################
Dynare misc commands
####################
.. matcomm:: send_endogenous_variables_to_workspace ;
Puts the simulation results for the endogenous variables stored in ``oo_.endo_simul``
into vectors with the same name as the respective variables into the base workspace.
.. matcomm:: send_exogenous_variables_to_workspace ;
Puts the simulation results for the exogenous variables stored in ``oo_.exo_simul``
into vectors with the same name as the respective variables into the base workspace.
.. matcomm:: send_irfs_to_workspace ;
Puts the IRFs stored in ``oo_.irfs`` into vectors with the same name into the base workspace.
.. command:: prior_function(OPTIONS);
Executes a user-defined function on parameter draws from the prior
distribution. Dynare returns the results of the computations for
all draws in an `ndraws` by :math:`n` cell array named
``oo_.prior_function_results``.
*Options*
.. option:: function = FUNCTION_NAME
The function must have the following header ``output_cell =
FILENAME(xparam1,M_,options_,oo_,estim_params_,bayestopt_,dataset_,dataset_info)``,
providing read-only access to all Dynare structures. The only
output argument allowed is a :math:`1 \times n` cell array,
which allows for storing any type of output/computations. This
option is required.
.. option:: sampling_draws = INTEGER
Number of draws used for sampling. Default: 500.
|br|
.. command:: posterior_function(OPTIONS);
Same as the :comm:`prior_function` command but for the
posterior distribution. Results returned in
``oo_.posterior_function_results``.
*Options*
.. option:: function = FUNCTION_NAME
See :opt:`prior_function_function <function = FUNCTION_NAME>`.
.. option:: sampling_draws = INTEGER
See :opt:`prior_function_sampling_draws <sampling_draws = INTEGER>`.
|br|
.. command:: generate_trace_plots(CHAIN_NUMBER);
Generates trace plots of the MCMC draws for all estimated
parameters and the posterior density for the specified Markov Chain(s)
``CHAIN_NUMBER``. If ``CHAIN_NUMBER`` is a vector of integers, the trace plots
will plot contains separate lines for each chain.
|br|
.. matcomm:: internals FLAG ROUTINENAME[.m]|MODFILENAME
Depending on the value of ``FLAG``, the ``internals`` command
can be used to run unitary tests specific to a MATLAB/Octave
routine (if available), to display documentation about a
MATLAB/Octave routine, or to extract some informations about the
state of Dynare.
*Flags*
``--test``
Performs the unitary test associated to ROUTINENAME (if this
routine exists and if the matlab/octave ``.m`` file has
unitary test sections).
*Example*
::
>> internals --test ROUTINENAME
if ``routine.m`` is not in the current directory, the full
path has to be given::
>> internals --test ../matlab/fr/ROUTINENAME
``--display-mh-history``
Displays information about the previously saved MCMC draws
generated by a ``.mod`` file named MODFILENAME. This file must
be in the current directory.
*Example*
::
>> internals --display-mh-history MODFILENAME
``--load-mh-history``
Loads into the MATLAB/Octave’s workspace informations
about the previously saved MCMC draws generated by a ``.mod``
file named MODFILENAME.
*Example*
::
>> internals --load-mh-history MODFILENAME
This will create a structure called ``mcmc_informations``
(in the workspace) with the following fields:
``Nblck``
The number of MCMC chains.
``InitialParameters``
A ``Nblck*n``, where ``n`` is the number of estimated
parameters, array of doubles. Initial state of
the MCMC.
``LastParameters``
A ``Nblck*n``, where ``n`` is the number of estimated
parameters, array of doubles. Current state of
the MCMC.
``InitialLogPost``
A ``Nblck*1`` array of doubles. Initial value of the
posterior kernel.
``LastLogPost``
A ``Nblck*1`` array of doubles. Current value of the
posterior kernel.
``InitialSeeds``
A ``1*Nblck`` structure array. Initial state of the random
number generator.
``LastSeeds``
A ``1*Nblck`` structure array. Current state of the random
number generator.
``AcceptanceRatio``
A ``1*Nblck`` array of doubles. Current acceptance ratios.
|br|
.. matcomm:: prior [OPTIONS[ ...]];
Prints information about the prior distribution given the provided
options. If no options are provided, the command returns the list of
available options.
*Options*
.. option:: table
Prints a table describing the marginal prior distributions
(mean, mode, std., lower and upper bounds, HPD interval).
.. option:: moments
Computes and displays first and second order moments of the
endogenous variables at the prior mode (considering the
linearized version of the model).
.. option:: moments(distribution)
Computes and displays the prior mean and prior standard
deviation of the first and second moments of the endogenous
variables (considering the linearized version of the model) by
randomly sampling from the prior. The results will also be
stored in the ``prior`` subfolder in a
``_endogenous_variables_prior_draws.mat`` file.
.. option:: optimize
Optimizes the prior density (starting from a random initial
guess). The parameters such that the steady state does not
exist or does not satisfy the Blanchard and Kahn conditions
are penalized, as they would be when maximizing the posterior
density. If a significant proportion of the prior mass is
defined over such regions, the optimization algorithm may fail
to converge to the true solution (the prior mode).
.. option:: simulate
Computes the effective prior mass using a Monte-Carlo. Ideally
the effective prior mass should be equal to 1, otherwise
problems may arise when maximising the posterior density and
model comparison based on marginal densities may be
unfair. When comparing models, say :math:`A` and :math:`B`,
the marginal densities, :math:`m_A` and :math:`m_B`, should be
corrected for the estimated effective prior mass
:math:`p_A\neq p_B \leq 1` so that the prior mass of the
compared models are identical.
.. option:: plot
Plots the marginal prior density.
|br|
.. matcomm:: search VARIABLENAME[ OPTION]
Searches all occurrences of a variable in a model, and prints the
equations where the variable appear in the command line window. If OPTION is
set to `withparamvalues`, the values of the parameters (if available) are
displayed instead of the name of the parameters. Requires the `json` command
line option to be set.
*Example*
Assuming that we already ran a `.mod` file and that the workspace has not
been cleaned after, we can search for all the equations containing variable `X`
::
>> search X
Y = alpha*X/(1-X)+e;
diff(X) = beta*(X(-1)-mX) + gamma1*Z + gamma2*R + u;
To replace the parameters with estimated or calibrated parameters:
::
>> search X withparamvalues
Y = 1.254634*X/(1-X)+e;
diff(X) = -0.031459*(X(-1)-mX) + 0.1*Z - 0.2*R + u;
|br|
.. matcomm:: dplot [OPTION VALUE[ ...]]
Plot expressions extracting data from different dseries objects.
*Options*
.. option:: --expression EXPRESSION
``EXPRESSION`` is a mathematical expression involving variables
available in the dseries objects, dseries methods, numbers or
parameters. All the referenced objects are supposed to be
available in the calling workspace.
.. option:: --dseries NAME
``NAME`` is the name of a dseries object from which the
variables involved in ``EXPRESSION`` will be extracted.
.. option:: --range DATE1:DATE2
This option is not mandatory and allows to plot the expressions
only over a sub-range. ``DATE1`` and ``DATE2`` must be dates as
defined in :ref:`dates in a mod file`.
.. option:: --style MATLAB_SCRIPT_NAME
Name of a Matlab script (without extension) containing Matlab
commands to customize the produced figure.
.. option:: --title MATLAB_STRING
Adds a title to the figure.
.. option:: --with-legend
Prints a legend below the produced plot.
*Remarks*
- More than one --expression argument is allowed, and they must come first.
- For each dseries object we plot all the expressions. We use two
nested loops, the outer loop is over the dseries objects and the
inner loop over the expressions. This determines the ordering of
the plotted lines.
- All dseries objects must be defined in the calling workspace, if a
dseries object is missing the routine throws a warning (we only
build the plots for the available dseries objects), if all dseries
objects are missing the routine throws an error.
- If the range is not provided, the expressions cannot involve leads or lags.
*Example*
::
>> toto = dseries(randn(100,3), dates('2000Q1'), {'x','y','z'});
>> noddy = dseries(randn(100,3), dates('2000Q1'), {'x','y','z'});
>> b = 3;
>> dplot --expression 2/b*cumsum(x/y(-1)-1) --dseries toto --dseries noddy --range 2001Q1:2024Q1 --title 'This is my plot'
will produce plots for ``2/b*cumsum(x/y(-1)-1)``, where ``x`` and
``y`` are variables in dseries objects ``toto`` and ``noddy``, in
the same figure.
.. command:: set_dynare_threads(NAME_OF_MEX_FILE,INTEGER);
A NAME_OF_MEX_FILE and INTEGER pair that can be used to set the number of
parallel threads employed during the execution of .mex files. To get the number
of logical cores `n` available, you can run ``n=numprocs``.
Available NAME_OF_MEX_FILE options are:
``'sparse_hessian_times_B_kronecker_C'``
.mex file used during computation of second-order solutions and in
`identification`. Default number of threads: number of logical cores.
``'local_state_space_iteration_2'``
.mex file used during nonlinear filtering at `order=2` without
`k_order_solver` or with `pruning`. Default number of threads:
number of logical cores.
``'local_state_space_iteration_3'``
.mex file used during nonlinear filtering at `order=3` without
`k_order_solver` or with `pruning`. Default number of threads:
number of logical cores.
``'local_state_space_iteration_k'``
.mex file used during nonlinear filtering at `order>3` (without `pruning`)
or at `order=3` with `k_order_solver` and without `pruning`. Default number of threads: 1.
``'perfect_foresight_problem'``
.mex file used during perfect foresight simulations. Default number of threads:
number of logical cores.
``'k_order_perturbation'``
.mex file used for perturbation solutions with `k_order_solver`. Default number of threads:
half the number of logical cores, but at least 1.
.. default-domain:: dynare
########
Examples
########
Dynare comes with a database of example ``.mod`` files, which are
designed to show a broad range of Dynare features, and are taken from
academic papers for most of them. You should have these files in the
``examples`` subdirectory of your distribution.
Here is a short list of the examples included. For a more complete
description, please refer to the comments inside the files themselves.
``ramst.mod``
An elementary real business cycle (RBC) model, simulated in a
deterministic setup.
``example1.mod``
``example2.mod``
Two examples of a small RBC model in a stochastic setup, presented
in *Collard (2001)* (see the file ``guide.pdf`` which comes with
Dynare).
``example3.mod``
A small RBC model in a stochastic setup, presented in *Collard
(2001)*. The steady state is solved analytically using the
``steady_state_model`` block (see :bck:`steady_state_model`).
``fs2000.mod``
A cash in advance model, estimated by *Schorfheide (2000)*. The
file shows how to use Dynare for estimation.
``fs2000_nonstationary.mod``
The same model than ``fs2000.mod``, but written in non-stationary
form. Detrending of the equations is done by Dynare.
``bkk.mod``
Multi-country RBC model with time to build, presented in *Backus,
Kehoe and Kydland (1992)*. The file shows how to use Dynare’s
macro processor.
``agtrend.mod``
Small open economy RBC model with shocks to the growth trend,
presented in *Aguiar and Gopinath (2004)*.
``Gali_2015.mod``
Basic New Keynesian model of *Galí (2015)*, Chapter 3 showing how to
i) use "system prior"-type prior restrictions as in *Andrle and Plašil (2018)*
and ii) run prior/posterior-functions.
``NK_baseline.mod``
Baseline New Keynesian Model estimated in *Fernández-Villaverde
(2010)*. It demonstrates how to use an explicit steady state file
to update parameters and call a numerical solver.
``Occbin_example.mod``
RBC model with two occasionally binding constraints. Demonstrates
how to set up Occbin.
``Ramsey_Example.mod``
File demonstrating how to conduct optimal policy experiments in a
simple New Keynesian model either under commitment (Ramsey) or using
optimal simple rules (OSR)
``Ramsey_steady_file.mod``
File demonstrating how to conduct optimal policy experiments in a
simple New Keynesian model under commitment (Ramsey) with a user-defined
conditional steady state file
``rbc_irf_matching.mod``
Baseline RBC model with government spending shocks estimated via impulse response function (IRF) matching.
Both Frequentist (Maximum Likelihood) and Bayesian (Slice Sampling) approaches are presented.
Additionally, it is shown how to estimate an AR(2)-process
by working with the roots of the autoregressive process instead of the coefficients
The Dynare Reference Manual, version |version|
==============================================
Currently the development team of Dynare is composed of:
* Stéphane Adjemian (Le Mans Université, Gains)
* Michel Juillard (Banque de France)
* Sumudu Kankanamge (Le Mans Université and CEPREMAP)
* Frédéric Karamé (Le Mans Université, Gains and CEPREMAP)
* Junior Maih (Norges Bank)
* Willi Mutschler (University of Tübingen)
* Johannes Pfeifer (University of the Bundeswehr Munich)
* Marco Ratto (European Commission, Joint Research Centre - JRC)
* Normann Rion (CEPREMAP)
* Sébastien Villemot (CEPREMAP)
The following people used to be members of the team:
* Houtan Bastani
* Abdeljabar Benzougar
* Alejandro Buesa
* Fabrice Collard
* Assia Ezzeroug
* Dóra Kocsis
* Stéphane Lhuissier
* Ferhat Mihoubi
* George Perendia
Copyright © 1996-2025, Dynare Team.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license can be found at `https://www.gnu.org/licenses/fdl.txt <https://www.gnu.org/licenses/fdl.txt>`__.
.. toctree::
:numbered:
:maxdepth: 4
introduction
installation-and-configuration
running-dynare
the-model-file
the-configuration-file
time-series
reporting
examples
dynare-misc-commands
bibliography
.. only:: builder_html
Indices and tables
==================
* :ref:`genindex`
.. default-domain:: dynare
##############################
Installation and configuration
##############################
Software requirements
=====================
Packaged versions of Dynare are available for Windows (10 and 11), several
GNU/Linux distributions (Debian, Ubuntu, Linux Mint, Arch Linux), macOS (15
“Sequoia”), and FreeBSD. Dynare should work on other systems, but some
compilation steps are necessary in that case.
In order to run Dynare, you need one of the following:
* MATLAB, any version ranging from 9.5 (R2018b) to 24.2 (R2024b);
* GNU Octave, any version ranging from 7.1.0 to 9.4.0, with the ``statistics`` package
from `Octave-Forge`_. Note however that the Dynare installer for Windows
requires a more specific version of Octave, as indicated on the download
page.
The following optional extensions are also useful to benefit from
extra features, but are in no way required:
* If under MATLAB: the
* Optimization Toolbox (providing various optimizers
like ``fminsearch``, ``fmincon``, or ``fminunc``, used in e.g. ``mode_compute``,
``opt_algo`` or ``ALGO``),
* Statistics Toolbox (for faster and sometimes more robust implementations of
statistical distributions),
* Global Optimization Toolbox (for ``particleswarm`` and ``simulannealbnd``, used in
e.g. ``mode_compute``, ``opt_algo`` or ``ALGO``)
* Control System Toolbox (for the Lyapunov solver ``dlyapchol`` triggered with ``lyapunov=square_root_solver``)
* Parallel Computing Toolbox (to speed up the ``dime`` sampler)
* If under Octave, the following `Octave-Forge`_ packages: ``optim``, ``io``,
``control``.
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.
On Windows
----------
Execute the automated installer called ``dynare-x.y-win.exe`` (where
``x.y`` is the version number), and follow the instructions. The
default installation directory is ``c:\dynare\x.y``.
After installation, this directory will contain several
sub-directories, among which are ``matlab``, ``mex`` and ``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 ``c:\dynare``), as long as you correctly adjust your path
settings (see see :ref:`words-warning`).
Also note that it is possible to do a silent installation, by passing the
``/S`` flag to the installer on the command line. This can be useful when
doing an unattended installation of Dynare on a computer pool.
On GNU/Linux
------------
On Debian, Ubuntu and Linux Mint, the Dynare package can be installed with:
``apt install dynare``. This will give a fully-functional Dynare installation
usable with Octave. If you have MATLAB installed, you should also do: ``apt
install dynare-matlab`` (under Debian, this package is in the ``contrib``
section). Documentation can be installed with ``apt install dynare-doc``. The
status of those packages can be checked at those pages:
* `Package status in Debian`_
* `Package status in Ubuntu`_
* `Package status in Linux Mint`_
On Arch Linux, the Dynare package is not in the official repositories, but is
available in the `Arch User Repository`_. The needed sources can be
downloaded from the `package status in Arch Linux`_.
There is also a Dynare package for openSUSE, see the `package status in
openSUSE`_.
Dynare will be installed under ``/usr/lib/dynare`` (or ``/usr/lib64/dynare`` on
openSUSE). Documentation will be under ``/usr/share/doc/dynare`` (only on
Debian, Ubuntu and Linux Mint).
On macOS
--------
.. warning::
Installing into ``/Applications/dynare`` might fail if you have older versions of Dynare already installed in ``/Applications/Dynare``.
To fix this, modify the ownership by executing the following command in Terminal.app::
sudo chown -R "$USER":staff /Applications/Dynare
Alternatively, you can modify the installation path in the automated installed using *Customize* and *Location*.
After installation, the folder will contain several sub-directories, among which are ``matlab``, ``mex``, and ``doc``.
Several versions of Dynare can coexist (by default in ``/Applications/Dynare``),
as long as you correctly adjust your path settings (see :ref:`words-warning`).
With MATLAB
^^^^^^^^^^^
To install Dynare for use with MATLAB, execute the automated installer called
``dynare-x.y-arch.pkg`` (where *x.y* is the version number and *arch* is either arm64 for Apple Silicon or x86_64 for Intel architectures),
and follow the instructions.
This installation does not require administrative privileges.
If for some reason admin rights are requested, use *Change Install Location* and select *Install for me only*.
The default installation directory is ``/Applications/Dynare/x.y-arch``.
It is recommended to install the Xcode Command Line Tools (this is an Apple product)
and GCC via Homebrew_ (see :ref:`prerequisites-macos`).
To deinstall Dynare, simply delete the folder where you installed the program. The package installer does
not put any files anywhere else in the system.
With Octave
^^^^^^^^^^^
We don’t provide Dynare packages for macOS with Octave support, but there is a
Dynare package with Octave support in Homebrew_.
Once Homebrew_ is installed, run a terminal and install Dynare (and Octave) by
typing the following::
brew install dynare
Then open Octave by running the following in the same terminal::
octave --gui
Finally, at the Octave prompt, install some add-ons (you only have to do it
once)::
octave:1> pkg install -forge io statistics control struct optim
If you want to use the `x13` functionality of `dseries`, you also need to build the `x13as` binary. [#fx13]_
On FreeBSD
----------
A `FreeBSD port for Dynare <https://www.freshports.org/science/dynare/>`__ is
available. It can be installed with::
pkg install dynare
For other systems
-----------------
You need to download Dynare source code from the `Dynare website`_ and
unpack it somewhere.
Then you will need to recompile the pre-processor and the dynamic
loadable libraries. Please refer to `README.md
<https://git.dynare.org/Dynare/dynare/blob/master/README.md>`__.
.. _compil-install:
Compiler installation
=====================
Prerequisites on Windows
------------------------
There are no prerequisites on Windows. Dynare now ships a compilation
environment that can be used with the :opt:`use_dll` option.
Prerequisites on GNU/Linux
--------------------------
Users of MATLAB under GNU/Linux need a working compilation environment
installed. Under Debian, Ubuntu or Linux Mint, it can be installed via ``apt
install build-essential``.
Users of Octave under GNU/Linux should install the package for MEX file
compilation (under Debian, Ubuntu or Linux Mint, it can be done via ``apt
install liboctave-dev``).
.. _prerequisites-macos:
Prerequisites on macOS
----------------------
With MATLAB
^^^^^^^^^^^
Dynare now ships a compilation environment that can be used with the
:opt:`use_dll` option. To install this environment correctly, the Dynare
installer ensures that the Xcode Command Line Tools (an Apple product) have
been installed on a system folder. To install the Xcode Command Line Tools
yourself, simply type ``xcode-select --install`` into the terminal
(``/Applications/Utilities/Terminal.app``) prompt.
Additionally, to make MATLAB aware that you agree to the terms of Xcode, run the following two commands in the Terminal prompt::
CLT_VERSION=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version | awk '{print $2}' | cut -d'.' -f1-2)
defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense "${CLT_VERSION}"
defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense
Otherwise you will see a warning that Xcode is installed, but its license has not been accepted.
You can check this e.g. by running the following command in the MATLAB command window::
mex -setup
Moreover, we recommend making use of optimized compilation flags when using :opt:`use_dll` and for this you need to install GCC via Homebrew_::
brew install gcc
If you already have installed GCC, Dynare will automatically prefer it for :opt:`use_dll`
if the binaries are either in ``/opt/homebrew/bin`` on Apple Silicon (arm64) or in ``/usr/local/bin`` on Intel (x86_64) systems.
Otherwise, it will fall back to Clang in ``/usr/bin/clang``, which works both on arm64 and x86_64 systems.
With Octave
^^^^^^^^^^^
The compiler can be installed via Homebrew_. In a terminal, run::
brew install gcc
Configuration
=============
For MATLAB
----------
.. highlight:: matlab
You need to add the ``matlab`` subdirectory of your Dynare
installation to MATLAB path. You have two options for doing that:
* Using the ``addpath`` command in the MATLAB command window:
Under Windows, assuming that you have installed Dynare in the
standard location, and replacing ``x.y`` with the correct version
number, type::
>> addpath c:/dynare/x.y/matlab
Under GNU/Linux, type::
>> addpath /usr/lib/dynare/matlab
Under macOS, assuming that you have installed Dynare in the standard
location, and replacing ``x.y`` with the correct version number,
type::
>> addpath /Applications/Dynare/x.y/matlab
MATLAB will not remember this setting next time you run it, and you
will have to do it again.
* Via the menu entries:
Select the “Set Path” entry in the “File” menu, then click on “Add
Folder…”, and select the ``matlab`` subdirectory of ‘your Dynare
installation. Note that you *should not* use “Add with
Subfolders…”. Apply the settings by clicking on “Save”. Note that
MATLAB will remember this setting next time you run it.
For Octave
----------
You need to add the ``matlab`` subdirectory of your Dynare
installation to Octave path, using the ``addpath`` at the Octave
command prompt.
Under Windows, assuming that you have installed Dynare in the standard
location, and replacing “*x.y*” with the correct version number,
type::
octave:1> addpath c:/dynare/x.y/matlab
Under Debian, Ubuntu or Linux Mint, there is no need to use the ``addpath``
command; the packaging does it for you. Under Arch Linux, you need to do::
octave:1> addpath /usr/lib/dynare/matlab
Under macOS, assuming you have installed Dynare via Homebrew_::
octave:1> addpath /usr/local/lib/dynare/matlab
If you don’t want to type this command every time you run Octave, you
can put it in a file called ``.octaverc`` in your home directory
(under Windows this will generally be ``c:\Users\USERNAME`` while under macOS it is
``/Users/USERNAME/``). This file is run by Octave at every startup.
.. _words-warning:
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 ``path`` in the
command window.
The path should normally contain system directories of MATLAB or
Octave, and some subdirectories of your Dynare installation. You have
to manually add the ``matlab`` subdirectory, and Dynare will
automatically add a few other subdirectories at runtime (depending on
your configuration). You must verify that there is no directory coming
from another version of Dynare than the one you are planning to use.
You have to be aware that adding other directories (on top of the
dynare folders) to your MATLAB or Octave path can potentially create
problems if any of your M-files have the same name as a Dynare
file. Your routine would then override the Dynare routine, making
Dynare unusable.
.. warning::
Never add all the subdirectories of the ``matlab`` folder to the
MATLAB or Octave path. You must let Dynare decide which subdirectories
have to be added to the MATLAB or Octave path. Otherwise, you may
end up with a non optimal or un-usable installation of Dynare.
.. _Package status in Debian: https://packages.debian.org/sid/dynare
.. _Package status in Ubuntu: https://launchpad.net/ubuntu/+source/dynare
.. _Package status in Linux Mint: https://community.linuxmint.com/software/view/dynare
.. _Package status in Arch Linux: https://aur.archlinux.org/packages/dynare/
.. _Package status in openSUSE: https://software.opensuse.org/package/dynare
.. _Arch User Repository: https://wiki.archlinux.org/index.php/Arch_User_Repository
.. _Dynare website: https://www.dynare.org/
.. _Dynare wiki: https://git.dynare.org/Dynare/dynare/wikis
.. _Octave-Forge: https://octave.sourceforge.io/
.. _Homebrew: https://brew.sh
.. rubric:: Footnotes
.. [#fx13] See the instructions at `<https://forum.dynare.org/t/missing-installation-package/27350/4>`__.
\ No newline at end of file
.. default-domain:: dynare
############
Introduction
############
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 *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, …
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
license.txt in Dynare distribution). It is available for the Windows,
macOS, and Linux platforms and is fully documented through a reference
manual. Part of Dynare is programmed in C++, while the rest is written
using the `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 `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 `CEPREMAP`_ by a core team
of researchers who devote part of their time to software
development. 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).
Interaction between developers and users of Dynare is central to the
project. A `web forum`_ is available for users who have questions
about the usage of Dynare or who want to report bugs. Current known
and fixed bugs are listed on the `Dynare wiki`_. Issues or whishes can
be reported on our `Git repository`_. 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.
Documentation sources
=====================
The present document is the reference manual for Dynare. It documents
all commands and features in a systematic fashion.
Other useful sources of information include the `Dynare wiki`_ and the
`Dynare forums`_.
Citing Dynare in your research
==============================
You should cite Dynare if you use it in your research. The
recommended way todo this is to cite the present manual, as:
Stéphane Adjemian, Michel Juillard, Frédéric Karamé, Willi Mutschler,
Johannes Pfeifer, Marco Ratto, Normann Rion and Sébastien Villemot (2024),
“Dynare: Reference Manual, Version 6,” *Dynare Working Papers*, 80, CEPREMAP
For convenience, you can copy and paste the following into your BibTeX file:
.. code-block:: bibtex
@TechReport{Adjemianetal2024,
author = {Adjemian, St\'ephane and Juillard, Michel and
Karam\'e, Fr\'ederic and Mutschler, Willi and
Pfeifer, Johannes and Ratto, Marco and
Rion, Normann and Villemot, S\'ebastien},
title = {Dynare: Reference Manual, Version 6},
year = {2024},
institution = {CEPREMAP},
type = {Dynare Working Papers},
number = {80},
}
If you want to give a URL, use the address of the Dynare website:
https://www.dynare.org.
.. _MATLAB: https://www.mathworks.com/products/matlab/
.. _GNU Octave: https://www.octave.org/
.. _CEPREMAP: https://www.cepremap.fr/
.. _web forum: https://forum.dynare.org/
.. _official Dynare website: https://www.dynare.org/
.. _Dynare wiki: https://git.dynare.org/Dynare/dynare/wikis
.. _Dynare forums: https://forum.dynare.org/
.. _Git repository: https://git.dynare.org/Dynare/dynare
.. default-domain:: dynare
.. |br| raw:: html
<br>
.. highlight:: matlab
#########
Reporting
#########
Dynare provides a simple interface for creating :math:`\text{\LaTeX}`
reports, comprised of :math:`\text{\LaTeX}` tables and ``PGFPLOTS/TikZ
graphs``. You can use the report as created through Dynare or pick out
the pieces (tables and graphs) you want for inclusion in your own
paper. Though Dynare provides a subset of options available through
``PGFPLOTS/TikZ``, you can easily modify the graphs created by Dynare
using the options available in the ``PGFPLOTS/TikZ`` manual. You can
either do this manually or by passing the options to
:opt:`miscTikzAxisOptions <miscTikzAxisOptions, STRING>` or
:opt:`graphMiscTikzAddPlotOptions <graphMiscTikzAddPlotOptions,
STRING>`.
Reports are created and modified by calling methods on class
objects. The objects are hierarchical, with the following order (from
highest to lowest): ``Report``, ``Page``, ``Section``,
``Graph/Table/Vspace``, ``Series``. For simplicity of syntax, we
abstract away from these classes, allowing you to operate directly on
a ``Report`` object, while maintaining the names of these classes in
the ``Report`` class methods you will use.
The report is created sequentially, command by command, hence the
order of the commands matters. When an object of a certain hierarchy
is inserted, all methods will function on that object until an object
of equal or greater hierarchy is added. Hence, once you add a ``Page``
to the report, every time you add a ``Section`` object, it will be
added to this ``Page`` until another ``Page`` is added to the report
(via :repmeth:`addPage`). This will become more clear with the example
at the end of the section.
Options to methods are passed differently than those to Dynare
commands. They take the form of named options to MATLAB functions
where the arguments come in pairs
(e.g. ``function_name(`option_1_name', `option_1_value',
`option_2_name', `option_2_value', ...)``, where ``option_X_name`` is
the name of the option while ``option_X_value`` is the value assigned
to that option). The ordering of the option pairs matters only in the
unusual case when an option is provided twice (probably
erroneously). In this case, the last value passed is the one that is
used.
Below, you will see a list of methods available for the Report class
and a clarifying example.
.. construct:: report
|br| Instantiates a ``Report`` object.
*Options*
.. option:: compiler, FILENAME
The full path to the :math:`\text{\LaTeX}` compiler on your
system. If this option is not provided, Dynare will try to
find the appropriate program to compile :math:`\text{\LaTeX}` on your
system. Default is system dependent:
* Windows: the result of findtexmf ``--file-type=exe pdflatex``.
* macOS and Linux: the result of ``which pdflatex``.
.. option:: directory, FILENAME
The path to the directory you want the report created in. Default:
current directory.
.. option:: showDate, BOOLEAN
Display the date and time when the report was
compiled. Default: ``true``.
.. option:: fileName, FILENAME
The file name to use when saving this report. Default: ``report.tex``.
.. option:: header, STRING
The valid :math:`\text{\LaTeX}` code to be included in the report before
``\begin{document}``. Default: ``empty``.
.. option:: maketoc, BOOLEAN
Whether or not to make the table of contents. One entry is made per
page containing a title. Default: ``false``.
.. option:: margin, DOUBLE
The margin size. Default: ``2.5``.
.. option:: marginUnit, `cm' | `in'
Units associated with the margin. Default: ```cm'``.
.. option:: orientation, `landscape' | `portrait'
Paper orientation: Default: ```portrait'``.
.. option:: paper, `a4' | `letter'
Paper size. Default: ```a4'``.
.. option:: reportDirName, FILENAME
The name of the folder in which to store the component parts of the
report (preamble, document, end). Default: ``tmpRepDir``.
.. option:: showDate, BOOLEAN
Display the date and time when the report was compiled. Default: true.
.. option:: showOutput, BOOLEAN
Print report creation progress to screen. Shows you the page
number as it is created and as it is written. This is useful
to see where a potential error occurs in report
creation. Default: ``true``.
.. option:: title, STRING
Report Title. Default: ``none``.
.. reportingmethod:: addPage
|br| Adds a Page to the Report.
*Options*
.. option:: footnote, STRING
A footnote to be included at the bottom of this page. Default: ``none``.
.. option:: latex, STRING
The valid :math:`\text{\LaTeX}` code to be used for this
page. Alows the user to create a page to be included in the
report by passing :math:`\text{\LaTeX}` code directly. If this option is
passed, the page itself will be saved in the :opt:`pageDirName
<pageDirName, FILENAME>` directory in the form ``page_X.tex``
where X refers to the page number. Default: ``empty``.
.. option:: orientation, `landscape' | `portrait'
See :opt:`orientation <orientation, `landscape' | `portrait'>`.
.. option:: pageDirName, FILENAME
The name of the folder in which to store this page. Directory given is
relative to the `directory` option of the report class. Only used when
the :opt:`latex <latex, STRING>` command is passed. Default:
``tmpRepDir``.
.. option:: paper, `a4' | `letter'
See :opt:`paper <paper, `a4' | `letter'>`.
.. option:: title, STRING | CELL_ARRAY_STRINGS
With one entry (a STRING), the title of the page. With more
than one entry (a CELL_ARRAY_STRINGS), the title and
subtitle(s) of the page. Values passed must be valid
:math:`\text{\LaTeX}` code (e.g., ``%`` must be
``\%``). Default: ``none``.
.. option:: titleFormat, STRING | CELL_ARRAY_STRINGS
A string representing the valid :math:`\text{\LaTeX}` markup to use on
``title``. The number of cell array entries must be equal to
that of the ``title`` option if you do not want to use the
default value for the title (and subtitles). Default:
``\large\bfseries``.
.. option:: titleTruncate, INTEGER
Useful when automatically generating page titles that may
become too long, ``titleTruncate`` can be used to truncate a
title (and subsequent subtitles) when they pass the specified
number of characters. Default: ``.off``.
.. reportingmethod:: addSection
|br| Adds a ``Section`` to a ``Page``.
*Options*
.. option:: cols, INTEGER
The number of columns in the section. Default: ``1``.
.. option:: height, STRING
A string to be used with the ``\sectionheight`` :math:`\text{\LaTeX}`
command. Default: ``'!'``
.. reportingmethod:: addGraph
|br| Adds a ``Graph`` to a ``Section``.
*Options*
.. option:: data, dseries
The ``dseries`` that provides the data for the graph. Default: ``none``.
.. option:: axisShape, `box' | `L'
The shape the axis should have. ```box'`` means that there is
an axis line to the left, right, bottom, and top of the
graphed line(s). 'L'`` means that there is an axis to the left
and bottom of the graphed line(s). Default: ```box'``.
.. option:: graphDirName, FILENAME
The name of the folder in which to store this figure. Directory given
is relative to the `directory` option of the report class. Default:
``tmpRepDir``.
.. option:: graphName, STRING
The name to use when saving this figure. Default: something of
the form ``graph_pg1_sec2_row1_col3.tex``.
.. option:: height, DOUBLE
The height of the graph, in inches. Default: ``4.5``.
.. option:: showGrid, BOOLEAN
Whether or not to display the major grid on the
graph. Default: ``true``.
.. option:: showLegend, BOOLEAN
Whether or not to display the legend.
Unless you use the :opt:`graphLegendName <graphLegendName,
STRING>` option, the name displayed in the legend is the tex
name associated with the ``dseries``. You can modify this tex
name by using :dsermeth:`tex_rename <B =
tex_rename>`. Default: ``false``.
.. option:: legendAt, NUMERICAL_VECTOR
The coordinates for the legend location. If this option is
passed, it overrides the :opt:`legendLocation <legendLocation,
OPTION>` option. Must be of size ``2``. Default: ``empty``.
.. option:: showLegendBox, BOOLEAN
Whether or not to display a box around the legend. Default: ``false``.
.. option:: legendLocation, OPTION
Where to place the legend in the graph. Possible values for OPTION are::
`south west' | `south east' | `north west' | `north east' | `outer north east'
Default: ```south east'``.
.. option:: legendOrientation, `vertical' | `horizontal'
Orientation of the legend. Default: ```horizontal'``.
.. option:: legendFontSize, OPTION
The font size for legend entries. Possible values for OPTION are::
`tiny' | `scriptsize' | `footnotesize' | `small' | `normalsize' |
`large' | `Large' | `LARGE' | `huge' | `Huge'
Default: ``tiny``.
.. option:: miscTikzAxisOptions, STRING
If you are comfortable with ``PGFPLOTS/TikZ``, you can use
this option to pass arguments directly to the
``PGFPLOTS/TikZ`` axis environment command. Specifically to be
used for desired ``PGFPLOTS/TikZ`` options that have not been
incorporated into Dynare Reporting. Default: ``empty``.
.. option:: miscTikzPictureOptions, STRING
If you are comfortable with ``PGFPLOTS/TikZ``, you can use
this option to pass arguments directly to the
``PGFPLOTS/TikZ`` ``tikzpicture`` environment command. (e.g.,
to scale the graph in the x and y dimensions, you can pass
following to this option: 'xscale=2.5,
yscale=0.5'``). Specifically to be used for desired
``PGFPLOTS/TikZ`` options that have not been incorporated into
Dynare Reporting. Default: ``empty``.
.. option:: seriesToUse, CELL_ARRAY_STRINGS
The names of the series contained in the ``dseries`` provided
to the :opt:`data <data, dseries>` option. If empty, use all
series provided to ``data`` option. Default: ``empty``.
.. option:: shade, dates
The date range showing the portion of the graph that should be
shaded. Default: ``none``.
.. option:: shadeColor, STRING
The color to use in the shaded portion of the graph. All valid
color strings defined for use by ``PGFPLOTS/TikZ`` are
valid. A list of defined colors is::
'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black', 'gray',
'white','darkgray', 'lightgray', 'brown', 'lime', 'olive', 'orange',
'pink', 'purple', 'teal', 'violet'.
Furthermore, You can use combinations of these colors. For
example, if you wanted a color that is 20\% green and 80\%
purple, you could pass the string ``'green!20!purple'``. You
can also use RGB colors, following the syntax:
```rgb,255:red,231;green,84;blue,121'`` which corresponds to
the RGB color ``(231;84;121)``. More examples are available in
the section 4.7.5 of the ``PGFPLOTS/TikZ`` manual, revision
1.10. Default: ```green'``
.. option:: shadeOpacity, DOUBLE
The opacity of the shaded area, must be in ``[0,100]``. Default: ``20``.
.. option:: tickFontSize, OPTION
The font size for x- and y-axis tick labels. Possible values
for OPTION are::
`tiny' | `scriptsize' | `footnotesize' | `small' | `normalsize' |
`large' | `Large' | `LARGE' | `huge' | `Huge'
Default: ``normalsize``.
.. option:: title, STRING | CELL_ARRAY_STRINGS
Same as :opt:`title <title, STRING | CELL_ARRAY_STRINGS>`,
just for graphs.
.. option:: titleFontSize, OPTION
The font size for title. Possible values for OPTION are::
`tiny' | `scriptsize' | `footnotesize' | `small' | `normalsize' |
`large' | `Large' | `LARGE' | `huge' | `Huge'
Default: ``normalsize``.
.. option:: titleFormat, STRING
The format to use for the graph title. Unlike
:opt:`titleFormat <titleFormat, STRING | CELL_ARRAY_STRINGS>`,
due to a constraint of ``TikZ``, this format applies to the
title and subtitles. Default: ``TikZ`` default.
.. option:: width, DOUBLE
The width of the graph, in inches. Default: ``6.0``.
.. option:: writeCSV, BOOLEAN
Whether or not to write a CSV file with only the plotted
data. The file will be saved in the directory specified by
:opt:`graphDirName <graphDirName, FILENAME>` with the same base
name as specified by :opt:`graphName <graphName, STRING>` with
the ending ``.csv``. Default: ``false``.
.. option:: xlabel, STRING
The x-axis label. Default: ``none``.
.. option:: ylabel, STRING
The y-axis label. Default: ``none``.
.. option:: xAxisTight, BOOLEAN
Use a tight x axis. If false, uses ``PGFPLOTS/TikZ`` ``enlarge
x limits`` to choose appropriate axis size. Default: ``true``.
.. option:: xrange, dates
The boundary on the x-axis to display in the graph. Default: ``all``.
.. option:: xTicks, NUMERICAL_VECTOR
Used only in conjunction with :opt:`xTickLabels <xTickLabels,
CELL_ARRAY_STRINGS | `ALL'>`, this option denotes the
numerical position of the label along the x-axis. The
positions begin at ``1``. Default: the indices associated with
the first and last dates of the ``dseries`` and, if passed,
the index associated with the first date of the :opt:`shade
<shade, dates>` option.
.. option:: xTickLabels, CELL_ARRAY_STRINGS | `ALL'
The labels to be mapped to the ticks provided by
``xTicks``. Default: the first and last dates of the
``dseries`` and, if passed, the date first date of the
:opt:`shade <shade, dates>` option.
.. option:: xTickLabelAnchor, STRING
Where to anchor the x tick label. Default: ```east'``.
.. option:: xTickLabelRotation, DOUBLE
The amount to rotate the x tick labels by. Default: ``0``.
.. option:: yAxisTight, BOOLEAN
Use a tight y axis. If false, uses ``PGFPLOTS/TikZ`` ``enlarge
y limits`` to choose appropriate axis size. Default:
``false``.
.. option:: yrange, NUMERICAL_VECTOR
The boundary on the y-axis to display in the graph,
represented as a ``NUMERICAL_VECTOR`` of size ``2``, with the
first entry less than the second entry. Default: ``all``.
.. option:: yTickLabelFixed, BOOLEAN
Round the y tick labels to a fixed number of decimal places,
given by ``yTickLabelPrecision``. Default: ``true``.
.. option:: yTickLabelPrecision, INTEGER
The precision with which to report the ``yTickLabel``. Default: ``0``.
.. option:: yTickLabelScaled, BOOLEAN
Determines whether or not there is a common scaling factor for
the y axis. Default: ``true``.
.. option:: yTickLabelZeroFill, BOOLEAN
Whether or not to fill missing precision spots with
zeros. Default: ``true``.
.. option:: showZeroline, BOOLEAN
Display a solid black line at :math:`y = 0`. Default: ``false``.
.. option:: zeroLineColor, STRING
The color to use for the zero line. Only used if
:opt:`showZeroLine <showZeroline, BOOLEAN>` is true. See the
explanation in :opt:`shadeColor <shadeColor, STRING>` for how
to use colors with reports. Default: ```black'``.
.. reportingmethod:: addTable
|br| Adds a ``Table`` to a ``Section``.
*Options*
.. option:: data, dseries
See :opt:`data <data, dseries>`.
.. option:: highlightRows, CELL_ARRAY_STRINGS
A cell array containing the colors to use for row
highlighting. See :opt:`shadeColor <shadeColor, STRING>` for
how to use colors with reports. Highlighting for a specific
row can be overridden by using the :opt:`tableRowColor
<tableRowColor, STRING>` option to
:repmeth:`addSeries`. Default: ``empty``.
.. option:: showHlines, BOOLEAN
Whether or not to show horizontal lines separating the
rows. Default: ``false``.
.. option:: precision, INTEGER
The number of decimal places to report in the table data
(rounding done via the *round half away from zero*
method). Default: ``1``.
.. option:: range, dates
The date range of the data to be displayed. Default: ``all``.
.. option:: seriesToUse, CELL_ARRAY_STRINGS
See :opt:`seriesToUse <seriesToUse, CELL_ARRAY_STRINGS>`.
.. option:: tableDirName, FILENAME
The name of the folder in which to store this table. Directory given is
relative to the `directory` option of the report class. Default:
``tmpRepDir``.
.. option:: tableName, STRING
The name to use when saving this table. Default: something of
the form ``table_pg1_sec2_row1_col3.tex``.
.. option:: title, STRING
Same as :opt:`title <title, STRING>`, just for tables.
.. option:: titleFormat, STRING
Same as :opt:`titleFormat <titleFormat, STRING | CELL_ARRAY_STRINGS>`,
just for tables. Default: ``\large``.
.. option:: vlineAfter, dates | CELL_ARRAY_DATES
Show a vertical line after the specified date (or dates if a
cell array of dates is passed). Default: ``empty``.
.. option:: vlineAfterEndOfPeriod, BOOLEAN
Show a vertical line after the end of every period (i.e. after
every year, after the fourth quarter, etc.). Default:
``false``.
.. option:: showVlines, BOOLEAN
Whether or not to show vertical lines separating the
columns. Default: ``false``.
.. option:: writeCSV, BOOLEAN
Whether or not to write a CSV file containing the data
displayed in the table. The file will be saved in the
directory specified by :opt:`tableDirName <tableDirName,
FILENAME>` with the same base name as specified by
:opt:`tableName <tableName, STRING>` with the ending
``.csv``. Default: ``false``.
.. reportingmethod:: addSeries
|br| Adds a ``Series`` to a ``Graph`` or a ``Table``.
Options specific to graphs begin with ```graph'`` while options
specific to tables begin with ```table'``.
*Options*
.. option:: data, dseries
See :opt:`data <data, dseries>`.
.. option:: graphBar, BOOLEAN
Whether or not to display this series as a bar graph as oppsed
to the default of displaying it as a line graph. Default:
``false``.
.. option:: graphFanShadeColor, STRING
The shading color to use between a series and the
previously-added series in a graph. Useful for making fan
charts. Default: ``empty``.
.. option:: graphFanShadeOpacity, INTEGER
The opacity of the color passed in :opt:`graphFanShadeColor
<graphFanShadeColor, STRING>`. Default: ``50``.
.. option:: graphBarColor, STRING
The outline color of each bar in the bar graph. Only active if
:opt:`graphBar <graphBar, BOOLEAN>` is passed. Default:
```black'``.
.. option:: graphBarFillColor, STRING
The fill color of each bar in the bar graph. Only active if
:opt:`graphBar <graphBar, BOOLEAN>` is passed. Default:
```black'``.
.. option:: graphBarWidth, DOUBLE
The width of each bar in the bar graph. Only active if
:opt:`graphBar <graphBar, BOOLEAN>` is passed. Default: ``2``.
.. option:: graphHline, DOUBLE
Use this option to draw a horizontal line at the given
value. Default: ``empty``.
.. option:: graphLegendName, STRING
The name to display in the legend for this series, passed as
valid :math:`\text{\LaTeX}` (e.g., ``GDP_{US}, $\alpha$,
\color{red}GDP\color{black}``). Will be displayed only if the
``data`` and :opt:`showLegend <showLegend, BOOLEAN>` options
have been passed. Default: the tex name of the series.
.. option:: graphLineColor, STRING
Color to use for the series in a graph. See the explanation in
:opt:`shadeColor <shadeColor, STRING>` for how to use colors
with reports. Default: ```black'``
.. option:: graphLineStyle, OPTION
Line style for this series in a graph. Possible values for OPTION are::
`none' | `solid' | `dotted' | `densely dotted' | `loosely dotted' | `dashed' |
`densely dashed' | `loosely dashed' | `dashdotted' | `densely dashdotted' |
`loosely dashdotted' | `dashdotdotted' | `densely dashdotdotted' |
`loosely dashdotdotted'
Default: ```solid'``.
.. option:: graphLineWidth DOUBLE
Line width for this series in a graph. Default: ``0.5``.
.. option:: graphMarker, OPTION
The Marker to use on this series in a graph. Possible values
for OPTION are::
`x' | `+' | `-' | `|' | `o' | `asterisk' | `star' | `10-pointed star' |
`oplus' | `oplus*' | `otimes' | `otimes*' | `square' | `square*' |
`triangle' | `triangle*' | `diamond' | `diamond*' | `halfdiamond*' |
`halfsquare*' | `halfsquare right*' | `halfsquare left*' | `Mercedes star' |
`Mercedes star flipped' | `halfcircle' | `halfcircle*' | `pentagon' |
`pentagon star'
Default: ``none``.
.. option:: graphMarkerEdgeColor, STRING
The edge color of the graph marker. See the explanation in
:opt:`shadeColor <shadeColor, STRING>` for how to use colors
with reports. Default: ``graphLineColor``.
.. option:: graphMarkerFaceColor, STRING
The face color of the graph marker. See the explanation in
:opt:`shadeColor <shadeColor, STRING>` for how to use colors
with reports. Default: ``graphLineColor``.
.. option:: graphMarkerSize, DOUBLE
The size of the graph marker. Default: ``1``.
.. option:: graphMiscTikzAddPlotOptions, STRING
If you are comfortable with ``PGFPLOTS/TikZ``, you can use
this option to pass arguments directly to the
``PGFPLOTS/TikZ`` ``addPlots`` command. (e.g., Instead of
passing the marker options above, you can pass a string such
as the following to this option: ```mark=halfcircle*,mark
options={rotate=90,scale=3}'``). Specifically to be used for
desired ``PGFPLOTS/TikZ`` options that have not been
incorporated into Dynare Reproting. Default: ``empty``.
.. option:: graphShowInLegend, BOOLEAN
Whether or not to show this series in the legend, given that
the :opt:`showLegend <showLegend, BOOLEAN>` option was passed
to :repmeth:`addGraph`. Default: ``true``.
.. option:: graphVline, dates
Use this option to draw a vertical line at a given
date. Default: ``empty``.
.. option:: tableDataRhs, dseries
A series to be added to the right of the current
series. Usefull for displaying aggregate data for a
series. e.g if the series is quarterly ``tableDataRhs`` could
point to the yearly averages of the quarterly series. This
would cause quarterly data to be displayed followed by annual
data. Default: ``empty``.
.. option:: tableRowColor, STRING
The color that you want the row to be. Predefined values
include ``LightCyan`` and ``Gray``. Default: ``white``.
.. option:: tableRowIndent, INTEGER
The number of times to indent the name of the series in the
table. Used to create subgroups of series. Default: ``0``.
.. option:: tableShowMarkers, BOOLEAN
In a Table, if ``true``, surround each cell with brackets and
color it according to :opt:`tableNegColor <tableNegColor,
LATEX_COLOR>` and :opt:`tablePosColor <tablePosColor,
LATEX_COLOR>`. No effect for graphs. Default: ``false``.
.. option:: tableAlignRight, BOOLEAN
Whether or not to align the series name to the right of the
cell. Default: ``false``.
.. option:: tableMarkerLimit, DOUBLE
For values less than :math:`-1*\texttt{tableMarkerLimit}`,
mark the cell with the color denoted by tableNegColor. For
those greater than ``tableMarkerLimit``, mark the cell with
the color denoted by tablePosColor. Default: ``1e-4``.
.. option:: tableNaNSymb, STRING
Replace ``NaN`` values with the text in this option. Default: ``NaN``.
.. option:: tableNegColor, LATEX_COLOR
The color to use when marking Table data that is less than
zero. Default: ```red'``
.. option:: tablePrecision, INTEGER
The number of decimal places to report in the table
data. Default: the value set by :opt:`precision <precision,
INTEGER>`.
.. option:: tablePosColor, LATEX_COLOR
The color to use when marking Table data that is greater than
zero. Default: ```blue'``
.. option:: tableSubSectionHeader, STRING
A header for a subsection of the table. No data will be
associated with it. It is equivalent to adding an empty series
with a name. Default: ``''``
.. option:: zeroTol, DOUBLE
The zero tolerance. Anything smaller than ``zeroTol`` and
larger than ``-zeroTol`` will be set to zero before being
graphed or written to the table. Default: ``1e-6``.
.. reportingmethod:: addParagraph
|br| Adds a ``Paragraph`` to a ``Section``.
The ``Section`` can only be comprised of ``Paragraphs`` and must
only have 1 column.
*Options*
.. option:: balancedCols, BOOLEAN
Determines whether the text is spread out evenly across the
columns when the ``Paragraph`` has more than one
column. Default: ``true``.
.. option:: cols, INTEGER
The number of columns for the ``Paragraph``. Default: ``1``.
.. option:: heading, STRING
The heading for the ``Paragraph`` (like a section
heading). The string must be valid :math:`\text{\LaTeX}` code. Default:
``empty``.
.. option:: indent, BOOLEAN
Whether or not to indent the paragraph. Default: ``true``.
.. option:: text, STRING
The paragraph itself. The string must be valid :math:`\text{\LaTeX}`
code. Default: ``empty``.
.. reportingmethod:: addVspace
|br| Adds a ``Vspace`` (vertical space) to a ``Section``.
*Options*
.. option:: hline, INTEGER
The number of horizontal lines to be inserted. Default: ``0``.
.. option:: number, INTEGER
The number of new lines to be inserted. Default: ``1``.
.. reportingmethod:: write
|br| Writes the :math:`\text{\LaTeX}` representation of this
``Report``, saving it to the file specified by :opt:`filename
<fileName, FILENAME>`.
.. reportingmethod:: compile
|br| Compiles the report written by ``write`` into a ``pdf``
file. If the report has not already been written (determined by
the existence of the file specified by :opt:`filename <fileName,
FILENAME>`, ``write`` is called.
*Options*
.. option:: compiler, FILENAME
Like :opt:`compiler <compiler, FILENAME>`, except will not
overwrite the value of ``compiler`` contained in the report
object. Hence, passing the value here is useful for using
different :math:`\text{\LaTeX}` compilers or just for passing
the value at the last minute.
.. option:: showOutput, BOOLEAN
Print the compiler output to the screen. Useful for debugging
your code as the :math:`\text{\LaTeX}` compiler hangs if there is a
problem. Default: the value of :opt:`showOutput <showOutput,
BOOLEAN>`.
.. option:: showReport, BOOLEAN
Open the compiled report (works on Windows and macOS on
MATLAB). Default: ``true``.
*Example*
The following code creates a one page report. The first part of the
page contains two graphs displayed across two columns and one row. The
bottom of the page displays a centered table::
%% Create dseries
dsq = dseries(`quarterly.csv');
dsa = dseries(`annual.csv');
dsca = dseries(`annual_control.csv');
%% Report
rep = report();
%% Page 1
rep.addPage('title', {'My Page Title', 'My Page Subtitle'}, ...
'titleFormat', {'\large\bfseries', '\large'});
% Section 1
rep.addSection('cols', 2);
rep.addGraph('title', 'Graph Column 1', 'showLegend', true, ...
'xrange', dates('2007q1'):dates('2013q4'), ...
'shade', dates('2012q2'):dates('2013q4'));
rep.addSeries('data', dsq{'GROWTH_US'}, 'graphLineColor', 'blue', ...
'graphLineStyle', 'loosely dashed', 'graphLineWidth', 1);
rep.addSeries('data', dsq{'GROWTH_EU'}, 'graphLineColor', 'green', ...
'graphLineWidth', 1.5);
rep.addGraph('title', 'Graph Column 2', 'showLegend', true, ...
'xrange', dates('2007q1'):dates('2013q4'), ...
'shade', dates('2012q2'):dates('2013q4'));
rep.addSeries('data', dsq{'GROWTH_JA'}, 'graphLineColor', 'blue', ...
'graphLineWidth', 1);
rep.addSeries('data', dsq{'GROWTH_RC6'}, 'graphLineColor', 'green', ...
'graphLineStyle', 'dashdotdotted', 'graphLineWidth', 1.5);
% Section 2
rep.addVspace('number', 15);
rep.addSection();
rep.addTable('title', 'Table 1', 'range', dates('2012Y'):dates('2014Y'));
shortNames = {'US', 'EU'};
longNames = {'United States', 'Euro Area'};
for i=1:length(shortNames)
rep.addSeries('data', dsa{['GROWTH_' shortNames{i}]});
delta = dsa{['GROWTH_' shortNames{i}]}-dsca{['GROWTH_' shortNames{i}]};
delta.tex_rename_('$\Delta$');
rep.addSeries('data', delta, ...
'tableShowMarkers', true, 'tableAlignRight', true);
end
%% Write & Compile Report
rep.write();
rep.compile();
Once compiled, the report looks like:
.. image:: _static/report.png
.. default-domain:: dynare
##############
Running Dynare
##############
In order to give instructions to Dynare, the user has to write a
*model file* whose filename extension must be ``.mod`` or
``.dyn``. This file contains the description of the model and the
computing tasks required by the user. Its contents are described in
:ref:`model-file`.
.. _dyn-invoc:
Dynare invocation
=================
Once the model file is written, Dynare is invoked using the ``dynare``
command at the MATLAB or Octave prompt (with the filename of the
``.mod`` given as argument).
In practice, the handling of the model file is done in two steps: in
the first one, the model and the processing instructions written by
the user in a *model file* are interpreted and the proper MATLAB or
Octave instructions are generated; in the second step, the program
actually runs the computations. Both steps are triggered automatically
by the ``dynare`` command.
.. matcomm:: dynare FILENAME[.mod] [OPTIONS…]
This command launches Dynare and executes the instructions
included in ``FILENAME.mod``. This user-supplied file contains the
model and the processing instructions, as described in
:ref:`model-file`. The options, listed below, can be passed on the
command line, following the name of the ``.mod`` file or in the
first line of the ``.mod`` file itself (see below).
dynare begins by launching the preprocessor on the ``.mod
file``. By default (unless the :opt:`use_dll` option has been given to
``model``), the preprocessor creates three intermediary files:
- ``+FILENAME/driver.m``
Contains variable declarations, and computing tasks.
- ``+FILENAME/dynamic.m``
Contains the dynamic model equations. Note that Dynare might
introduce auxiliary equations and variables (see
:ref:`aux-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 derivatives are provided. When computing the
Jacobian of the dynamic model, the order of the endogenous
variables in the columns is stored in
``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 columns 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 ``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 ``c`` and the ``(3,2)`` entry of ``M_.lead_lag_incidence``
be 15. Then the 15th column of the Jacobian is the derivative
with respect to ``c(+1)``.
- ``+FILENAME/static.m``
Contains the long run static model equations. Note that Dynare
might introduce auxiliary equations and variables (see
:ref:`aux-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 ``(i,j)`` of the
Jacobian represents the derivative of the ith static model
equation with respect to the jth model variable in declaration
order.
These files may be looked at to understand errors reported at the
simulation stage.
``dynare`` will then run the computing tasks by executing
``+FILENAME/driver.m``. If a user needs to rerun the computing
tasks without calling the preprocessor (or without calling the
:mcomm:`dynare` command), for
instance because he has modified the script, he just have to type
the following on the command line:
.. code-block:: matlab
>> FILENAME.driver
A few words of warning are warranted here: under Octave the
filename of the ``.mod`` file should be chosen in such a way that
the generated ``.m`` files described above do not conflict with
``.m`` files provided by Octave or by Dynare. Not
respecting this rule could cause crashes or unexpected
behaviour. In particular, it means that the ``.mod`` file cannot
be given the name of an Octave or Dynare command. For instance, under
Octave, it also means that the ``.mod`` file cannot be named
``test.mod`` or ``example.mod``.
.. _quote-note:
.. note::
Note on Quotes
When passing command line options that contains a space (or, under
Octave, a double quote), you must surround the entire option (keyword
and argument) with single quotes, as in the following example.
*Example*
Call Dynare with options containing spaces
.. code-block:: matlab
>> dynare <<modfile.mod>> '-DA=[ i in [1,2,3] when i > 1 ]' 'conffile=C:\User\My Documents\config.txt'
*Options*
.. option:: noclearall
By default, ``dynare`` deletes all the global variables and the
functions using persistent variables, in order to benefit from the JIT
(just-in-time) compilation. This option instructs ``dynare`` not to
clear those.
.. option:: onlyclearglobals
By default, ``dynare`` deletes all the global variables and the
functions using persistent variables, in order to benefit from the JIT
(just-in-time) compilation. This option instructs ``dynare`` to clear
only its own global variables (*i.e.* ``M_, options_, oo_,
estim_params_, bayestopt_``, ``dataset_``, ``dataset_info`` and
``estimation_info``), leaving the other variables in the workspace, and
not clearing functions using persistent variables.
.. option:: debug
Instructs the preprocessor to write some debugging information
about the scanning and parsing of the ``.mod`` file.
.. option:: 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.
.. option:: savemacro[=FILENAME]
Instructs ``dynare`` to save the intermediary file which is obtained
after macro processing (see :ref:`macro-proc-lang`); the saved output
will go in the file specified, or if no file is specified in
``FILENAME_macroexp.mod``. See the :ref:`note on quotes<quote-note>`
for info on passing a ``FILENAME`` argument containing spaces.
.. option:: onlymacro
Instructs the preprocessor to only perform the
macro processing step, and stop just after. Useful for
debugging purposes or for using the macro processor
independently of the rest of Dynare toolbox.
.. option:: linemacro
Instructs the macro preprocessor include ``@#line`` directives
specifying the line on which macro directives were encountered and
expanded from. Only useful in conjunction with :opt:`savemacro
<savemacro[=FILENAME]>`.
.. option:: onlymodel
Instructs the preprocessor to print only information about the
model in the driver file; no Dynare commands (other than the
shocks statement and parameter initializations) are printed
and hence no computational tasks performed. The same
ancillary files are created as would otherwise be created
(dynamic, static files, etc.).
.. option:: nolog
Instructs Dynare to no create a logfile of this run in
``FILENAME.log.`` The default is to create the logfile.
.. option:: output=first|second|third
Instructs the preprocessor to output derivatives of the dynamic model at
least up to the given order. The `first` option is useful in
larger models when debugging steady state computation, because it allows
overriding the default computation and output of dynamic second order derivatives
in case of the mod-file not containing commands for further computations.
.. option:: language=matlab|julia
Instructs the preprocessor to write output for MATLAB or Julia. Default:
MATLAB
.. option:: params_derivs_order=0|1|2
When :comm:`identification`, :comm:`dynare_sensitivity` (with
identification), or :ref:`estimation <estim-comm>` are
present, this option is used to limit the order of the
derivatives with respect to the parameters that are calculated
by the preprocessor. 0 means no derivatives, 1 means first
derivatives, and 2 means second derivatives. Default: 2
.. option:: nowarn
Suppresses all warnings.
.. option:: notime
Do not print the total computing time at the end of the driver, and do
not save that total computing time to ``oo_.time``.
.. option:: transform_unary_ops
Transform the following operators in the model block into auxiliary
variables: ``exp``, ``log``, ``log10``, ``cos``, ``sin``, ``tan``,
``acos``, ``asin``, ``atan``, ``cosh``, ``sinh``, ``tanh``, ``acosh``,
``asinh``, ``atanh``, ``sqrt``, ``cbrt``, ``abs``, ``sign``,
``erf``. Default: no obligatory transformation
.. option:: json = parse|check|transform|compute
Causes the preprocessor to output a version of the ``.mod`` file in
JSON format to ``<<M_.fname>>/model/json/``.
When the JSON output is created depends on the value
passed. These values represent various steps of processing in the
preprocessor.
If ``parse`` is passed, the output will be written after the parsing of
the ``.mod`` file to a file called ``FILENAME.json`` but before file
has been checked (e.g. if there are unused exogenous in the model
block, the JSON output will be created before the preprocessor exits).
If ``check`` is passed, the output will be written to a file called
``FILENAME.json`` after the model has been checked.
If ``transform`` is passed, the JSON output of the transformed
model (maximum lead of 1, minimum lag of -1, expectation
operators substituted, etc.) will be written to a file called
``FILENAME.json`` and the original, untransformed model will
be written in ``FILENAME_original.json``.
And if ``compute`` is passed, the output is written after the
computing pass. In this case, the transformed model is written
to ``FILENAME.json``, the original model is written to
``FILENAME_original.json``, and the dynamic and static files
are written to ``FILENAME_dynamic.json`` and
``FILENAME_static.json``.
.. option:: jsonstdout
Instead of writing output requested by ``json`` to files,
write to standard out, i.e. to the MATLAB/Octave command window
(and the log-file).
.. option:: onlyjson
Quit processing once the output requested by ``json`` has been
written.
.. option:: jsonderivsimple
Print a simplified version (excluding variable name(s) and lag
information) of the static and dynamic files in
``FILENAME_static.json`` and ``FILENAME_dynamic.``.
.. option:: warn_uninit
Display a warning for each variable or parameter which is not
initialized. See :ref:`param-init`, or
:comm:`load_params_and_steady_state
<load_params_and_steady_state>` for initialization of
parameters. See :ref:`init-term-cond`, or
:comm:`load_params_and_steady_state
<load_params_and_steady_state>` for initialization of
endogenous and exogenous variables.
.. option:: console
Activate console mode. In addition to the behavior of
``nodisplay``, Dynare will not use graphical waitbars for long
computations.
.. option:: nograph
:noindex:
Activate the ``nograph`` option (see :opt:`nograph`), so that
Dynare will not produce any graph.
.. option:: nointeractive
Instructs Dynare to not request user input.
.. option:: nopathchange
By default Dynare will change MATLAB/Octave’s path if
``dynare/matlab`` directory is not on top and if Dynare’s
routines are overriden by routines provided in other
toolboxes. If one wishes to override Dynare’s routines, the
``nopathchange`` options can be used. Alternatively, the path
can be temporarly modified by the user at the top of the
``.mod`` file (using MATLAB/Octave’s ``addpath`` command).
.. option:: nopreprocessoroutput
Prevent Dynare from printing the output of the steps leading up to the
preprocessor as well as the preprocessor output itself.
.. option:: mexext=mex|mexw64|mexmaci64|mexmaca64|mexa64
The mex extension associated with your platform to be used
when compiling output associated with :opt:`use_dll`.
Dynare is able to set this automatically, so you should not
need to set it yourself.
.. option:: matlabroot=<<path>>
The path to the MATLAB installation for use with :opt:`use_dll`. Dynare
is able to set this automatically, so you should not need to set it
yourself. See the :ref:`note on quotes<quote-note>` for info on
passing a ``<<path>>`` argument containing spaces.
.. option:: parallel[=CLUSTER_NAME]
Tells Dynare to perform computations in parallel. If
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. See
:ref:`conf-file`, for more information about the configuration
file.
.. option:: conffile=FILENAME
Specifies the location of the configuration file if it differs from the
default. See :ref:`conf-file`, for more information about the
configuration file and its default location. See the :ref:`note on
quotes<quote-note>` for info on passing a ``FILENAME`` argument
containing spaces.
.. option:: parallel_follower_open_mode
Instructs Dynare to leave the connection to the follower node
open after computation is complete, closing this connection
only when Dynare finishes processing.
.. option:: parallel_test
Tests the parallel setup specified in the configuration file
without executing the ``.mod`` file. See :ref:`conf-file`, for
more information about the configuration file.
.. option:: parallel_use_psexec=true|false
For local execution under Windows operating system,
set ``parallel_use_psexec=false`` to use ``start``
instead of ``psexec``, to properly allocate affinity when there are
more than 32 cores in the local machine. This option is also helpful if
``psexec`` cannot be executed due to missing admininstrator privileges. [default=true]
.. option:: -DMACRO_VARIABLE[=MACRO_EXPRESSION]
Defines a macro-variable from the command line (the same effect as
using the Macro directive ``@#define`` in a model file, see
:ref:`macro-proc-lang`). See the :ref:`note on quotes<quote-note>` for
info on passing a ``MACRO_EXPRESSION`` argument containing spaces. Note
that an expression passed on the command line can reference variables
defined before it. If ``MACRO_EXPRESSION`` is omitted, the variable is
assigned the ``true`` logical value. Strings assigned to a macro variable
need to be enclosed in double quoted strings. This also allows for passing
single quotes within the strings.
*Example*
Call dynare with command line defines
.. code-block:: matlab
>> dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DD=[ i in C when i > 1 ]' -DE -Ddatafile_name="'my_data_file.mat'"
.. option:: -I<<path>>
Defines a path to search for files to be included by the macro
processor (using the ``@#include`` command). Multiple ``-I`` flags can
be passed on the command line. The paths will be searched in the order
that the ``-I`` flags are passed and the first matching file will be
used. The flags passed here take priority over those passed to
``@#includepath``. See the :ref:`note on quotes<quote-note>` for info
on passing a ``<<path>>`` argument containing spaces.
.. option:: nostrict
Allows Dynare to issue a warning and continue processing when
1. there are more endogenous variables than equations.
2. an undeclared symbol is assigned in ``initval`` or ``endval``.
3. an undeclared symbol is found in the ``model`` block in
this case, it is automatically declared exogenous.
4. exogenous variables were declared but not used in the
``model`` block.
.. option:: fast
Don’t rewrite the output files otherwise written to the disk by the preprocessor
when re-running the same model file while the lists of variables and the equations
haven’t changed. Note that the whole model still needs to be preprocessed. This option
is most useful with model option :opt:`use_dll`, because
the time-consuming compilation of the MEX files will be skipped. We use a 32
bit checksum, stored in ``<model filename>/checksum``. There
is a very small probability that the preprocessor misses a
change in the model. In case of doubt, re-run without the fast
option.
.. option:: minimal_workspace
Instructs Dynare not to write parameter assignments to
parameter names in the .m file produced by the
preprocessor. This is potentially useful when running
``dynare`` on a large ``.mod`` file that runs into workspace
size limitations imposed by MATLAB.
.. option:: compute_xrefs
Tells Dynare to compute the equation cross references, writing
them to the output ``.m`` file.
.. option:: stochastic
Tells Dynare that the model to be solved is stochastic. If no
Dynare commands related to stochastic models (``stoch_simul``,
``estimation``, ...) are present in the ``.mod`` file, Dynare
understands by default that the model to be solved is
deterministic.
.. _exclude_eqs:
.. option:: exclude_eqs=<<equation_tags_to_exclude>>
Tells Dynare to exclude all equations specified by the argument. As a
``.mod`` file must have the same number of endogenous variables as
equations, when `exclude_eqs` is passed, certain rules are followed for
excluding endogenous variables. If the ``endogenous`` tag has been set
for the excluded equation, the variable it specifies is
excluded. Otherwise, if the left hand side of the excluded equation is
an expression that contains only one endogenous variable, that variable
is excluded. If neither of these conditions hold, processing stops with
an error. If an endogenous variable has been excluded by the
`exclude_eqs` option and it exists in an equation that has not been
excluded, it is transformed into an exogenous variable.
To specify which equations to exclude, you must pass the argument
``<<equation_tags_to_exclude>>``. This argument takes either a list of
equation tags specifying the equations to be excluded or a filename that
contains those tags.
If ``<<equation_tags_to_exclude>>`` is a list of equation tags, it can
take one of the following forms:
#. Given a single argument, e.g. ``exclude_eqs=eq1``, the equation with
the tag ``[name='eq1']`` will be excluded. Note that if there is a
file called ``eq1`` in the current directory, Dynare will instead
try to open this and read equations to exclude from it (see info on
filename argument to ``exclude_eqs`` below). Further note that if the
tag value contains a space, you must use the variant specified in 2
below, i.e. ``exclude_eqs=[eq 1]``.
#. Given two or more arguments, e.g. ``exclude_eqs=[eq1, eq 2]``, the
equations with the tags ``[name='eq1']`` and ``[name='eq 2']`` will
be excluded.
#. If you'd like to exclude equations based on another tag name (as
opposed to the default ``name``), you can pass the argument as either
e.g. ``exclude_eqs=[tagname=a tag]`` if a single equation with tag
``[tagname='a tag']`` is to be excluded or as
e.g. ``exclude_eqs=[tagname=(a tag, 'a tag with a, comma')]`` if more
than one equation with tags ``[tagname='a tag']`` and ``[tagname='a
tag with a, comma']`` will be excluded (note the parenthesis, which
are required when more than one equation is specified). Note that if
the value of a tag contains a comma, it must be included inside
single quotes.
If ``<<equation_tags_to_exclude>>`` is a filename, the file can take one
of the following forms:
#. One equation per line of the file, where every line represents the
value passed to the ``name`` tag. e.g., a file such as::
eq1
eq 2
would exclude equations with tags ``[name='eq1']`` and ``[name='eq
2']``.
#. One equation per line of the file, where every line after the first
line represents the value passed to the tag specified by the first
line. e.g., a file such as::
tagname=
a tag
a tag with a, comma
would exclude equations with tags ``[tagname='a tag']`` and
``[tagname='a tag with a, comma']``. Here note that the first line
must end in an equal sign.
.. option:: include_eqs=<<equation_tags_to_include>>
Tells Dynare to run with only those equations specified by the
argument; in other words, Dynare will exclude all equations not
specified by the argument. The argument ``<<equation_tags_to_include>>``
is specified in the same way as the argument to :ref:`exclude_eqs
<exclude_eqs>`. The functionality of ``include_eqs`` is to find which
equations to exclude then take actions in accord with :ref:`exclude_eqs
<exclude_eqs>`.
.. option:: use_dll
:noindex:
Instructs the preprocessor to create dynamic loadable libraries (DLL)
containing the model equations and derivatives, instead of writing
those in M-files. This is equivalent to the :opt:`use_dll` option of
the ``model`` block.
.. option:: nocommutativity
This option tells the preprocessor not to use the commutativity of
addition and multiplication when looking for common subexpressions. As a
consequence, when using this option, equations in various outputs
(LaTeX, JSON…) will appear as the user entered them (without terms or
factors swapped). Note that using this option may have a performance
impact on the preprocessing stage, though it is likely to be small.
These options can be passed to the preprocessor by listing them
after the name of the ``.mod`` file. They can alternatively be
defined in the first line of the ``.mod`` file, this avoids typing
them on the command line each time a ``.mod`` file is to be
run. This line must be a Dynare one-line comment (i.e. must begin with ``//``)
and the options must be whitespace separated between ``--+ options:``
and ``+--``. Note that any text after the ``+--`` will be
discarded. As in the command line, if an option admits a value the
equal symbol must not be surrounded by spaces. For instance ``json
= compute`` is not correct, and should be written
``json=compute``. The ``nopathchange`` option cannot be specified in
this way, it must be passed on the command-line.
*Output*
Depending on the computing tasks requested in the ``.mod`` file,
executing the ``dynare`` command will leave variables containing
results in the workspace available for further processing. More
details are given under the relevant computing tasks. The
``M_``, ``oo_``, and ``options_`` structures are saved in a file
called ``FILENAME_results.mat`` located in the ``MODFILENAME/Output`` folder.
If they exist, ``estim_params_``,
``bayestopt_``, ``dataset_``, ``oo_recursive_`` and
``estimation_info`` are saved in the same file. Note that MATLAB
by default only allows ``.mat`` files up to 2GB. You can lift this
restriction by enabling the ``save -v7.3`` option in
``Preferences -> General -> MAT-Files``.
.. matvar:: M_
Structure containing various information about the model.
.. matvar:: options_
Structure contains the values of the various options used by
Dynare during the computation.
.. matvar:: oo_
Structure containing the various results of the computations.
.. matvar:: dataset_
A ``dseries`` object containing the data used for estimation.
.. matvar:: oo_recursive_
Cell array containing the ``oo_`` structures obtained when
estimating the model for the different samples when performing
recursive estimation and forecasting. The ``oo_`` structure
obtained for the sample ranging to the `i` -th observation is
saved in the `i` -th field. The fields for non-estimated
endpoints are empty.
.. matvar:: oo_.time
Total computing time of the Dynare run, in seconds. This field is not
set if the :opt:`notime` option has been used.
*Example*
Call dynare from the MATLAB or Octave prompt, without or with options:
.. code-block:: matlab
>> dynare ramst
>> dynare ramst.mod savemacro
Alternatively the options can be passed in the first line of
``ramst.mod``:
.. code-block:: dynare
// --+ options: savemacro, json=compute +--
and then dynare called without passing options on the command line:
.. code-block:: matlab
>> dynare ramst
Dynare hooks
============
It is possible to call pre and post Dynare preprocessor hooks written
as MATLAB scripts. The script ``MODFILENAME/hooks/priorprocessing.m``
is executed before the call to Dynare’s preprocessor, and can be used
to programmatically transform the mod file that will be read by the
preprocessor. The script ``MODFILENAME/hooks/postprocessing.m`` is
gexecuted just after the call to Dynare’s preprocessor, and can be used
to programmatically transform the files generated by Dynare’s
preprocessor before actual computations start. The pre and/or post
dynare preprocessor hooks are executed if and only if the
aforementioned scripts are detected in the same folder as the the
model file, ``FILENAME.mod``.
Understanding Preprocessor Error Messages
=========================================
If the preprocessor runs into an error while processing your ``.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:
#. ``ERROR: <<file.mod>>: line A, col B: <<error message>>``
#. ``ERROR: <<file.mod>>: line A, cols B-C: <<error message>>``
#. ``ERROR: <<file.mod>>: line A, col B - line C, col D: <<error message>>``
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::
varexo a, b
parameters c, ...;
In this case, the parser doesn’t know a semicolon is missing at the
end of the ``varexo`` command until it begins parsing the second line
and bumps into the ``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, ``parameters``, which it did not
expect. Hence, it throws an error of the form: ``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.
It is also helpful to keep in mind that any piece of code that does not violate
Dynare syntax, but at the same time is not recognized by the parser, is interpreted
as native MATLAB code. This code will be directly passed to the driver script.
Investigating the ``driver.m`` file then helps with debugging. Such problems most often
occur when defined variable or parameter names have been misspelled so that Dynare's
parser is unable to recognize them.
.. default-domain:: dynare
.. |br| raw:: html
<br>
.. _conf-file:
######################
The configuration file
######################
The configuration file is used to provide Dynare with information not
related to the model (and hence not placed in the model file). At the
moment, it is only used when using Dynare to run parallel
computations.
On Linux and macOS, the configuration file is searched by default under
``dynare/dynare.ini`` in the configuration directories defined by the XDG
specification (typically ``$HOME/.config/dynare/dynare.ini`` for the
user-specific configuration and ``/etc/xdg/dynare/dynare.ini`` for the
system-wide configuration, the former having precedence over the latter). Under
Windows, the configuration file is searched by default in
``%APPDATA%\dynare\dynare.ini`` (typically
``c:\Users\USERNAME\AppData\Roaming\dynare\dynare.ini``). You can specify a non
standard location using the ``conffile`` option of the ``dynare`` command (see
:ref:`dyn-invoc`).
The parsing of the configuration file is case-sensitive and it should
take the following form, with each option/choice pair placed on a
newline::
[command0]
option0 = choice0
option1 = choice1
[command1]
option0 = choice0
option1 = choice1
The configuration file follows a few conventions (self-explanatory
conventions such as ``USER_NAME`` have been excluded for concision):
``COMPUTER_NAME``
Indicates the valid name of a server (e.g. ``localhost``,
``server.cepremap.org``) or an IP address.
``DRIVE_NAME``
Indicates a valid drive name in Windows, without the trailing
colon (e.g. ``C``).
``PATH``
Indicates a valid path in the underlying operating system
(e.g. ``/home/user/dynare/matlab/``).
``PATH_AND_FILE``
Indicates a valid path to a file in the underlying operating
system (e.g. ``/usr/local/MATLAB/R2023b/bin/matlab``).
``BOOLEAN``
Is ``true`` or ``false``.
Dynare Configuration
====================
This section explains how to configure Dynare for general
processing. Currently, there is only one option available.
.. confblock:: [hooks]
|br| This block can be used to specify configuration options that will
be used when running Dynare.
*Options*
.. option:: GlobalInitFile = PATH_AND_FILE
The location of a global initialization file that can be used to
customize some Dynare internals (typically default option values). This
is a MATLAB/Octave script.
If this option is not specified, Dynare will look for a
``global_init.m`` file in its configuration directory (typically
``$HOME/.config/dynare/global_init.m`` under Linux and macOS, and
``c:\Users\USERNAME\AppData\Roaming\dynare\global_init.m`` under
Windows).
*Example*
::
[hooks]
GlobalInitFile = /home/usern/dynare/myInitFile.m
.. confblock:: [paths]
|br| This block can be used to specify paths that will be used
when running dynare.
*Options*
.. option:: Include = PATH
A colon-separated path to use when searching for files to
include via ``@#include``. Paths specified via :opt:`-I
<-I\<\<path\>\>>` take priority over paths specified here,
while these paths take priority over those specified by
``@#includepath``.
*Example*
::
[paths]
Include = /path/to/folder/containing/modfiles:/path/to/another/folder
.. _paral-conf:
Parallel Configuration
======================
This section explains how to configure Dynare for parallelizing some
tasks which require very little inter-process communication.
The parallelization is done by running several MATLAB or Octave
processes, either on local or on remote machines. Communication
between leader and follower processes are done through SMB on Windows and
SSH on UNIX. Input and output data, and also some short status
messages, are exchanged through network filesystems. Currently the
system works only with homogenous grids: only Windows or only Unix
machines.
The following routines are currently parallelized:
* the posterior sampling algorithms when using multiple chains;
* the Metropolis-Hastings diagnostics;
* the posterior IRFs;
* the prior and posterior statistics;
* some plotting routines.
Note that creating the configuration file is not enough in order to
trigger parallelization of the computations: you also need to specify
the ``parallel`` option to the ``dynare`` command. For more details,
and for other options related to the parallelization engine, see
:ref:`dyn-invoc`.
You also need to verify that the following requirements are met by
your cluster (which is composed of a leader and of one or more
followers):
For a Windows grid:
* a standard Windows network (SMB) must be in place;
* the `PsTools`_ suite must be installed in the path of the
leader Windows machine;
* the Windows user on the leader machine has to be user of any
other follower machine in the cluster, and that user will be
used for the remote computations.
* detailed step-by-step setup instructions can be found in
:ref:`win-ssg`.
For a UNIX grid:
* SSH must be installed on the leader and on the follower machines;
* SSH keys must be installed so that the SSH connection from
the leader to the follower can be done without passwords, or
using an SSH agent.
.. warning:: Compatibility considerations between leader and follower
It is highly recommended to use the same version of Dynare on both the
leader and all followers. Different versions regularly cause problems like
zero acceptance rates during estimation. When upgrading to a newer Dynare
version do not forget to adjust the ``DynarePath``.
We now turn to the description of the configuration directives. Note
that comments in the configuration file can be provided by separate
lines starting with a hashtag (#).
.. confblock:: [cluster]
|br| When working in parallel, ``[cluster]`` is required to specify the
group of computers that will be used. It is required even if you
are only invoking multiple processes on one computer.
*Options*
.. option:: Name = CLUSTER_NAME
The reference name of this cluster.
.. option:: Members = NODE_NAME[(WEIGHT)] NODE_NAME[(WEIGHT)] ...
A list of nodes that comprise the cluster with an optional
computing weight specified for that node. The computing weight
indicates how much more powerful one node is with respect to
the others (e.g. ``n1(2) n2(1) n3(3)`` means that ``n1`` is
two times more powerful than ``n2`` whereas ``n3`` is three
times more powerful than ``n2``). Each node is separated by at
least one space and the weights are in parenthesis with no
spaces separating them from their node.
*Example*
::
[cluster]
Name = c1
Members = n1 n2 n3
[cluster]
Name = c2
Members = n1(4) n2 n3
.. confblock:: [node]
|br| When working in parallel, ``[node]`` is required for every
computer that will be used. The options that are required differ,
depending on the underlying operating system and whether you are
working locally or remotely.
*Options*
.. option:: Name = NODE_NAME
The reference name of this node.
.. option:: CPUnbr = INTEGER | [INTEGER:INTEGER]
If just one integer is passed, the number of processors to
use. If a range of integers is passed, the specific processors
to use (processor counting is defined to begin at one as
opposed to zero). Note that using specific processors is only
possible under Windows; under Linux and macOS, if a range is
passed the same number of processors will be used but the
range will be adjusted to begin at one.
.. option:: ComputerName = COMPUTER_NAME
The name or IP address of the node. If you want to run
locally, use ``localhost`` (case-sensitive).
.. option:: Port = INTEGER
The port number to connect to on the node. The default is
empty, meaning that the connection will be made to the default
SSH port (22).
.. option:: UserName = USER_NAME
The username used to log into a remote system. Required for
remote runs on all platforms.
.. option:: Password = PASSWORD
The password used to log into the remote system. Required for
remote runs originating from Windows.
.. option:: RemoteDrive = DRIVE_NAME
The drive to be used for remote computation. Required for
remote runs originating from Windows.
.. option:: RemoteDirectory = PATH
The directory to be used for remote computation. Required for
remote runs on all platforms.
.. option:: DynarePath = PATH
The path to the matlab subdirectory within the Dynare
installation directory. The default is the empty string.
.. option:: MatlabOctavePath = PATH_AND_FILE
The path to the MATLAB or Octave executable. The default value
is ``matlab`` as MATLAB’s executable is typically in the %PATH% environment
variable. When using full paths on Windows, you may need to enclose the path
in quoted strings, e.g. ``MatlabOctavePath="C:\Program Files\MATLAB\R2023b\bin\matlab.exe"``
.. option:: NumberOfThreadsPerJob = INTEGER
This option controls the distribution of jobs (e.g. MCMC chains) across additional MATLAB instances that are run in parallel.
Needs to be an exact divisor of the number of cores.
The formula :opt:`CPUnbr <CPUnbr = INTEGER | [INTEGER:INTEGER]>` divided by :opt:`NumberOfThreadsPerJob <NumberOfThreadsPerJob = INTEGER>`
calculates the number of MATLAB/Octave instances that will be launched in parallel,
where each instance will then execute a certain number of jobs sequentially.
For example, if you run a MCMC estimation with 24 chains on a 12 core machine, setting ``CPUnbr = 12`` and ``NumberOfThreadsPerJob = 4``
will launch 3 MATLAB instances in parallel, each of which will compute 8 chains sequentially.
Note that this option does not dictate the number of maximum threads utilized by each MATLAB/Octave instance,
see related option :opt:`SingleCompThread <SingleCompThread = BOOLEAN>` for this.
Particularly for very large models, setting this option to 2 might distribute the workload in a
more efficient manner, depending on your hardware and task specifics.
It’s advisable to experiment with different values to achieve optimal performance.
The default value is ``1``.
.. option:: SingleCompThread = BOOLEAN
This option allows you to enable or disable MATLAB’s native multithreading capability. When set to ``true``,
the additional MATLAB instances are initiated in single thread mode utilizing the ``-singleCompThread`` startup option,
thereby disabling MATLAB’s native multithreading. When set to ``false``, MATLAB’s native multithreading
is enabled, e.g. the actual number of threads utilized by each MATLAB instance is usually determined by the number of CPU cores
(you can check this by running ``maxNumCompThreads`` in MATLAB’s command window).
Note: While MATLAB aims to accelerate calculations by distributing them across your computer’s threads,
certain tasks, like MCMC estimations, may exhibit slowdowns with MATLAB’s multitasking especially when Dynare’s parallel computing is turned on
as we do not use MATLAB’s parallel toolbox.
So in many cases it is advisable to set this setting to ``true``.
If you want to have more control, you can manually add the MATLAB command `maxNumCompThreads(N)` at the beginning of `fParallel.m`.
The default value is ``false``. This option is ineffective under Octave.
.. option:: OperatingSystem = OPERATING_SYSTEM
The operating system associated with a node. Only necessary
when creating a cluster with nodes from different operating
systems. Possible values are ``unix`` or ``windows``. There is
no default value.
*Example*
::
[node]
Name = n1
ComputerName = localhost
CPUnbr = 1
[node]
Name = n2
ComputerName = dynserv.cepremap.org
CPUnbr = 5
UserName = usern
RemoteDirectory = /home/usern/Remote
DynarePath = /home/usern/dynare/matlab
MatlabOctavePath = matlab
[node]
Name = n3
ComputerName = dynserv.dynare.org
Port = 3333
CPUnbr = [2:4]
UserName = usern
RemoteDirectory = /home/usern/Remote
DynarePath = /home/usern/dynare/matlab
MatlabOctavePath = matlab
.. _win-ssg:
Windows Step-by-Step Guide
==========================
This section outlines the steps necessary on most Windows systems to
set up Dynare for parallel execution. Note that the steps 3 to 6 are
required unless parallel execution is confined to a local pool
with the ``parallel_use_psexec=false`` option.
1. Write a configuration file containing the options you want. A
mimimum working example setting up a cluster consisting of two
local CPU cores that allows for e.g. running two Monte Carlo
Markov Chains in parallel is shown below.
2. Save the configuration file somwhere. The name and file ending
do not matter if you are providing it with the ``conffile``
command line option. The only restrictions are that the path
must be a valid filename, not contain non-alpha-numeric
characters, and not contain any whitespaces. For the
configuration file to be accessible without providing an
explicit path at the command line, you must save it under the
name ``dynare.ini`` into your user account’s ``Application
Data`` folder.
3. Install `PSTools`_ to your system, e.g. into ``C:\PSTools.``
4. Set the Windows System Path to the ``PSTools`` folder
(e.g. using something along the line of pressing Windows
Key+Pause to open the System Configuration, then go to Advanced
-> Environment Variables -> Path).
5. Restart your computer to make the path change effective.
6. Open MATLAB and type into the command window::
!psexec
This executes the ``psexec.exe`` from PSTools on your system
and shows whether Dynare will be able to locate it. If MATLAB
complains at this stage, you did not correctly set your Windows
system path for the ``PSTools`` folder.
7. If ``psexec.exe`` was located in the previous step, a popup
will show up, asking for confirmation of the license
agreement. Confirm this copyright notice of ``psexec`` (this
needs to be done only once). After this, Dynare should be ready
for parallel execution.
8. Call Dynare on your mod-file invoking the ``parallel`` option
and providing the path to your configuration file with the
``conffile`` option (if you did not save it as
``%APPDATA%\dynare.ini`` in step 2 where it should be detected
automatically)::
dynare ls2003 parallel conffile='C:\Users\Dynare~1\parallel\conf_file.ini'
Please keep in mind that no white spaces or names longer than 8
characters are allowed in the ``conffile`` path. The 8-character
restriction can be circumvented by using the tilde Windows path
notation as in the above example.
*Example*::
#cluster needs to always be defined first
[cluster]
#Provide a name for the cluster
Name=Local
#declare the nodes being member of the cluster
Members=n1
#declare nodes (they need not all be part of a cluster)
[node]
#name of the node
Name=n1
#name of the computer (localhost for the current machine)
ComputerName=localhost
#cores to be included from this node
CPUnbr=[1:2]
#path to matlab.exe; on Windows, the MATLAB bin folder is in the system path
#so we only need to provide the name of the exe file
MatlabOctavePath=matlab
#Dynare path you are using
DynarePath=C:/dynare/4.7.0/matlab
.. _PsTools: https://technet.microsoft.com/sysinternals/pstools.aspx
Source diff could not be displayed: it is too large. Options to address this: view the blob.
.. default-domain:: dynare
.. |br| raw:: html
<br>
###########
Time Series
###########
Dynare provides a MATLAB/Octave class for handling time series data,
which is based on a class for handling dates. Dynare also provides a
new type for dates, so that the user does not have to worry about
class and methods for dates. Below, you will first find the class and
methods used for creating and dealing with dates and then the class
used for using time series. Dynare also provides an interface to the
X-13 ARIMA-SEATS seasonal adjustment program produced, distributed, and
maintained by the U.S. Census Bureau (2020).
Dates
=====
.. highlight:: matlab
.. _dates in a mod file:
Dates in a mod file
-------------------
Dynare understands dates in a mod file. Users can declare annual, bi-annual,
quarterly, or monthly dates using the following syntax::
1990Y
1990A
1990S2
1990H2
1990Q4
1990M11
Note that there are two syntaxes for annual dates (`1990A` is equivalent to
`1990Y`), and for bi-annual dates (`1990H2` is equivalent to `1990S2`).
Behind the scene, Dynare’s preprocessor translates these expressions
into instantiations of the MATLAB/Octave’s class ``dates`` described
below. Basic operations can be performed on dates:
**plus binary operator (+)**
An integer scalar, interpreted as a number of periods, can be
added to a date. For instance, if ``a = 1950Q1`` then ``b =
1951Q2`` and ``b = a + 5`` are identical.
**plus unary operator (+)**
Increments a date by one period. ``+1950Q1`` is identical to
``1950Q2``, ``++++1950Q1`` is identical to ``1951Q1``.
**minus binary operator (-)**
Has two functions: difference and subtraction. If the second
argument is a date, calculates the difference between the first
date and the second date (e.g. ``1951Q2-1950Q1`` is equal to
``5``). If the second argument is an integer ``X``, subtracts
``X`` periods from the date (e.g. ``1951Q2-2`` is equal to
``1950Q4``).
**minus unary operator (-)**
Subtracts one period to a date. ``-1950Q1`` is identical to
``1949Q4``. The unary minus operator is the reciprocal of the
unary plus operator, ``+-1950Q1`` is identical to ``1950Q1``.
**colon operator (:)**
Can be used to create a range of dates. For instance, ``r =
1950Q1:1951Q1`` creates a ``dates`` object with five elements:
``1950Q1``, ``1950Q2``, ``1950Q3``, ``1950Q4`` and ``1951Q1``. By default the
increment between each element is one period. This default can be
changed using, for instance, the following instruction:
``1950Q1:2:1951Q1`` which will instantiate a ``dates`` object with
three elements: ``1950Q1``, ``1950Q3`` and ``1951Q1``.
**horzcat operator ([,])**
Concatenates dates objects without removing repetitions. For
instance ``[1950Q1, 1950Q2]`` is a ``dates`` object with two
elements (``1950Q1`` and ``1950Q2``).
**vertcat operator ([;])**
Same as ``horzcat`` operator.
**eq operator (equal, ==)**
Tests if two ``dates`` objects are equal. ``+1950Q1==1950Q2``
returns ``true``, ``1950Q1==1950Q2`` returns ``false``. If the compared
objects have both ``n>1`` elements, the ``eq`` operator returns a
column vector, ``n`` by ``1``, of logicals.
**ne operator (not equal, ~=)**
Tests if two ``dates`` objects are not equal. ``+1950Q1~=``
returns ``false`` while ``1950Q1~=1950Q2`` returns ``true``. If the
compared objects both have ``n>1`` elements, the ``ne`` operator
returns an ``n`` by ``1`` column vector of logicals.
**lt operator (less than, <)**
Tests if a ``dates`` object preceeds another ``dates`` object. For
instance, ``1950Q1<1950Q3`` returns ``true``. If the compared objects
have both ``n>1`` elements, the ``lt`` operator returns a column
vector, ``n`` by ``1``, of logicals.
**gt operator (greater than, >)**
Tests if a ``dates`` object follows another ``dates`` object. For
instance, ``1950Q1>1950Q3`` returns ``false``. If the compared objects
have both ``n>1`` elements, the ``gt`` operator returns a column
vector, ``n`` by ``1``, of logicals.
**le operator (less or equal, <=)**
Tests if a ``dates`` object preceeds another ``dates`` object or
is equal to this object. For instance, ``1950Q1<=1950Q3`` returns
``true``. If the compared objects have both ``n>1`` elements, the
``le`` operator returns a column vector, ``n`` by ``1``, of logicals.
**ge operator (greater or equal, >=)**
Tests if a ``dates`` object follows another ``dates`` object or is
equal to this object. For instance, ``1950Q1>=1950Q3`` returns
``false``. If the compared objects have both ``n>1`` elements, the
``ge`` operator returns a column vector, ``n`` by ``1``, of logicals.
One can select an element, or some elements, in a ``dates`` object as
he would extract some elements from a vector in MATLAB/Octave. Let ``a
= 1950Q1:1951Q1`` be a ``dates`` object, then ``a(1)==1950Q1`` returns
``true``, ``a(end)==1951Q1`` returns ``true`` and ``a(end-1:end)`` selects
the two last elements of ``a`` (by instantiating the ``dates`` object
``[1950Q4, 1951Q1]``).
Remark: Dynare substitutes any occurrence of dates in the ``.mod`` file
into an instantiation of the ``dates`` class regardless of the
context. For instance, ``d = 1950Q1`` will be translated as ``d =
dates('1950Q1');``. This automatic substitution can lead to a crash if
a date is defined in a string. Typically, if the user wants to display
a date::
disp('Initial period is 1950Q1');
Dynare will translate this as::
disp('Initial period is dates('1950Q1')');
which will lead to a crash because this expression is illegal in
MATLAB. For this situation, Dynare provides the ``$`` escape
parameter. The following expression::
disp('Initial period is $1950Q1');
will be translated as::
disp('Initial period is 1950Q1');
in the generated MATLAB script.
.. _dates-members:
The dates class
---------------
.. class:: dates
:arg freq: equal to 1, 2, 4, 12 or 365 (resp. for annual, bi-annual, quarterly,
monthly, or daily dates).
:arg time: a ``n*1`` array of integers, the number of periods since year 0 ().
Each member is private, one can display the content of a member
but cannot change its value directly. Note also that it is not
possible to mix frequencies in a ``dates`` object: all the
elements must have common frequency.
The ``dates`` class has the following constructors:
.. construct:: dates()
dates(FREQ)
|br| Returns an empty ``dates`` object with a given frequency
(if the constructor is called with one input
argument). ``FREQ`` is a character equal to ’Y’ or ’A’ for
annual dates, ’S’ or ’H’ for bi-annual dates, ’Q’ for
quarterly dates, ’M’ for monthly dates, or ’D’ for daily
dates. Note that ``FREQ`` is not case sensitive, so that, for
instance, ’q’ is also allowed for quarterly dates. The
frequency can also be set with an integer scalar equal to 1
(annual), 2 (bi-annual), 4 (quarterly), 12 (monthly), or 365
(daily). The instantiation of empty objects can be used to
rename the ``dates`` class. For instance, if one only works
with quarterly dates, object ``qq`` can be created as::
qq = dates('Q')
and a ``dates`` object holding the date ``2009Q2``::
d0 = qq(2009,2);
which is much simpler if ``dates`` objects have to be defined
programmatically. For daily dates, we would instantiate an
empty daily dates object as::
dd = dates('D')
and a ``dates`` object holding the date ``2020-12-31``::
d1 = dd(2020,12,31);
.. construct:: dates(STRING)
dates(STRING, STRING, ...)
|br| Returns a ``dates`` object that represents a date as
given by the string ``STRING``. This string has to be
interpretable as a date (only strings of the following forms
are admitted: ``'1990Y'``, ``'1990A'``, ``1990S1``,
``1990H1``, ``'1990Q1'``, ``'1990M2'``, or ``'2020-12-31'``),
the routine ``isdate`` can be used to test if a string is
interpretable as a date. If more than one argument is
provided, they should all be dates represented as strings, the
resulting ``dates`` object contains as many elements as
arguments to the constructor. For the daily dates, the string
must be of the form yyyy-mm-dd with two digits for the
months (mm) and days (dd), even if the number of days or
months is smaller than ten (in this case a leading 0 is
required).
.. construct:: dates(DATES)
dates(DATES, DATES, ...)
|br| Returns a copy of the ``dates`` object ``DATES`` passed
as input arguments. If more than one argument is provided,
they should all be ``dates`` objects. The number of elements
in the instantiated ``dates`` object is equal to the sum of
the elements in the ``dates`` passed as arguments to the
constructor.
.. construct:: dates (FREQ, YEAR, SUBPERIOD[, S])
|br| where ``FREQ`` is a single character (’Y’, ’A’, ’S’, ’H’,
’Q’, ’M’, ’D’) or integer (1, 2, 4, 12, or 365) specifying the
frequency, ``YEAR`` and ``SUBPERIOD`` and ``S`` are ``n*1``
vectors of integers. Returns a ``dates`` object with ``n``
elements. The last argument, ``S``, is only to be used for
daily frequency. If ``FREQ`` is equal to ``'Y'``, ``'A'`` or
``1``, the third argument is not needed (because ``SUBPERIOD``
is necessarily a vector of ones in this case).
*Example*
::
do1 = dates('1950Q1');
do2 = dates('1950Q2','1950Q3');
do3 = dates(do1,do2);
do4 = dates('Q',1950, 1);
do5 = dates('D',1973, 1, 25);
|br|
A ``dates`` object with multiple elements can be considered a one-dimensional array of dates. Standard array operations can be applied to a ``dates`` object:
- square brackets can be used to concatenate dates objects::
>> A = dates('1938Q4');
>> B = dates('1945Q3');
>> C = [A, B];
- semicolons can be used to create ranges of dates::
>> A = dates('2009Q2');
>> B = A:A+2;
>> B
B = <dates: 2009Q2, 2009Q3, 2009Q4>
- objects can be indexed by an integer or a vector of integer::
>> B(1)
ans = <dates: 2009Q2>
>> B(end)
ans = <dates: 2009Q4>
>> B(1:2)
ans = <dates: 2009Q2, 2009Q3>
|br|
A list of the available methods, by alphabetical order, is given
below. Note that by default the methods do not allow in place
modifications: when a method is applied to an object a new object
is instantiated. For instance, to apply the method
``multiplybytwo`` to an object ``X`` we write::
>> X = 2;
>> Y = X.multiplybytwo();
>> X
2
>> Y
4
or equivalently::
>> Y = multiplybytwo(X);
the object ``X`` is left unchanged, and the object ``Y`` is a
modified copy of ``X`` (multiplied by two). This behaviour is
altered if the name of the method is postfixed with an
underscore. In this case the creation of a copy is avoided. For
instance, following the previous example, we would have::
>> X = 2;
>> X.multiplybytwo_();
>> X
4
Modifying the objects in place, with underscore methods, is
particularly useful if the methods are called in loops, since this
saves the object instantiation overhead.
|br|
.. datesmethod:: C = append (A, B)
append_ (B)
|br| Appends ``dates`` object ``B``, or a string that can be
interpreted as a date, to the ``dates`` object ``A``. If ``B``
is a ``dates`` object it is assumed that it has no more than
one element.
*Example*
::
>> D = dates('1950Q1','1950Q2');
>> d = dates('1950Q3');
>> E = D.append(d);
>> F = D.append('1950Q3');
>> isequal(E,F)
ans =
1
>> F
F = <dates: 1950Q1, 1950Q2, 1950Q3>
>> D
D = <dates: 1950Q1, 1950Q2>
>> D.append_('1950Q3')
ans = <dates: 1950Q1, 1950Q2, 1950Q3>
.. datesmethod:: B = char (A)
|br| Overloads the MATLAB/Octave ``char`` function. Converts a
``dates`` object into a character array.
*Example*
::
>> A = dates('1950Q1');
> A.char()
ans =
'1950Q1'
.. datesmethod:: C = colon (A, B)
C = colon (A, i, B)
|br| Overloads the MATLAB/Octave colon (``:``) operator. A and
B are ``dates`` objects. The optional increment ``i`` is a
scalar integer (default value is ``i=1``). This method returns
a ``dates`` object and can be used to create ranges of dates.
*Example*
::
>> A = dates('1950Q1');
>> B = dates('1951Q2');
>> C = A:B
C = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1>
>> D = A:2:B
D = <dates: 1950Q1, 1950Q3, 1951Q1>
.. datesmethod:: B = copy (A)
|br| Returns a copy of a ``dates`` object.
.. datesmethod:: disp (A)
|br| Overloads the MATLAB/Octave disp function for ``dates`` object.
.. datesmethod:: display (A)
|br| Overloads the MATLAB/Octave display function for ``dates`` object.
*Example*
::
>> disp(B)
B = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1, 1951Q2, 1951Q3, 1951Q4, 1952Q1, 1952Q2, 1952Q3>
>> display(B)
B = <dates: 1950Q1, 1950Q2, ..., 1952Q2, 1952Q3>
.. datesmethod:: B = double (A)
|br| Overloads the MATLAB/Octave ``double`` function. ``A`` is
a ``dates`` object. The method returns a floating point
representation of a ``dates`` object, the integer and
fractional parts respectively corresponding to the year and
the subperiod. The fractional part is the subperiod number
minus one divided by the frequency (``1``, ``4``, or ``12``).
*Example*:
::
>> a = dates('1950Q1'):dates('1950Q4');
>> a.double()
ans =
1950.00
1950.25
1950.50
1950.75
.. datesmethod:: C = eq (A, B)
|br| Overloads the MATLAB/Octave ``eq`` (equal, ``==``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``). The returned argument is a
``n`` by ``1`` vector of logicals. The i-th element of
``C`` is equal to ``true`` if and only if the dates ``A(i)`` and
``B(i)`` are the same.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A==B
ans =
2x1 logical array
1
0
.. datesmethod:: C = ge (A, B)
|br| Overloads the MATLAB/Octave ``ge`` (greater or equal,
``>=``) operator. ``dates`` objects ``A`` and ``B`` must have
the same number of elements (say, ``n``). The returned
argument is a ``n`` by ``1`` vector of logicals. The
i-th element of ``C`` is equal to ``true`` if and only if the
date ``A(i)`` is posterior or equal to the date ``B(i)``.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A>=B
ans =
2x1 logical array
1
1
.. datesmethod:: C = gt (A, B)
|br| Overloads the MATLAB/Octave ``gt`` (greater than, ``>``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``). The returned argument is a
``n`` by ``1`` vector of logicals. The i-th element of
``C`` is equal to ``1`` if and only if the date ``A(i)`` is
posterior to the date ``B(i)``.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A>B
ans =
2x1 logical array
0
1
.. datesmethod:: D = horzcat (A, B, C, ...)
|br| Overloads the MATLAB/Octave ``horzcat`` operator. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object gathering all the dates given
in the input arguments (repetitions are not removed).
*Example*
::
>> A = dates('1950Q1');
>> B = dates('1950Q2');
>> C = [A, B];
>> C
C = <dates: 1950Q1, 1950Q2>
.. datesmethod:: C = intersect (A, B)
|br| Overloads the MATLAB/Octave ``intersect`` function. All
the input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object gathering all the common dates
given in the input arguments. If ``A`` and ``B`` are disjoint
``dates`` objects, the function returns an empty ``dates``
object. Returned dates in ``dates`` object ``C`` are sorted by
increasing order.
*Example*
::
>> A = dates('1950Q1'):dates('1951Q4');
>> B = dates('1951Q1'):dates('1951Q4');
>> C = intersect(A, B);
>> C
C = <dates: 1951Q1, 1951Q2, 1951Q3, 1951Q4>
.. datesmethod:: B = isempty (A)
|br| Overloads the MATLAB/Octave ``isempty`` function.
*Example*
::
>> A = dates('1950Q1');
>> A.isempty()
ans =
logical
0
>> B = dates();
>> B.isempty()
ans =
logical
1
.. datesmethod:: C = isequal (A, B)
|br| Overloads the MATLAB/Octave ``isequal`` function.
*Example*
::
>> A = dates('1950Q1');
>> B = dates('1950Q2');
>> isequal(A, B)
ans =
logical
0
.. datesmethod:: C = le (A, B)
|br| Overloads the MATLAB/Octave ``le`` (less or equal,
``<=``) operator. ``dates`` objects ``A`` and ``B`` must have
the same number of elements (say, ``n``). The returned
argument is a ``n`` by ``1`` vector of logicals. The
i-th element of ``C`` is equal to ``true`` if and only if the
date ``A(i)`` is anterior or equal to the date ``B(i)``.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A<=B
ans =
2x1 logical array
1
0
.. datesmethod:: B = length (A)
|br| Overloads the MATLAB/Octave ``length`` function. Returns
the number of elements in a ``dates`` object.
*Example*
::
>> A = dates('1950Q1'):dates(2000Q3);
>> A.length()
ans =
203
.. datesmethod:: C = lt (A, B)
|br| Overloads the MATLAB/Octave ``lt`` (less than,
``<``) operator. ``dates`` objects ``A`` and ``B`` must have
the same number of elements (say, ``n``). The returned
argument is a ``n`` by ``1`` vector of logicals. The
i-th element of ``C`` is equal to ``true`` if and only if the
date ``A(i)`` is anterior or equal to the date ``B(i)``.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A<B
ans =
2x1 logical array
0
0
.. datesmethod:: D = max (A, B, C, ...)
|br| Overloads the MATLAB/Octave ``max`` function. All input
arguments must be ``dates`` objects. The function returns a
single element ``dates`` object containing the greatest date.
*Example*
::
>> A = {dates('1950Q2'), dates('1953Q4','1876Q2'), dates('1794Q3')};
>> max(A{:})
ans = <dates: 1953Q4>
.. datesmethod:: D = min (A, B, C, ...)
|br| Overloads the MATLAB/Octave ``min`` function. All input
arguments must be ``dates`` objects. The function returns a
single element ``dates`` object containing the smallest date.
*Example*
::
>> A = {dates('1950Q2'), dates('1953Q4','1876Q2'), dates('1794Q3')};
>> min(A{:})
ans = <dates: 1794Q3>
.. datesmethod:: C = minus (A, B)
|br| Overloads the MATLAB/Octave ``minus`` operator
(``-``). If both input arguments are ``dates`` objects, then
number of periods between ``A`` and ``B`` is returned (so that
``A+C=B``). If ``B`` is a vector of integers, the minus
operator shifts the ``dates`` object by ``B`` periods
backward.
*Example*
::
>> d1 = dates('1950Q1','1950Q2','1960Q1');
>> d2 = dates('1950Q3','1950Q4','1960Q1');
>> ee = d2-d1
ee =
2
2
0
>> d1-(-ee)
ans = <dates: 1950Q3, 1950Q4, 1960Q1>
.. datesmethod:: C = mtimes (A, B)
|br| Overloads the MATLAB/Octave ``mtimes`` operator
(``*``). ``A`` and ``B`` are respectively expected to be a
``dates`` object and a scalar integer. Returns ``dates``
object ``A`` replicated ``B`` times.
*Example*
::
>> d = dates('1950Q1');
>> d*2
ans = <dates: 1950Q1, 1950Q1>
.. datesmethod:: C = ne (A, B)
|br| Overloads the MATLAB/Octave ``ne`` (not equal, ``~=``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``) or one of the inputs must be a
single element ``dates`` object. The returned argument is a
``n`` by ``1`` vector of logicals. The i-th element of
``C`` is equal to ``true`` if and only if the dates ``A(i)`` and
``B(i)`` are different.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A~=B
ans =
2x1 logical array
0
1
.. datesmethod:: C = plus (A, B)
|br| Overloads the MATLAB/Octave ``plus`` operator (``+``). If
both input arguments are ``dates`` objects, then the method
combines ``A`` and ``B`` without removing repetitions. If
``B`` is a vector of integers, the ``plus`` operator shifts
the ``dates`` object by ``B`` periods forward.
*Example*
::
>> d1 = dates('1950Q1','1950Q2')+dates('1960Q1');
>> d2 = (dates('1950Q1','1950Q2')+2)+dates('1960Q1');
>> ee = d2-d1;
ee =
2
2
0
>> d1+ee
ans = <dates: 1950Q3, 1950Q4, 1960Q1>
.. datesmethod:: C = pop (A)
C = pop (A, B)
pop_ ()
pop_ (B)
|br| Pop method for ``dates`` class. If only one input is
provided, the method removes the last element of a ``dates``
object. If a second input argument is provided, a scalar
integer between ``1`` and ``A.length()``, the method removes
element number ``B`` from ``dates`` object ``A``.
*Example*
::
>> d = dates('1950Q1','1950Q2');
>> d.pop()
ans = <dates: 1950Q1>
>> d.pop_(1)
ans = <dates: 1950Q2>
.. datesmethod:: C = remove (A, B)
remove_ (B)
|br| Remove method for ``dates`` class. Both inputs have to be ``dates`` objects, removes dates in ``B`` from ``A``.
*Example*
::
>> d = dates('1950Q1','1950Q2');
>> d.remove(dates('1950Q2'))
ans = <dates: 1950Q1>
.. datesmethod:: C = setdiff (A, B)
|br| Overloads the MATLAB/Octave ``setdiff`` function. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object all dates present in ``A`` but
not in ``B``. If ``A`` and ``B`` are disjoint ``dates``
objects, the function returns ``A``. Returned dates in
``dates`` object ``C`` are sorted by increasing order.
*Example*
::
>> A = dates('1950Q1'):dates('1969Q4');
>> B = dates('1960Q1'):dates('1969Q4');
>> C = dates('1970Q1'):dates('1979Q4');
>> setdiff(A, B)
ans = <dates: 1950Q1, 1950Q2, ..., 1959Q3, 1959Q4>
>> setdiff(A, C)
ans = <dates: 1950Q1, 1950Q2, ..., 1969Q3, 1969Q4>
.. datesmethod:: B = sort (A)
sort_ ()
|br| Sort method for ``dates`` objects. Returns a ``dates`` object
with elements sorted by increasing order.
*Example*
::
>> dd = dates('1945Q3','1938Q4','1789Q3');
>> dd.sort()
ans = <dates: 1789Q3, 1938Q4, 1945Q3>
.. datesmethod:: B = strings (A)
|br| Converts a ``dates`` object into a cell of char arrays.
*Example*
::
>> A = dates('1950Q1');
>> A = A:A+1;
>> A.strings()
ans =
1x2 cell array
{'1950Q1'} {'1950Q2'}
.. datesmethod:: B = subperiod (A)
|br| Returns the subperiod of a date (an integer scalar
between 1 and ``A.freq``). This method is not implemented for
daily dates.
*Example*
::
>> A = dates('1950Q2');
>> A.subperiod()
ans =
2
.. datesmethod:: B = uminus (A)
|br| Overloads the MATLAB/Octave unary minus operator. Returns
a ``dates`` object with elements shifted one period backward.
*Example*
::
>> dd = dates('1945Q3','1938Q4','1973Q1');
>> -dd
ans = <dates: 1945Q2, 1938Q3, 1972Q4>
.. datesmethod:: D = union (A, B, C, ...)
|br| Overloads the MATLAB/Octave ``union`` function. Returns a
``dates`` object with elements sorted by increasing order
(repetitions are removed, to keep the repetitions use the
``horzcat`` or ``plus`` operators).
*Example*
::
>> d1 = dates('1945Q3','1973Q1','1938Q4');
>> d2 = dates('1973Q1','1976Q1');
>> union(d1,d2)
ans = <dates: 1938Q4, 1945Q3, 1973Q1, 1976Q1>
.. datesmethod:: B = unique (A)
unique_ ()
|br| Overloads the MATLAB/Octave ``unique`` function. Returns
a ``dates`` object with repetitions removed (only the last
occurence of a date is kept).
*Example*
::
>> d1 = dates('1945Q3','1973Q1','1945Q3');
>> d1.unique()
ans = <dates: 1973Q1, 1945Q3>
.. datesmethod:: B = uplus (A)
|br| Overloads the MATLAB/Octave unary plus operator. Returns
a ``dates`` object with elements shifted one period ahead.
*Example*
::
>> dd = dates('1945Q3','1938Q4','1973Q1');
>> +dd
ans = <dates: 1945Q4, 1939Q1, 1973Q2>
.. datesmethod:: D = vertcat (A, B, C, ...)
|br| Overloads the MATLAB/Octave ``horzcat`` operator. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object gathering all the dates given
in the input arguments (repetitions are not removed).
.. datesmethod:: B = year (A)
|br| Returns the year of a date (an integer scalar
between 1 and ``A.freq``).
*Example*
::
>> A = dates('1950Q2');
>> A.subperiod()
ans =
1950
.. _dseries-members:
The dseries class
=================
.. class:: dseries
|br| The MATLAB/Octave ``dseries`` class handles time series
data. As any MATLAB/Octave statements, this class can be used in a
Dynare’s mod file. A ``dseries`` object has six members:
:arg name: A ``vobs*1`` cell of strings or a ``vobs*p`` character array, the names of the variables.
:arg tex: A ``vobs*1`` cell of strings or a ``vobs*p`` character array, the tex names of the variables.
:arg dates dates: An object with ``nobs`` elements, the dates of the sample.
:arg double data: A ``nobs`` by ``vobs`` array, the data.
:arg ops: The history of operations on the variables.
:arg tags: The user-defined tags on the variables.
``data``, ``name``, ``tex``, and ``ops`` are private members. The following
constructors are available:
.. construct:: dseries ()
dseries (INITIAL_DATE)
|br| Instantiates an empty ``dseries`` object with, if
defined, an initial date given by the single element ``dates``
object *INITIAL_DATE.*
.. construct:: dseries (FILENAME[, INITIAL_DATE])
|br| Instantiates and populates a ``dseries`` object with a
data file specified by *FILENAME*, a string passed as
input. Valid file types are ``.m``, ``.mat``, ``.csv`` and
``.xls/.xlsx`` (Octave only supports ``.xlsx`` files and the
`io <https://octave.sourceforge.io/io/>`__ package from
Octave-Forge must be installed). The extension of the file
should be explicitly provided.
A typical ``.m`` file will have the following form::
FREQ__ = 4;
INIT__ = '1994Q3';
NAMES__ = {'azert';'yuiop'};
TEX__ = {'azert';'yuiop'};
azert = randn(100,1);
yuiop = randn(100,1);
If a ``.mat`` file is used instead, it should provide the same
informations, except that the data should not be given as a
set of vectors, but as a single matrix of doubles named
``DATA__``. This array should have as many columns as elements
in ``NAMES__`` (the number of variables). Note that the
``INIT__`` variable can be either a ``dates`` object or a
string which could be used to instantiate the same ``dates``
object. If ``INIT__`` is not provided in the ``.mat`` or
``.m`` file, the initial is by default set equal to
``dates('1Y')``. If a second input argument is passed to the
constructor, ``dates`` object *INITIAL_DATE*, the initial date
defined in *FILENAME* is reset to *INITIAL_DATE*. This is
typically usefull if ``INIT__`` is not provided in the data
file.
If an ``.xlsx`` file is used, the first row should be a header
containing the variable names. The first column may contain date
information that must correspond to a valid date format recognized
by Dynare. If such date information is specified in the first column,
its header name must be left empty.
.. construct:: dseries (DATA_MATRIX[,INITIAL_DATE[,LIST_OF_NAMES[,TEX_NAMES]]])
dseries (DATA_MATRIX[,RANGE_OF_DATES[,LIST_OF_NAMES[,TEX_NAMES]]])
|br| If the data is not read from a file, it can be provided
via a :math:`T \times N` matrix as the first argument to
``dseries`` ’ constructor, with :math:`T` representing the
number of observations on :math:`N` variables. The optional
second argument, *INITIAL_DATE*, can be either a ``dates``
object representing the period of the first observation or a
string which would be used to instantiate a ``dates``
object. Its default value is ``dates('1Y')``. The optional
third argument, *LIST_OF_NAMES*, is a :math:`N \times 1` cell
of strings with one entry for each variable name. The default
name associated with column ``i`` of *DATA_MATRIX* is
``Variable_i``. The final argument, *TEX_NAMES*, is a :math:`N
\times 1` cell of strings composed of the LaTeX names
associated with the variables. The default LaTeX name
associated with column ``i`` of *DATA_MATRIX* is
``Variable\_i``. If the optional second input argument is a
range of dates, ``dates`` object *RANGE_OF_DATES*, the number
of rows in the first argument must match the number of
elements *RANGE_OF_DATES* or be equal to one (in which case
the single observation is replicated).
.. construct:: dseries (TABLE)
Creates a ``dseries`` object given the MATLAB Table provided as the sole
argument. It is assumed that the first column of the table contains the
dates of the ``dseries`` and the first row contains the names. This
feature is not available under Octave or MATLAB R2013a or earlier.
*Example*
Various ways to create a ``dseries`` object::
do1 = dseries(1999Q3);
do2 = dseries('filename.csv');
do3 = dseries([1; 2; 3], 1999Q3, {'var123'}, {'var_{123}'});
>> do1 = dseries(dates('1999Q3'));
>> do2 = dseries('filename.csv');
>> do3 = dseries([1; 2; 3], dates('1999Q3'), {'var123'}, {'var_{123}'});
One can easily create subsamples from a ``dseries`` object using
the overloaded parenthesis operator. If ``ds`` is a ``dseries``
object with :math:`T` observations and ``d`` is a ``dates`` object
with :math:`S<T` elements, such that :math:`\min(d)` is not
smaller than the date associated to the first observation in
``ds`` and :math:`\max(d)` is not greater than the date associated
to the last observation, then ``ds(d)`` instantiates a new
``dseries`` object containing the subsample defined by ``d``.
A list of the available methods, by alphabetical order, is given
below. As in the previous section the in place modifications
versions of the methods are postfixed with an underscore.
.. dseriesmethod:: A = abs (B)
abs_ ()
|br| Overloads the ``abs()`` function for ``dseries``
objects. Returns the absolute value of the variables in
dseries ``object`` ``B``.
*Example*
::
>> ts0 = dseries(randn(3,2),'1973Q1',{'A1'; 'A2'},{'A_1'; 'A_2'});
>> ts1 = ts0.abs();
>> ts0
ts0 is a dseries object:
| A1 | A2
1973Q1 | -0.67284 | 1.4367
1973Q2 | -0.51222 | -0.4948
1973Q3 | 0.99791 | 0.22677
>> ts1
ts1 is a dseries object:
| abs(A1) | abs(A2)
1973Q1 | 0.67284 | 1.4367
1973Q2 | 0.51222 | 0.4948
1973Q3 | 0.99791 | 0.22677
*Example (in-place modification version)*
::
>> ts0 = dseries(randn(3,2),'1973Q1',{'A1'; 'A2'},{'A_1'; 'A_2'});
>> ts0
ts0 is a dseries object:
| A1 | A2
1973Q1 | -0.67284 | 1.4367
1973Q2 | -0.51222 | -0.4948
1973Q3 | 0.99791 | 0.22677
>> ts0.abs_();
>> ts0
ts0 is a dseries object:
| abs(A1) | abs(A2)
1973Q1 | 0.67284 | 1.4367
1973Q2 | 0.51222 | 0.4948
1973Q3 | 0.99791 | 0.22677
.. dseriesmethod:: [A, B] = align (A, B)
align_ (B)
If ``dseries`` objects ``A`` and ``B`` are defined on
different time ranges, this function extends ``A`` and/or
``B`` with NaNs so that they are defined on the same time
range. Note that both ``dseries`` objects must have the same
frequency.
*Example*
::
>> ts0 = dseries(rand(5,1),dates('2000Q1')); % 2000Q1 -> 2001Q1
>> ts1 = dseries(rand(3,1),dates('2000Q4')); % 2000Q4 -> 2001Q2
>> [ts0, ts1] = align(ts0, ts1); % 2000Q1 -> 2001Q2
>> ts0
ts0 is a dseries object:
| Variable_1
2000Q1 | 0.81472
2000Q2 | 0.90579
2000Q3 | 0.12699
2000Q4 | 0.91338
2001Q1 | 0.63236
2001Q2 | NaN
>> ts1
ts1 is a dseries object:
| Variable_1
2000Q1 | NaN
2000Q2 | NaN
2000Q3 | NaN
2000Q4 | 0.66653
2001Q1 | 0.17813
2001Q2 | 0.12801
>> ts0 = dseries(rand(5,1),dates('2000Q1')); % 2000Q1 -> 2001Q1
>> ts1 = dseries(rand(3,1),dates('2000Q4')); % 2000Q4 -> 2001Q2
>> align_(ts0, ts1); % 2000Q1 -> 2001Q2
>> ts1
ts1 is a dseries object:
| Variable_1
2000Q1 | NaN
2000Q2 | NaN
2000Q3 | NaN
2000Q4 | 0.66653
2001Q1 | 0.17813
2001Q2 | 0.12801
*Example (in-place modification version)*
::
>> ts0 = dseries(rand(5,1),dates('2000Q1')); % 2000Q1 -> 2001Q1
>> ts1 = dseries(rand(3,1),dates('2000Q4')); % 2000Q4 -> 2001Q2
>> ts0
ts0 is a dseries object:
| Variable_1
2000Q1 | 0.80028
2000Q2 | 0.14189
2000Q3 | 0.42176
2000Q4 | 0.91574
2001Q1 | 0.79221
>> ts1
ts1 is a dseries object:
| Variable_1
2000Q4 | 0.95949
2001Q1 | 0.65574
2001Q2 | 0.035712
>> align_(ts0, ts1); % 2000Q1 -> 2001Q2
>> ts0
ts0 is a dseries object:
| Variable_1
2000Q1 | 0.80028
2000Q2 | 0.14189
2000Q3 | 0.42176
2000Q4 | 0.91574
2001Q1 | 0.79221
2001Q2 | NaN
>> ts1
ts1 is a dseries object:
| Variable_1
2000Q1 | NaN
2000Q2 | NaN
2000Q3 | NaN
2000Q4 | 0.95949
2001Q1 | 0.65574
2001Q2 | 0.035712
.. dseriesmethod:: C = backcast (A, B[, diff])
backcast_ (B[, diff])
Backcasts ``dseries`` object ``A`` with ``dseries`` object B's
growth rates (except if the last optional argument, ``diff``,
is true in which case first differences are used). Both
``dseries`` objects must have the same frequency.
.. dseriesmethod:: B = baxter_king_filter (A[, hf[, lf[, K]]])
baxter_king_filter_ ([hf[, lf[, K]]])
|br| Implementation of the *Baxter and King* (1999) band pass
filter for ``dseries`` objects. This filter isolates business
cycle fluctuations with a period of length ranging between
``hf`` (high frequency) to ``lf`` (low frequency) using a
symmetric moving average smoother with :math:`2K+1` points, so
that :math:`K` observations at the beginning and at the end of
the sample are lost in the computation of the filter. The
default value for ``hf`` is ``6``, for ``lf`` is ``32``, and
for ``K`` is ``12``.
*Example*
::
% Simulate a component model (stochastic trend, deterministic
% trend, and a stationary autoregressive process).
e = 0.2*randn(200,1);
u = randn(200,1);
stochastic_trend = cumsum(e);
deterministic_trend = .1*transpose(1:200);
x = zeros(200,1);
for i=2:200
x(i) = .75*x(i-1) + u(i);
end
y = x + stochastic_trend + deterministic_trend;
% Instantiates time series objects.
ts0 = dseries(y,'1950Q1');
ts1 = dseries(x,'1950Q1'); % stationary component.
% Apply the Baxter-King filter.
ts2 = ts0.baxter_king_filter();
% Plot the filtered time series.
plot(ts1(ts2.dates).data,'-k'); % Plot of the stationary component.
hold on
plot(ts2.data,'--r'); % Plot of the filtered y.
hold off
axis tight
id = get(gca,'XTick');
set(gca,'XTickLabel',strings(ts1.dates(id)));
.. dseriesmethod:: B = center (A[, geometric])
center_ ([geometric])
|br| Centers variables in ``dseries`` object ``A`` around their
arithmetic means, except if the optional argument ``geometric``
is set equal to ``true`` in which case all the variables are
divided by their geometric means.
.. dseriesmethod:: C = chain (A, B)
chain_ (B)
|br| Merge two ``dseries`` objects along the time
dimension. The two objects must have the same number of
observed variables, and the initial date in ``B`` must not be
posterior to the last date in ``A``. The returned ``dseries``
object, ``C``, is built by extending ``A`` with the cumulated
growth factors of ``B``.
*Example*
::
>> ts = dseries([1; 2; 3; 4],dates('1950Q1'))
ts is a dseries object:
| Variable_1
1950Q1 | 1
1950Q2 | 2
1950Q3 | 3
1950Q4 | 4
>> us = dseries([3; 4; 5; 6],dates('1950Q3'))
us is a dseries object:
| Variable_1
1950Q3 | 3
1950Q4 | 4
1951Q1 | 5
1951Q2 | 6
>> chain(ts, us)
ans is a dseries object:
| Variable_1
1950Q1 | 1
1950Q2 | 2
1950Q3 | 3
1950Q4 | 4
1951Q1 | 5
1951Q2 | 6
*Example (in-place modification version)*
::
>> ts = dseries([1; 2; 3; 4],dates('1950Q1'))
>> us = dseries([3; 4; 5; 6],dates('1950Q3'))
>> ts.chain_(us);
>> ts
ts is a dseries object:
| Variable_1
1950Q1 | 1
1950Q2 | 2
1950Q3 | 3
1950Q4 | 4
1951Q1 | 5
1951Q2 | 6
.. dseriesmethod:: [error_flag, message ] = check (A)
|br| Sanity check of ``dseries`` object ``A``. Returns ``1``
if there is an error, ``0`` otherwise. The second output
argument is a string giving brief informations about the
error.
.. dseriesmethod:: B = copy (A)
|br| Returns a copy of ``A``. If an inplace modification method
is applied to ``A``, object ``B`` will not be affected. Note
that if ``A`` is assigned to ``C``, ``C = A``, then any in
place modification method applied to ``A`` will change ``C``.
*Example*
::
>> a = dseries(randn(5,1))
a is a dseries object:
| Variable_1
1Y | -0.16936
2Y | -1.1451
3Y | -0.034331
4Y | -0.089042
5Y | -0.66997
>> b = copy(a);
>> c = a;
>> a.abs();
>> a.abs_();
>> a
a is a dseries object:
| Variable_1
1Y | 0.16936
2Y | 1.1451
3Y | 0.034331
4Y | 0.089042
5Y | 0.66997
>> b
b is a dseries object:
| Variable_1
1Y | -0.16936
2Y | -1.1451
3Y | -0.034331
4Y | -0.089042
5Y | -0.66997
>> c
c is a dseries object:
| Variable_1
1Y | 0.16936
2Y | 1.1451
3Y | 0.034331
4Y | 0.089042
5Y | 0.66997
.. dseriesmethod:: B = cumprod (A[, d[, v]])
cumprod_ ([d[, v]])
|br| Overloads the MATLAB/Octave ``cumprod`` function for
``dseries`` objects. The cumulated product cannot be computed
if the variables in ``dseries`` object ``A`` have NaNs. If a
``dates`` object ``d`` is provided as a second argument, then
the method computes the cumulated product with the additional
constraint that the variables in the ``dseries`` object ``B``
are equal to one in period ``d``. If a single-observation
``dseries`` object ``v`` is provided as a third argument, the
cumulated product in ``B`` is normalized such that ``B(d)``
matches ``v`` (``dseries`` objects ``A`` and ``v`` must have
the same number of variables).
*Example*
::
>> ts1 = dseries(2*ones(7,1));
>> ts2 = ts1.cumprod();
>> ts2
ts2 is a dseries object:
| cumprod(Variable_1)
1Y | 2
2Y | 4
3Y | 8
4Y | 16
5Y | 32
6Y | 64
7Y | 128
>> ts3 = ts1.cumprod(dates('3Y'));
>> ts3
ts3 is a dseries object:
| cumprod(Variable_1)
1Y | 0.25
2Y | 0.5
3Y | 1
4Y | 2
5Y | 4
6Y | 8
7Y | 16
>> ts4 = ts1.cumprod(dates('3Y'),dseries(pi));
>> ts4
ts4 is a dseries object:
| cumprod(Variable_1)
1Y | 0.7854
2Y | 1.5708
3Y | 3.1416
4Y | 6.2832
5Y | 12.5664
6Y | 25.1327
7Y | 50.2655
.. dseriesmethod:: B = cumsum (A[, d[, v]])
cumsum_ ([d[, v]])
|br| Overloads the MATLAB/Octave ``cumsum`` function for
``dseries`` objects. The cumulated sum cannot be computed if
the variables in ``dseries`` object ``A`` have NaNs. If a
``dates`` object ``d`` is provided as a second argument, then
the method computes the cumulated sum with the additional
constraint that the variables in the ``dseries`` object ``B``
are zero in period ``d``. If a single observation ``dseries``
object ``v`` is provided as a third argument, the cumulated
sum in ``B`` is such that ``B(d)`` matches ``v`` (``dseries``
objects ``A`` and ``v`` must have the same number of
variables).
*Example*
::
>> ts1 = dseries(ones(10,1));
>> ts2 = ts1.cumsum();
>> ts2
ts2 is a dseries object:
| cumsum(Variable_1)
1Y | 1
2Y | 2
3Y | 3
4Y | 4
5Y | 5
6Y | 6
7Y | 7
8Y | 8
9Y | 9
10Y | 10
>> ts3 = ts1.cumsum(dates('3Y'));
>> ts3
ts3 is a dseries object:
| cumsum(Variable_1)
1Y | -2
2Y | -1
3Y | 0
4Y | 1
5Y | 2
6Y | 3
7Y | 4
8Y | 5
9Y | 6
10Y | 7
>> ts4 = ts1.cumsum(dates('3Y'),dseries(pi));
>> ts4
ts4 is a dseries object:
| cumsum(Variable_1)
1Y | 1.1416
2Y | 2.1416
3Y | 3.1416
4Y | 4.1416
5Y | 5.1416
6Y | 6.1416
7Y | 7.1416
8Y | 8.1416
9Y | 9.1416
10Y | 10.1416
.. dseriesmethod:: B = detrend (A[, m])
detrend_ ([m])
|br| Detrends ``dseries`` object ``A`` with a fitted
polynomial of order ``m``. Default value fir ``m`` is 0 (time
series are detrended by removing the average). Note that each
variable is detrended with a different polynomial.
.. dseriesmethod:: B = dgrowth (A)
dgrowth_ ()
|br| Computes daily growth rates.
.. dseriesmethod:: B = diff (A)
diff_ ()
|br| Returns the first difference of ``dseries`` object ``A``.
.. datesmethod:: disp (A)
|br| Overloads the MATLAB/Octave disp function for ``dseries`` object.
.. datesmethod:: display (A)
|br| Overloads the MATLAB/Octave display function for
``dseries`` object. ``display`` is the function called by
MATLAB to print the content of an object if a semicolon is
missing at the end of a MATLAB statement. If the ``dseries``
object is defined over a too large time span, only the first
and last periods will be printed. If the ``dseries`` object
contains too many variables, only the first and last variables
will be printed. If all the periods and variables are
required, the ``disp`` method should be used instead.
.. dseriesmethod:: C = eq (A, B)
|br| Overloads the MATLAB/Octave ``eq`` (equal, ``==``)
operator. ``dseries`` objects ``A`` and ``B`` must have the
same number of observations (say, :math:`T`) and variables
(:math:`N`). The returned argument is a :math:`T \times N`
matrix of logicals. Element :math:`(i,j)` of ``C`` is
equal to ``true`` if and only if observation :math:`i` for
variable :math:`j` in ``A`` and ``B`` are the same.
*Example*
::
>> ts0 = dseries(2*ones(3,1));
>> ts1 = dseries([2; 0; 2]);
>> ts0==ts1
ans =
3x1 logical array
1
0
1
.. dseriesmethod:: l = exist (A, varname)
|br| Tests if variable ``varname`` exists in ``dseries`` object ``A``. Returns
``true`` iff variable exists in ``A``.
*Example*
::
>> ts = dseries(randn(100,1));
>> ts.exist('Variable_1')
ans =
logical
1
>> ts.exist('Variable_2')
ans =
logical
0
.. dseriesmethod:: B = exp (A)
exp_ (A)
|br| Overloads the MATLAB/Octave ``exp`` function for
``dseries`` objects.
*Example*
::
>> ts0 = dseries(rand(10,1));
>> ts1 = ts0.exp();
*Exemple (in-place modification version)*
::
>> ts0 = dseries(rand(3,1))
ts0 is a dseries object:
| Variable_1
1Y | 0.82953
2Y | 0.84909
3Y | 0.37253
>> ts0.exp_();
>> ts0
ts0 is a dseries object:
| Variable_1
1Y | 2.2922
2Y | 2.3375
3Y | 1.4514
.. dseriesmethod:: C = extract (A, B[, ...])
|br| Extracts some variables from a ``dseries`` object ``A``
and returns a ``dseries`` object ``C``. The input arguments
following ``A`` are strings representing the variables to be
selected in the new ``dseries`` object ``C``. To simplify the
creation of sub-objects, the ``dseries`` class overloads the
curly braces (``D = extract (A, B, C)`` is equivalent to ``D =
A{B,C}``) and allows implicit loops (defined between a pair of
``@`` symbol, see examples below) or MATLAB/Octave’s regular
expressions (introduced by square brackets).
*Example*
The following selections are equivalent::
>> ts0 = dseries(ones(100,10));
>> ts1 = ts0{'Variable_1','Variable_2','Variable_3'};
>> ts2 = ts0{'Variable_@1,2,3@'};
>> ts3 = ts0{'Variable_[1-3]$'};
>> isequal(ts1,ts2) && isequal(ts1,ts3)
ans =
logical
1
It is possible to use up to two implicit loops to select variables::
names = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'; 'GDP_6'; 'GDP_7'; 'GDP_8'; ...
'GDP_9'; 'GDP_10'; 'GDP_11'; 'GDP_12'; ...
'HICP_1';'HICP_2';'HICP_3'; 'HICP_4'; 'HICP_5'; 'HICP_6'; 'HICP_7'; 'HICP_8'; ...
'HICP_9'; 'HICP_10'; 'HICP_11'; 'HICP_12'};
ts0 = dseries(randn(4,24),dates('1973Q1'),names);
ts0{'@GDP,HICP@_@1,3,5@'}
ans is a dseries object:
| GDP_1 | GDP_3 | GDP_5 | HICP_1 | HICP_3 | HICP_5
1973Q1 | 1.7906 | -1.6606 | -0.57716 | 0.60963 | -0.52335 | 0.26172
1973Q2 | 2.1624 | 3.0125 | 0.52563 | 0.70912 | -1.7158 | 1.7792
1973Q3 | -0.81928 | 1.5008 | 1.152 | 0.2798 | 0.88568 | 1.8927
1973Q4 | -0.03705 | -0.35899 | 0.85838 | -1.4675 | -2.1666 | -0.62032
.. dseriesmethod:: fill_(name, v)
|br| Assign the value ``v`` to the variable ``name`` in a
dseries object. If ``name`` is a character row array, it should
correspond to an existing variable within the dseries
object. When ``v`` is a scalar, its value will be applied to
all periods uniformly. If ``v`` is a vector, its length must
match the number of observations in the dseries object.You can
invoke this method for a batch of variables by providing a 1 by
n cell array of character row arrays as the first argument. When
"v" is a row vector with n elements, the method will be applied
uniformly across all periods. If "v" is a matrix, it must have
n columns, and the number of rows should correspond to the
number of periods.
*Example*
::
>> ts = dseries(rand(3,3));
>> ts.fill_({'Variable_1', 'Variable_3'}, [1 3]);
>> ts
ts is a dseries object:
| Variable_1 | Variable_2 | Variable_3
1Y | 1 | 0.91338 | 3
2Y | 1 | 0.63236 | 3
3Y | 1 | 0.09754 | 3
.. dseriesmethod:: f = firstdate (A)
|br| Returns the initial period in the ``dseries`` object ``A``.
.. dseriesmethod:: f = firstobservedperiod (A)
|br| Returns the first period where all the variables in ``dseries`` object ``A`` are observed (non NaN).
.. dseriesmethod:: B = flip (A)
flip_ (A)
|br| Flips the rows in the data member (without changing the
periods order).
.. dseriesmethod:: f = frequency (B)
|br| Returns the frequency of the variables in ``dseries`` object ``B``.
*Example*
::
>> ts = dseries(randn(3,2),'1973Q1');
>> ts.frequency
ans =
4
.. dseriesmethod:: l = ge (A, B)
l = gt (A, B)
|br| Overloads the ``gt`` (>) and ``ge`` (>=) binary operators. Returns a logical array.
*Example*
::
>> ts = dseries(randn(3,1))
ts is a dseries object:
| Variable_1
1Y | -1.2075
2Y | 0.71724
3Y | 1.6302
>> ts>1
ans =
3x1 logical array
0
0
1
>> ds = dseries(randn(3,1))
ds is a dseries object:
| Variable_1
1Y | 0.48889
2Y | 1.0347
3Y | 0.72689
>> ds>ts
ans =
3x1 logical array
1
1
0
.. dseriesmethod:: B = hdiff (A)
hdiff_ ()
|br| Computes bi-annual differences.
.. dseriesmethod:: B = hgrowth (A)
hgrowth_ ()
|br| Computes bi-annual growth rates.
.. dseriesmethod:: D = horzcat (A, B[, ...])
|br| Overloads the ``horzcat`` MATLAB/Octave’s method for
``dseries`` objects. Returns a ``dseries`` object ``D``
containing the variables in ``dseries`` objects passed as
inputs: ``A, B, ...`` If the inputs are not defined on the
same time ranges, the method adds NaNs to the variables so
that the variables are redefined on the smallest common time
range. Note that the names in the ``dseries`` objects passed
as inputs must be different and these objects must have common
frequency.
*Example*
::
>> ts0 = dseries(rand(5,2),'1950Q1',{'nifnif';'noufnouf'});
>> ts1 = dseries(rand(7,1),'1950Q3',{'nafnaf'});
>> ts2 = [ts0, ts1];
>> ts2
ts2 is a dseries object:
| nifnif | noufnouf | nafnaf
1950Q1 | 0.17404 | 0.71431 | NaN
1950Q2 | 0.62741 | 0.90704 | NaN
1950Q3 | 0.84189 | 0.21854 | 0.83666
1950Q4 | 0.51008 | 0.87096 | 0.8593
1951Q1 | 0.16576 | 0.21184 | 0.52338
1951Q2 | NaN | NaN | 0.47736
1951Q3 | NaN | NaN | 0.88988
1951Q4 | NaN | NaN | 0.065076
1952Q1 | NaN | NaN | 0.50946
.. dseriesmethod:: B = hpcycle (A[, lambda])
hpcycle_ ([lambda])
|br| Extracts the cycle component from a ``dseries`` ``A``
object using the *Hodrick and Prescott (1997)* filter and
returns a ``dseries`` object, ``B``. The default value for
``lambda``, the smoothing parameter, is ``1600``.
*Example*
::
% Simulate a component model (stochastic trend, deterministic
% trend, and a stationary autoregressive process).
e = 0.2*randn(200,1);
u = randn(200,1);
stochastic_trend = cumsum(e);
deterministic_trend = .1*transpose(1:200);
x = zeros(200,1);
for i=2:200
x(i) = .75*x(i-1) + u(i);
end
y = x + stochastic_trend + deterministic_trend;
% Instantiates time series objects.
ts0 = dseries(y,'1950Q1');
ts1 = dseries(x,'1950Q1'); % stationary component.
% Apply the HP filter.
ts2 = ts0.hpcycle();
% Plot the filtered time series.
plot(ts1(ts2.dates).data,'-k'); % Plot of the stationary component.
hold on
plot(ts2.data,'--r'); % Plot of the filtered y.
hold off
axis tight
id = get(gca,'XTick');
set(gca,'XTickLabel',strings(ts.dates(id)));
.. dseriesmethod:: B = hptrend (A[, lambda])
hptrend_ ([lambda])
|br| Extracts the trend component from a ``dseries`` A object
using the *Hodrick and Prescott (1997)* filter and returns a
``dseries`` object, ``B``. Default value for ``lambda``, the
smoothing parameter, is ``1600``.
*Example*
::
% Using the same generating data process
% as in the previous example:
ts1 = dseries(stochastic_trend + deterministic_trend,'1950Q1');
% Apply the HP filter.
ts2 = ts0.hptrend();
% Plot the filtered time series.
plot(ts1.data,'-k'); % Plot of the nonstationary components.
hold on
plot(ts2.data,'--r'); % Plot of the estimated trend.
hold off
axis tight
id = get(gca,'XTick');
set(gca,'XTickLabel',strings(ts0.dates(id)));
.. dseriesmethod:: C = insert (A, B, I)
|br| Inserts variables contained in ``dseries`` object ``B``
in ``dseries`` object ``A`` at positions specified by integer
scalars in vector ``I``, returns augmented ``dseries`` object
``C``. The integer scalars in ``I`` must take values between
`` and ``A.length()+1`` and refers to ``A`` ’s column
numbers. The ``dseries`` objects ``A`` and ``B`` need not be
defined over the same time ranges, but it is assumed that they
have common frequency.
*Example*
::
>> ts0 = dseries(ones(2,4),'1950Q1',{'Sly'; 'Gobbo'; 'Sneaky'; 'Stealthy'});
>> ts1 = dseries(pi*ones(2,1),'1950Q1',{'Noddy'});
>> ts2 = ts0.insert(ts1,3)
ts2 is a dseries object:
| Sly | Gobbo | Noddy | Sneaky | Stealthy
1950Q1 | 1 | 1 | 3.1416 | 1 | 1
1950Q2 | 1 | 1 | 3.1416 | 1 | 1
>> ts3 = dseries([pi*ones(2,1) sqrt(pi)*ones(2,1)],'1950Q1',{'Noddy';'Tessie Bear'});
>> ts4 = ts0.insert(ts1,[3, 4])
ts4 is a dseries object:
| Sly | Gobbo | Noddy | Sneaky | Tessie Bear | Stealthy
1950Q1 | 1 | 1 | 3.1416 | 1 | 1.7725 | 1
1950Q2 | 1 | 1 | 3.1416 | 1 | 1.7725 | 1
.. dseriesmethod:: B = isempty (A)
|br| Overloads the MATLAB/octave’s ``isempty`` function. Returns
``true`` if ``dseries`` object ``A`` is empty.
.. dseriesmethod:: C = isequal (A, B)
|br| Overloads the MATLAB/octave’s ``isequal`` function. Returns
``true`` if ``dseries`` objects ``A`` and ``B`` are identical.
.. dseriesmethod:: C = isinf (A)
|br| Overloads the MATLAB/octave’s ``isinf`` function. Returns
a logical array, with element ``(i,j)`` equal to ``true`` if and
only if variable ``j`` is finite in period ``A.dates(i)``.
.. dseriesmethod:: C = isnan (A)
|br| Overloads the MATLAB/octave’s ``isnan`` function. Returns
a logical array, with element ``(i,j)`` equal to ``true`` if and
only if variable ``j`` isn't NaN in period ``A.dates(i)``.
.. dseriesmethod:: C = isreal (A)
|br| Overloads the MATLAB/octave’s ``isreal`` function. Returns
a logical array, with element ``(i,j)`` equal to ``true`` if and
only if variable ``j`` is real in period ``A.dates(i)``.
.. dseriesmethod:: B = lag (A[, p])
lag_ ([p])
|br| Returns lagged time series. Default value of integer
scalar ``p``, the number of lags, is ``1``. The `dseries`
class overloads the parentheses, so that `ts.lag(p)` is
equivalent to `ts(-p)`.
*Example*
::
>> ts0 = dseries(transpose(1:4), '1950Q1')
ts0 is a dseries object:
| Variable_1
1950Q1 | 1
1950Q2 | 2
1950Q3 | 3
1950Q4 | 4
>> ts1 = ts0.lag()
ts1 is a dseries object:
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 2
1950Q4 | 3
>> ts2 = ts0.lag(2)
ts2 is a dseries object:
| Variable_1
1950Q1 | NaN
1950Q2 | NaN
1950Q3 | 1
1950Q4 | 2
% dseries class overloads the parenthesis
% so that ts.lag(p) can be written more
% compactly as ts(-p). For instance:
>> ts0.lag(1)
ans is a dseries object:
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 2
1950Q4 | 3
or alternatively::
>> ts0(-1)
ans is a dseries object:
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 2
1950Q4 | 3
.. dseriesmethod:: l = lastdate (B)
|br| Retrieves the final period from the ``dseries`` object ``B``.
*Example*
::
>> ts = dseries(randn(3,2),'1973Q1');
>> ts.lastdate()
ans = <dates: 1973Q3>
.. dseriesmethod:: f = lastobservedperiod (A)
|br| Returns the last period in which all variables of the
``dseries`` object ``A`` are fully observed (i.e., contain no
NaN values).
.. dseriesmethod:: f = lastobservedperiods (A)
|br| Returns the last period without missing observations for
each variable in the ``dseries`` object ``A``. The output
argument ``f`` is a structure where each field name corresponds
to a variable in ``A``, and the content of each field is a
singleton ``date`` object.
.. dseriesmethod:: l = le (A, B)
l = lt (A, B)
|br| Overloads the ``gt`` (<) and ``ge`` (<=) binary operators. Returns a logical array.
*Example*
::
>> ts = dseries(randn(3,1))
ts is a dseries object:
| Variable_1
1Y | -1.2075
2Y | 0.71724
3Y | 1.6302
>> ts<1
ans =
3x1 logical array
1
1
0
>> ds = dseries(randn(3,1))
ds is a dseries object:
| Variable_1
1Y | 0.48889
2Y | 1.0347
3Y | 0.72689
>> ds<ts
ans =
3x1 logical array
0
0
1
.. dseriesmethod:: B = lead (A[, p])
lead_ ([p])
|br| Returns a lead time series. The default value for the
integer scalar ``p``, which represents the number of leads, is
``1``. Similar to the ``lag`` method, the ``dseries`` class
overloads the parentheses, making ``ts.lead(p)`` equivalent to
``ts(p)``.
*Example*
::
>> ts0 = dseries(transpose(1:4),'1950Q1');
>> ts1 = ts0.lead()
ts1 is a dseries object:
| Variable_1
1950Q1 | 2
1950Q2 | 3
1950Q3 | 4
1950Q4 | NaN
>> ts2 = ts0(2)
ts2 is a dseries object:
| Variable_1
1950Q1 | 3
1950Q2 | 4
1950Q3 | NaN
1950Q4 | NaN
*Remark*
The overload of parentheses for ``dseries`` objects simplifies
the creation of new ``dseries`` instances by enabling the
direct copying and pasting of equations defined within the
``model`` block. For example, if an Euler equation is
specified in the ``model`` block,::
model;
...
1/C - beta/C(1)*(exp(A(1))*K^(alpha-1)+1-delta) ;
...
end;
and if variables ``, ``A`` and ``K`` are defined as
``dseries`` objects, then by writing::
Residuals = 1/C - beta/C(1)*(exp(A(1))*K^(alpha-1)+1-delta) ;
outside of the ``model`` block, we create a new ``dseries``
object, called ``Residuals``, for the residuals of the Euler
equation (the conditional expectation of the equation defined
in the ``model`` block is zero, but the residuals are non
zero).
.. dseriesmethod:: B = lineartrend (A)
|br| Returns a linear trend centered on 0, the length of the
trend is given by the size of ``dseries`` object ``A`` (the
number of periods).
*Example*
::
>> ts = dseries(ones(3,1));
>> ts.lineartrend()
ans =
-1
0
1
.. dseriesmethod:: B = log (A)
log_ ()
|br| Overloads the MATLAB/Octave ``log`` function for
``dseries`` objects.
*Example*
::
>> ts0 = dseries(rand(10,1));
>> ts1 = ts0.log();
.. dseriesmethod:: B = mdiff (A)
mdiff_ ()
B = mgrowth (A)
mgrowth_ ()
|br| Calculates the monthly differences or growth rates of
variables in the ``dseries`` object ``A``.
.. dseriesmethod:: B = mean (A[, geometric])
|br| This function overloads the MATLAB/Octave ``mean``
function specifically for ``dseries`` objects. It calculates
the mean for each variable within the ``dseries`` object
``A``. If the second argument is set to ``true``, the
geometric mean is calculated; otherwise, the arithmetic mean
is computed by default.
.. dseriesmethod:: C = merge (A, B[, legacy])
|br| Merges two ``dseries`` objects, ``A`` and ``B``, into a new
``dseries`` object ``C``. The objects ``A`` and ``B`` must share a
common frequency, although they can cover different time
ranges. If a variable, such as ``x``, exists in both ``dseries``
objects, the ``merge`` function will prioritize the definition
from the second input, ``B``, while retaining the values from
``A`` for any corresponding periods where ``B`` has NaN
values. This behavior can be altered by setting the optional
argument ``legacy`` to true, in which case the second variable
will replace the first, even if it contains NaN values.
*Example*
::
>> ts0 = dseries(rand(3,2),'1950Q1',{'A1';'A2'})
ts0 is a dseries object:
| A1 | A2
1950Q1 | 0.96284 | 0.5363
1950Q2 | 0.25145 | 0.31866
1950Q3 | 0.34447 | 0.4355
>> ts1 = dseries(rand(3,1),'1950Q2',{'A1'})
ts1 is a dseries object:
| A1
1950Q2 | 0.40161
1950Q3 | 0.81763
1950Q4 | 0.97769
>> merge(ts0,ts1)
ans is a dseries object:
| A1 | A2
1950Q1 | 0.96284 | 0.5363
1950Q2 | 0.40161 | 0.31866
1950Q3 | 0.81763 | 0.4355
1950Q4 | 0.97769 | NaN
>> merge(ts1,ts0)
ans is a dseries object:
| A1 | A2
1950Q1 | 0.96284 | 0.5363
1950Q2 | 0.25145 | 0.31866
1950Q3 | 0.34447 | 0.4355
1950Q4 | 0.97769 | NaN
.. dseriesmethod:: C = minus (A, B)
|br| Overloads the MATLAB/Octave ``minus`` (``-``) operator
for ``dseries`` objects, allowing for element-by-element
subtraction. When both ``A`` and ``B`` are ``dseries``
objects, they do not need to be defined over the same time
ranges. If ``A`` and ``B`` have :math:`T_A` and :math:`T_B`
observations and :math:`N_A` and :math:`N_B` variables, then
:math:`N_A` must equal :math:`N_B` or :math:`1`, and
:math:`N_B` must equal :math:`N_A` or :math:`1`. If
:math:`T_A=T_B`, ``isequal(A.init,B.init)`` returns ``1``,
and :math:`N_A=N_B`, then the ``minus`` operator will compute
for each pair :math:`(t,n)`, where :math:`1\le t\le T_A` and
:math:`1\le n\le N_A`, the operation
``C.data(t,n)=A.data(t,n)-B.data(t,n)``. If :math:`N_B` equals
:math:`1` and :math:`N_A>1`, the smaller ``dseries`` object
(``B``) is “broadcasted” across the larger ``dseries`` (``A``),
ensuring compatible shapes for the subtraction of the variable
defined in ``B`` from each variable in ``A``. If ``B`` is a
double scalar, the ``minus`` method will subtract ``B`` from
all observations and variables in ``A``. If ``B`` is a row
vector of length :math:`N_A`, the ``minus`` method will
subtract ``B(i)`` from all observations of variable ``i``, for
:math:`i=1,...,N_A`. If ``B`` is a column vector of length
:math:`T_A`, the ``minus`` method will subtract ``B`` from all
the variables.
*Example*
::
>> ts0 = dseries(rand(3,2));
>> ts1 = ts0{'Variable_2'};
>> ts0-ts1
ans is a dseries object:
| Variable_1 | Variable_2
1Y | -0.48853 | 0
2Y | -0.50535 | 0
3Y | -0.32063 | 0
>> ts1
ts1 is a dseries object:
| Variable_2
1Y | 0.703
2Y | 0.75415
3Y | 0.54729
>> ts1-ts1.data(1)
ans is a dseries object:
| Variable_2
1Y | 0
2Y | 0.051148
3Y | -0.15572
>> ts1.data(1)-ts1
ans is a dseries object:
| Variable_2
1Y | 0
2Y | -0.051148
3Y | 0.15572
.. dseriesmethod:: C = mpower (A, B)
|br| Overloads the MATLAB/Octave ``mpower`` (``^``) operator
for ``dseries`` objects, performing element-wise
exponentiation. Given a ``dseries`` object ``A`` with ``N``
variables and ``T`` observations, if ``B`` is a real scalar,
then ``mpower(A,B)`` yields a ``dseries`` object ``C`` where
``C.data(t,n) = A.data(t,n)^B``. If ``B`` is also a
``dseries`` object with ``N`` variables and ``T``
observations, then ``mpower(A,B)`` produces a ``dseries``
object ``C`` such that ``C.data(t,n) =
A.data(t,n)^{C.data(t,n)}``.
*Example*
::
>> ts0 = dseries(transpose(1:3));
>> ts1 = ts0^2
ts1 is a dseries object:
| Variable_1
1Y | 1
2Y | 4
3Y | 9
>> ts2 = ts0^ts0
ts2 is a dseries object:
| Variable_1
1Y | 1
2Y | 4
3Y | 27
.. dseriesmethod:: C = mrdivide (A, B)
|br| Overloads the MATLAB/Octave ``mrdivide`` (``/``) operator
for ``dseries`` objects, enabling element-wise division
similar to the ``./`` operator in MATLAB/Octave. When both
``A`` and ``B`` are ``dseries`` objects, they can have
different time ranges. If ``A`` contains :math:`T_A`
observations and :math:`N_A` variables, and ``B`` has
:math:`T_B` observations and :math:`N_B` variables, then
:math:`N_A` must equal :math:`N_B` or :math:`1`, and vice
versa. If :math:`T_A=T_B` and ``isequal(A.init,B.init)``
returns ``1``, along with :math:`N_A=N_B`, the ``mrdivide``
operator calculates for each pair :math:`(t,n)`, where
:math:`1\le t\le T_A` and :math:`1\le n\le N_A`, the value of
``C.data(t,n)=A.data(t,n)/B.data(t,n)``. If :math:`N_B` equals
:math:`1` and :math:`N_A>1`, the smaller ``dseries`` object
(``B``) is “broadcast” across the larger one (``A``) to ensure
compatible shapes. In this case, the ``mrdivide`` operator
divides each variable in ``A`` by the variable in ``B``,
observation by observation. If ``B`` is a double scalar, then
``mrdivide`` will divide all observations and variables in
``A`` by ``B``. If ``B`` is a row vector of length
:math:`N_A`, then ``mrdivide`` will divide each observation of
variable ``i`` by ``B(i)``, for :math:`i=1,...,N_A`. If ``B``
is a column vector of length :math:`T_A`, then ``mrdivide``
will perform an element-wise division of all variables by
``B``.
*Example*
::
>> ts0 = dseries(rand(3,2))
ts0 is a dseries object:
| Variable_1 | Variable_2
1Y | 0.72918 | 0.90307
2Y | 0.93756 | 0.21819
3Y | 0.51725 | 0.87322
>> ts1 = ts0{'Variable_2'};
>> ts0/ts1
ans is a dseries object:
| Variable_1 | Variable_2
1Y | 0.80745 | 1
2Y | 4.2969 | 1
3Y | 0.59235 | 1
.. dseriesmethod:: C = mtimes (A, B)
|br| Overloads the MATLAB/Octave ``mtimes`` (``*``) operator
for ``dseries`` objects, enabling element-wise multiplication
similar to the ``.*`` operator in MATLAB/Octave. When both
``A`` and ``B`` are ``dseries`` objects, they can have
different time ranges. If ``A`` contains :math:`T_A`
observations and :math:`N_A` variables, and ``B`` has
:math:`T_B` observations and :math:`N_B` variables, then
:math:`N_A` must equal :math:`N_B` or :math:`1`, and vice
versa. If :math:`T_A=T_B` and ``isequal(A.init,B.init)``
returns ``1``, along with :math:`N_A=N_B`, the ``mtimes``
operator calculates for each pair :math:`(t,n)`, where
:math:`1\le t\le T_A` and :math:`1\le n\le N_A`, the value of
``C.data(t,n)=A.data(t,n)*B.data(t,n)``. If :math:`N_B` equals
:math:`1` and :math:`N_A>1`, the smaller ``dseries`` object
(``B``) is “broadcasted” across the larger one (``A``) to ensure
compatible shapes. In this case, the ``mtimes`` operator
multiply each variable in ``A`` by the variable in ``B``,
observation by observation. If ``B`` is a double scalar, then
``mtimes`` will multiply all observations and variables in
``A`` by ``B``. If ``B`` is a row vector of length
:math:`N_A`, then ``mtimes`` will multiply each observation of
variable ``i`` by ``B(i)``, for :math:`i=1,...,N_A`. If ``B``
is a column vector of length :math:`T_A`, then ``mtimes``
will perform an element-wise multiplication of all variables by
``B``.
.. dseriesmethod:: B = nanmean (A[, geometric])
|br| Overloads the MATLAB/Octave ``nanmean`` function for
``dseries`` objects. Computes the mean of each variable in the
``dseries`` object ``A``, excluding NaN values. If the second
argument is ``true``, the geometric mean is calculated;
otherwise, the default is to report the arithmetic mean.
.. dseriesmethod:: B = nanstd (A[, geometric])
|br| Overloads the MATLAB/Octave ``nanstd`` function for
``dseries`` objects. This function calculates the standard
deviation for each variable within the ``dseries`` object
``A``, while disregarding any NaN values. If the second
argument is set to ``true``, the geometric standard deviation
will be computed; the default value for the second argument is
``false``.
.. dseriesmethod:: C = ne (A, B)
|br| Overloads the MATLAB/Octave ``ne`` (not equal, ``~=``)
operator. The ``dseries`` objects ``A`` and ``B`` must contain
the same number of observations (denoted as :math:`T`) and
variables (denoted as :math:`N`). The output is a :math:`T` by
:math:`N` matrix consisting of zeros and ones. The element
:math:`(i,j)` of the matrix ``C`` is equal to ``1`` if and
only if observation :math:`i` for variable :math:`j` in ``A``
and ``B`` are not equal.
*Example*
::
>> ts0 = dseries(2*ones(3,1));
>> ts1 = dseries([2; 0; 2]);
>> ts0~=ts1
ans =
3x1 logical array
0
1
0
.. dseriesmethod:: B = nobs (A)
|br| Returns the number of observations in ``dseries`` object
``A``.
*Example*
::
>> ts0 = dseries(randn(10));
>> ts0.nobs
ans =
10
.. dseriesmethod:: B = onesidedhpcycle (A[, lambda[, init]])
onesidedhpcycle_ ([lambda[, init]])
|br| Extracts the cycle component from a ``dseries`` ``A``
object using a one-sided HP filter (implemented with a Kalman
filter) and returns a ``dseries`` object, ``B``. The default
value for ``lambda``, the smoothing parameter, is set to
``1600``. By default, if ``init`` is not provided, the initial
value is determined from the first two observations.
.. dseriesmethod:: B = onesidedhptrend (A[, lambda[, init]])
onesidedhptrend_ (A[, lambda[, init]])
|br| Extracts the trend component from a ``dseries`` ``A``
object using a one-sided HP filter (implemented with a Kalman
filter) and returns a ``dseries`` object, ``B``. The default
value for ``lambda``, the smoothing parameter, is set to
``1600``. By default, if ``init`` is not provided, the initial
value is derived from the first two observations.
.. dseriesmethod:: h = plot (A)
h = plot (A, B)
h = plot (A[, ...])
h = plot (A, B[, ...])
|br| Overloads the MATLAB/Octave ``plot`` function for
``dseries`` objects. This function returns a MATLAB/Octave
plot handle, which can be utilized to modify the properties of
the plotted time series. If a single ``dseries`` object,
``A``, is provided as an argument, the plot function will
place the corresponding dates on the x-axis. If this
``dseries`` object contains only one variable, additional
arguments can be included to adjust the plot properties,
similar to how one would with MATLAB/Octave's original plot
function. However, if the ``dseries`` object ``A`` has more
than one variable, additional arguments cannot be passed, and
modifications to the plotted time series properties must be
done using the returned plot handle alongside the
MATLAB/Octave ``set`` function (refer to the example
below). When two ``dseries`` objects, ``A`` and ``B``, are
passed as input arguments, the plot function will display the
variables in ``A`` against those in ``B`` (it is essential
that both objects contain the same number of variables;
otherwise, an error will occur). Once more, if each object
includes only one variable, additional arguments can be
utilized to alter the plotted time series properties;
otherwise, the MATLAB/Octave ``set`` command must be employed.
*Example*
Define a ``dseries`` object with two variables (named by
default ``Variable_1`` and ``Variable_2``)::
>> ts = dseries(randn(100,2),'1950Q1');
The following command will plot the first variable in ``ts``::
>> plot(ts{'Variable_1'},'-k','linewidth',2);
The next command will draw all the variables in ``ts`` on
the same figure::
>> h = plot(ts);
If one wants to modify the properties of the plotted time
series (line style, colours, ...), the set function can be
used (see MATLAB’s documentation)::
>> set(h(1),'-k','linewidth',2);
>> set(h(2),'--r');
The following command will plot ``Variable_1`` against
``exp(Variable_1)``::
>> plot(ts{'Variable_1'},ts{'Variable_1'}.exp(),'ok');
Again, the properties can also be modified using the
returned plot handle and the ``set`` function::
>> h = plot(ts, ts.exp());
>> set(h(1),'ok');
>> set(h(2),'+r');
.. dseriesmethod:: C = plus (A, B)
|br| Overloads the MATLAB/Octave ``plus`` (``+``) operator for
``dseries`` objects, allowing for element-wise addition. When both
``A`` and ``B`` are ``dseries`` objects, they do not need to
be defined over the same time ranges. If ``A`` and ``B`` are
``dseries`` objects with :math:`T_A` and :math:`T_B`
observations and :math:`N_A` and :math:`N_B` variables, then
:math:`N_A` must be equal to :math:`N_B` or :math:`1` and
:math:`N_B` must be equal to :math:`N_A` or :math:`1`. If
:math:`T_A=T_B`, ``isequal(A.init,B.init)`` returns ``1`` and
:math:`N_A=N_B`, then the ``plus`` operator will compute for
each pair :math:`(t,n)`, with :math:`1\le t\le T_A` and
:math:`1\le n\le N_A`,
``C.data(t,n)=A.data(t,n)+B.data(t,n)``. If :math:`N_B` is
equal to :math:`1` and :math:`N_A>1`, the smaller ``dseries``
object (``B``) is “broadcasted” across the larger ``dseries``
(``A``) to ensure compatible shapes, the plus operator
will add the variable defined in ``B`` to each variable in
``A``. If ``B`` is a double scalar, then the method ``plus``
will add ``B`` to all the observations/variables in ``A``. If
``B`` is a row vector of length :math:`N_A`, then the ``plus``
method will add ``B(i)`` to all the observations of variable
``i``, for :math:`i=1,\ldots,N_A`. If ``B`` is a column vector of
length :math:`T_A`, then the ``plus`` method will add ``B`` to
all the variables.
.. dseriesmethod:: C = pop (A[, B])
pop_ ([B])
|br| Removes the variable ``B`` from the ``dseries`` object
``A``. By default, if the second argument is not specified, the
last variable is removed.
*Example*
::
>> ts0 = dseries(ones(3,3));
>> ts1 = ts0.pop('Variable_2');
ts1 is a dseries object:
| Variable_1 | Variable_3
1Y | 1 | 1
2Y | 1 | 1
3Y | 1 | 1
.. dseriesmethod:: A = projection (A, info, periods)
|br| Projects variables in the dseries object ``A``. The
``info`` variable is a :math:`n \times 3` cell array, where
each row contains essential information for projecting a
variable. The first column holds the variable name (as a
character array), while the second column indicates the
projection method used (also a character array). The possible
values for this column are ``'Trend'``, ``'Constant'``, and
``'AR'``. The third column provides quantitative details
related to the projection: if the second column is
``'Trend'``, the third column specifies the growth factor of
the (exponential) trend; if ``'Constant'``, it indicates the
variable's level; and if ``'AR'``, it denotes the
autoregressive parameter. Variables can be projected using an
AR(p) model if the third column contains a 1×p vector of
doubles. Note that the stationarity of the AR(p) model is not
tested. For constant projections, one can use either `'Trend'`
with a growth factor of 1 or `'AR'` with an autoregressive
parameter of one (indicating a random walk). This projection
routine solely addresses exponential trends.
*Example*
::
>> data = ones(10,4);
>> ts = dseries(data, '1990Q1', {'A1', 'A2', 'A3', 'A4'});
>> info = {'A1', 'Trend', 1.2; 'A2', 'Constant', 0.0; 'A3', 'AR', .5; 'A4', 'AR', [.4, -.2]};
>> ts.projection(info, 10);
.. dseriesmethod:: B = qdiff (A)
B = qgrowth (A)
qdiff_ ()
qgrowth_ ()
|br| Computes quarterly differences or growth rates.
*Example*
::
>> ts0 = dseries(transpose(1:4),'1950Q1');
>> ts1 = ts0.qdiff()
ts1 is a dseries object:
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 1
1950Q4 | 1
>> ts0 = dseries(transpose(1:6),'1950M1');
>> ts1 = ts0.qdiff()
ts1 is a dseries object:
| Variable_1
1950M1 | NaN
1950M2 | NaN
1950M3 | NaN
1950M4 | 3
1950M5 | 3
1950M6 | 3
.. dseriesmethod:: C = remove (A, B)
remove_ (B)
|br| If ``B`` is a row character array representing the name
of a variable, these methods serve as aliases for the ``pop``
and ``pop_`` methods that accept two arguments. They remove
the variable ``B`` from the ``dseries`` object ``A``. To
remove multiple variables, you can pass a cell array of row
character arrays for ``B``.
*Example*
::
>> ts0 = dseries(ones(3,3));
>> ts1 = ts0.remove('Variable_2');
ts1 is a dseries object:
| Variable_1 | Variable_3
1Y | 1 | 1
2Y | 1 | 1
3Y | 1 | 1
A more concise syntax is available: ``remove(ts,
'Variable_2')``, which is equivalent to ``ts{'Variable_2'}
= []`` (where ``[]`` can be substituted with any empty
object). This alternative syntax proves useful when
removing multiple variables. For example::
ts{'Variable_@2,3,4@'} = [];
will remove ``Variable_2``, ``Variable_3`` and
``Variable_4`` from ``dseries`` object ``ts`` (if these
variables exist). Regular expressions cannot be used but
implicit loops can.
.. dseriesmethod:: B = rename (A, oldname, newname)
rename_ (oldname, newname)
|br| Renames the variable ``oldname`` to ``newname`` in the
``dseries`` object ``A``. This function returns a ``dseries``
object. If multiple variables need to be renamed, you can
provide cell arrays of row character arrays as the second and
third arguments.
*Example*
::
>> ts0 = dseries(ones(2,2));
>> ts1 = ts0.rename('Variable_1','Stinkly')
ts1 is a dseries object:
| Stinkly | Variable_2
1Y | 1 | 1
2Y | 1 | 1
.. dseriesmethod:: C = rename (A, newname)
rename_ (newname)
|br| Replace the names in ``A`` with those specified in the
cell of row character arrays ``newname``. The cell ``newname`` must contain
the same number of elements as there are variables in the
``dseries`` object ``A``.
*Example*
::
>> ts0 = dseries(ones(2,3));
>> ts1 = ts0.rename({'TinkyWinky','Dipsy','LaaLaa'})
ts1 is a dseries object:
| TinkyWinky | Dipsy | LaaLaa
1Y | 1 | 1 | 1
2Y | 1 | 1 | 1
.. dseriesmethod:: A = resetops (A, ops)
|br| Redefine ``ops`` member.
.. dseriesmethod:: A = resetags (A, ops)
|br| Redefine ``tags`` member.
.. dseriesmethod:: B = round (A[, n])
round_ ([n])
|br| Rounds each value to the nearest decimal or integer. The
parameter ``n`` specifies the precision (number of decimal
places), with a default value of 0, indicating that the method
will round to the nearest integer by default.
*Example*
::
>> ts = dseries(pi)
ts is a dseries object:
| Variable_1
1Y | 3.1416
>> ts.round_();
>> ts
ts is a dseries object:
| Variable_1
1Y | 3
.. dseriesmethod:: save (A, basename[, format])
|br| Overloads the MATLAB/Octave ``save`` function to save the
``dseries`` object ``A`` to disk. The available formats
include ``mat`` (default, MATLAB binary data file), ``m``
(MATLAB/Octave script), and ``csv`` (comma-separated values
file). The base name of the file, excluding the extension, is
specified by ``basename``.
*Example*
::
>> ts0 = dseries(ones(2,2));
>> ts0.save('ts0', 'csv');
The last command will create a file ts0.csv with the
following content::
,Variable_1,Variable_2
1Y, 1, 1
2Y, 1, 1
To create a MATLAB/Octave script, the following command::
>> ts0.save('ts0','m');
will produce a file ts0.m with the following content::
% File created on 14-Nov-2013 12:08:52.
FREQ__ = 1;
INIT__ = ' 1Y';
NAMES__ = {'Variable_1'; 'Variable_2'};
TEX__ = {'Variable_{1}'; 'Variable_{2}'};
OPS__ = {};
TAGS__ = struct();
Variable_1 = [
1
1];
Variable_2 = [
1
1];
The generated (``csv``, ``m``, or ``mat``) files can be
loaded when instantiating a ``dseries`` object as
explained above.
.. dseriesmethod:: B = set_names(A, s1, s2, ...)
|br| Renames the variables in the ``dseries`` object ``A`` and
returns a new ``dseries`` object ``B`` with the updated names
``s1``, ``s2``, and so forth. The number of input arguments
following the first one (the ``dseries`` object ``A``) must be
equal to ``A.vobs`` (the total number of variables in
``A``). The name ``s1`` will correspond to the first variable
in ``B``, ``s2`` to the second variable in ``B``, and this
pattern continues for the remaining variables.
*Example*
::
>> ts0 = dseries(ones(1,3));
>> ts1 = ts0.set_names('Barbibul',[],'Barbouille')
ts1 is a dseries object:
| Barbibul | Variable_2 | Barbouille
1Y | 1 | 1 | 1
.. dseriesmethod:: [T, N ] = size(A[, dim])
Overloads the MATLAB/Octave ``size`` function to return the
number of observations in the ``dseries`` object ``A`` (i.e.,
``A.nobs``) as well as the number of variables (i.e.,
``A.vobs``). If a second input argument is provided, the
``size`` function will return the number of observations when
``dim=1`` or the number of variables when ``dim=2``. An error
will be issued for any other values of ``dim``.
*Example*
::
>> ts0 = dseries(ones(1,3));
>> ts0.size()
ans =
1 3
.. dseriesmethod:: B = std (A[, geometric])
|br| Overloads the MATLAB/Octave ``std`` function for
``dseries`` objects. This function returns the standard
deviation of each variable within the ``dseries`` object
``A``. If the second argument is set to ``true``, the
geometric standard deviation is calculated (the default value
for the second argument is ``false``).
.. dseriesmethod:: B = subsample (A, d1, d2)
|br| Returns a subsample for the period between ``d1`` and
``d2``. While you can achieve the same result by indexing a
``dseries`` object with a ``dates`` object, the ``subsample``
method offers a more straightforward approach for programmatic
use.
*Example*
::
>> o = dseries(transpose(1:5));
>> o.subsample(dates('2y'),dates('4y'))
ans is a dseries object:
| Variable_1
2Y | 2
3Y | 3
4Y | 4
.. dseriesmethod:: A = tag (A, a[, b, c])
|br| Adds a tag to a variable in ``dseries`` object ``A``.
*Example*
::
>> ts = dseries(randn(10, 3));
>> tag(ts, 'type'); % Define a tag name.
>> tag(ts, 'type', 'Variable_1', 'Stock');
>> tag(ts, 'type', 'Variable_2', 'Flow');
>> tag(ts, 'type', 'Variable_3', 'Stock');
.. dseriesmethod:: B = tex_rename (A, name, newtexname)
B = tex_rename (A, newtexname)
tex_rename_ (name, newtexname)
tex_rename_ (newtexname)
|br| Updates the TeX name of the variable ``name`` to
``newtexname`` in the ``dseries`` object ``A``. Returns an
updated ``dseries`` object.
With just two arguments, ``A`` and ``newtexname``, this
function redefines the TeX names of the entries in ``A`` to
those specified in ``newtexname``. The ``newtexname`` argument
must be a cell row character arrays containing the same number of
entries as there are variables in ``A``.
.. dseriesmethod:: B = uminus(A)
|br| Overloads the ``uminus`` operator (``-``, unary minus)
for the ``dseries`` object.
*Example*
::
>> ts0 = dseries(1)
ts0 is a dseries object:
| Variable_1
1Y | 1
>> ts1 = -ts0
ts1 is a dseries object:
| Variable_1
1Y | -1
.. dseriesmethod:: D = vertcat (A, B[, ...])
|br| Overloads the ``vertcat`` method in MATLAB/Octave for
``dseries`` objects. This method facilitates the appending of
additional observations to a ``dseries`` object. It returns a
new ``dseries`` object, ``D``, which contains the variables
from the input ``dseries`` objects. All input arguments must
be ``dseries`` objects that share the same variables but are
defined over different time ranges.
*Example*
::
>> ts0 = dseries(rand(2,2),'1950Q1',{'nifnif';'noufnouf'});
>> ts1 = dseries(rand(2,2),'1950Q3',{'nifnif';'noufnouf'});
>> ts2 = [ts0; ts1]
ts2 is a dseries object:
| nifnif | noufnouf
1950Q1 | 0.82558 | 0.31852
1950Q2 | 0.78996 | 0.53406
1950Q3 | 0.089951 | 0.13629
1950Q4 | 0.11171 | 0.67865
.. dseriesmethod:: B = vobs (A)
|br| Returns the count of variables in the ``dseries`` object ``A``.
*Example*
::
>> ts0 = dseries(randn(10,2));
>> ts0.vobs
ans =
2
.. dseriesmethod:: B = ydiff (A)
B = ygrowth (A)
ydiff_ ()
ygrowth_ ()
|br| Calculates annual differences or growth rates.
.. _x13-members:
X-13 ARIMA-SEATS interface
==========================
.. class:: x13
|br| The x13 class provides a method for each X-13 command as
documented in the X-13 ARIMA-SEATS reference manual (`x11`,
`automdl`, `estimate`, ...). The respective options (see Chapter 7 of U.S. Census Bureau (2020))
can then be passed by key/value pairs. The ``x13`` class has 22 members:
:arg y: ``dseries`` object with a single variable.
:arg x: ``dseries`` object with an arbitrary number of variables (to be used in the REGRESSION block).
:arg arima: structure containing the options of the ARIMA model command.
:arg automdl: structure containing the options of the ARIMA model selection command.
:arg regression: structure containing the options of the Regression command.
:arg estimate: structure containing the options of the estimation command.
:arg transform: structure containing the options of the transform command.
:arg outlier: structure containing the options of the outlier command.
:arg forecast: structure containing the options of the forecast command.
:arg check: structure containing the options of the check command.
:arg x11: structure containing the options of the X11 command.
:arg force: structure containing the options of the force command.
:arg history: structure containing the options of the history command.
:arg metadata: structure containing the options of the metadata command.
:arg identify: structure containing the options of the identify command.
:arg pickmdl: structure containing the options of the pickmdl command.
:arg seats: structure containing the options of the seats command.
:arg slidingspans: structure containing the options of the slidingspans command.
:arg spectrum: structure containing the options of the spectrum command.
:arg x11regression: structure containing the options of the x11Regression command.
:arg results: structure containing the results returned by x13.
:arg commands: cell array containing the list of commands.
All these members are private. The following constructors are available:
.. construct:: x13 (y)
|br| Instantiates an ``x13`` object with `dseries` object
``y``. The ``dseries`` object passed as an argument must
contain only one variable, the one we need to pass to X-13.
.. construct:: x13 (y, x)
|br| Instantiates an ``x13`` object with `dseries` objects
``y`` and ``x``. The first ``dseries`` object passed as an
argument must contain only one variable, the second
``dseries`` object contains the exogenous variables used by
some of the X-13 commands. Both objects must be defined on the
same time span.
The following methods allow to set sequence of X-13 commands, write an `.spc` file, and run the X-13 binary:
.. x13method:: A = arima (A, key, value[, key, value[, [...]]])
Interface to the ``arima`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = automdl (A, key, value[, key, value[, [...]]])
Interface to the ``automdl`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = regression (A, key, value[, key, value[, [...]]])
Interface to the ``regression`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = estimate (A, key, value[, key, value[, [...]]])
Interface to the ``estimate`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = transform (A, key, value[, key, value[, [...]]])
Interface to the ``transform`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs. For example, the key/value pair ``function,log``
instructs the use of a multiplicative instead of an additive seasonal pattern,
while ``function,auto`` triggers an automatic selection between the two based
on their fit.
.. x13method:: A = outlier (A, key, value[, key, value[, [...]]])
Interface to the ``outlier`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = forecast (A, key, value[, key, value[, [...]]])
Interface to the ``forecast`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = check (A, key, value[, key, value[, [...]]])
Interface to the ``check`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = x11 (A, key, value[, key, value[, [...]]])
Interface to the ``x11`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = force (A, key, value[, key, value[, [...]]])
Interface to the ``force`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = history (A, key, value[, key, value[, [...]]])
Interface to the ``history`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = metadata (A, key, value[, key, value[, [...]]])
Interface to the ``metadata`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = identify (A, key, value[, key, value[, [...]]])
Interface to the ``identify`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = pickmdl (A, key, value[, key, value[, [...]]])
Interface to the ``pickmdl`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = seats (A, key, value[, key, value[, [...]]])
Interface to the ``seats`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = slidingspans (A, key, value[, key, value[, [...]]])
Interface to the ``slidingspans`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = spectrum (A, key, value[, key, value[, [...]]])
Interface to the ``spectrum`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = x11regression (A, key, value[, key, value[, [...]]])
Interface to the ``x11regression`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: print (A[, basefilename])
Prints an ``.spc`` file with all the X-13 commands. The
optional second argument is a row char array specifying the
name (without extension) of the file.
.. x13method:: run (A)
Calls the X-13 binary and run the previously defined
commands. All the results are stored in the structure
``A.results``. When it makes sense these results are saved in
``dseries`` objects (*e.g.* for forecasts or filtered variables).
.. x13method:: clean (A)
Removes the temporary files created by an x13 run that store the intermediate
results. This method allows keeping the main folder clean but will also
delete potentially important debugging information.
*Example*
::
>> ts = dseries(rand(100,1),'1999M1');
>> o = x13(ts);
>> o.x11('save','(d11)');
>> o.automdl('savelog','amd','mixed','no');
>> o.outlier('types','all','save','(fts)');
>> o.check('maxlag',24,'save','(acf pcf)');
>> o.estimate('save','(mdl est)');
>> o.forecast('maxlead',18,'probability',0.95,'save','(fct fvr)');
>> o.run();
The above example shows a run of X13 with various commands an options specified.
*Example*
::
% 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
y = [112 115 145 171 196 204 242 284 315 340 360 417 ... % Jan
118 126 150 180 196 188 233 277 301 318 342 391 ... % Feb
132 141 178 193 236 235 267 317 356 362 406 419 ... % Mar
129 135 163 181 235 227 269 313 348 348 396 461 ... % Apr
121 125 172 183 229 234 270 318 355 363 420 472 ... % May
135 149 178 218 243 264 315 374 422 435 472 535 ... % Jun
148 170 199 230 264 302 364 413 465 491 548 622 ... % Jul
148 170 199 242 272 293 347 405 467 505 559 606 ... % Aug
136 158 184 209 237 259 312 355 404 404 463 508 ... % Sep
119 133 162 191 211 229 274 306 347 359 407 461 ... % Oct
104 114 146 172 180 203 237 271 305 310 362 390 ... % Nov
118 140 166 194 201 229 278 306 336 337 405 432 ]'; % Dec
ts = dseries(y,'1949M1');
o = x13(ts);
o.transform('function','auto','savelog','atr');
o.automdl('savelog','all');
o.x11('save','(d11 d10)');
o.run();
o.clean();
y_SA=o.results.d11;
y_seasonal_pattern=o.results.d10;
figure('Name','Comparison raw data and SAed data');
plot(ts.dates,log(o.y.data),ts.dates,log(y_SA.data),ts.dates,log(y_seasonal_pattern.data))
The above example shows how to remove a seasonal pattern from a time series.
``o.transform('function','auto','savelog','atr')`` instructs the subsequent
``o.automdl()`` command to check whether an additional or a multiplicative
pattern fits the data better and to save the result. The result is saved in
`o.results.autotransform`, which in the present example indicates that a
log transformation, i.e. a multiplicative model was preferred. The ``o.automdl('savelog','all')`` automatically selects a fitting
ARIMA model and saves all relevant output to the .log-file. The ``o.x11('save','(d11, d10)')`` instructs
``x11`` to save both the final seasonally adjusted series ``d11`` and the final seasonal factor ``d10``
into ``dseries`` with the respective names in the output structure ``o.results``. ``o.clean()`` removes the
temporary files created by ``o.run()``. Among these are the ``.log``-file storing
summary information, the ``.err``-file storing information on problems encountered,
the ``.out``-file storing the raw output, and the `.spc`-file storing the specification for the `x11` run.
There may be further files depending on the output requested. The last part of the example reads out the
results and plots a comparison of the logged raw data and its log-additive decomposition into a
seasonal pattern and the seasonally adjusted series.
Miscellaneous
=============
Time aggregation
----------------
|br| A set of functions allows to convert time series to lower frequencies:
- ``dseries2M`` converts daily time series object to monthly
time series object.
- ``dseries2Q`` converts daily or monthly time series object
to quarterly time series object.
- ``dseries2S`` converts daily, monthly, or quarterly time
series object to bi-annual time series object.
- ``dseries2Y`` converts daily, monthly, quarterly, or
bi-annual time series object to annual time series object.
|br| All these routines have two mandatory input arguments: the first one is a
``dseries`` object, the second one the name (row char array) of the
aggregation method. Possible values for the second argument are:
- ``arithmetic-average`` (for growth rates),
- ``geometric-average`` (for growth factors),
- ``sum`` (for flow variables), and
- ``end-of-period`` (for stock variables).
*Example*
::
>> ts = dseries(rand(12,1),'2000M1')
ts is a dseries object:
| Variable_1
2000M1 | 0.55293
2000M2 | 0.14228
2000M3 | 0.38036
2000M4 | 0.39657
2000M5 | 0.57674
2000M6 | 0.019402
2000M7 | 0.57758
2000M8 | 0.9322
2000M9 | 0.10687
2000M10 | 0.73215
2000M11 | 0.97052
2000M12 | 0.60889
>> ds = dseries2Y(ts, 'end-of-period')
ds is a dseries object:
| Variable_1
2000Y | 0.60889
Create time series with a univariate model
------------------------------------------
|br| It is possible to expand a ``dseries`` object recursively
with the ``from`` command. For instance to create a ``dseries`` object
containing the simulation of an ARMA(1,1) model:
::
>> e = dseries(randn(100, 1), '2000Q1', 'e', '\varepsilon');
>> y = dseries(zeros(100, 1), '2000Q1', 'y');
>> from 2000Q2 to 2024Q4 do y(t)=.9*y(t-1)+e(t)-.4*e(t-1);
>> y
y is a dseries object:
| y
2000Q1 | 0
2000Q2 | -0.95221
2000Q3 | -0.6294
2000Q4 | -1.8935
2001Q1 | -1.1536
2001Q2 | -1.5905
2001Q3 | 0.97056
2001Q4 | 1.1409
2002Q1 | -1.9255
2002Q2 | -0.29287
|
2022Q2 | -1.4683
2022Q3 | -1.3758
2022Q4 | -1.2218
2023Q1 | -0.98145
2023Q2 | -0.96542
2023Q3 | -0.23203
2023Q4 | -0.34404
2024Q1 | 1.4606
2024Q2 | 0.901
2024Q3 | 2.4906
2024Q4 | 0.79661
The expression following the ``do`` keyword can be any univariate
equation, the only constraint is that the model cannot have
leads. It can be a static equation, or a very nonlinear backward
equation with an arbitrary number of lags. The ``from`` command
must be followed by a range, which is separated from the
(recursive) expression to be evaluated by the ``do`` command.