2014-04-29 17:56:45 +02:00
\documentclass [10pt] { beamer}
2014-05-06 18:05:14 +02:00
2014-05-26 12:12:44 +02:00
\usepackage { tikz, hyperref, alltt}
2014-04-29 17:56:45 +02:00
\usetikzlibrary { positioning,shapes,shadows,arrows}
2014-05-06 18:05:14 +02:00
\tikzstyle { abstract} =[rectangle, rounded corners, draw=black, anchor=north, fill=blue!10, text centered, minimum height={ height("Gp")+2pt} , minimum width=3cm, font=\footnotesize ]
2014-04-29 17:56:45 +02:00
\definecolor { links} { HTML} { 0000CC}
\hypersetup { colorlinks,linkcolor=,urlcolor=links}
\mode <handout>
{
\usepackage { pgfpages}
\pgfpagesuselayout { 4 on 1} [a4paper,border shrink=3mm,landscape]
\usetheme { CambridgeUS}
\usecolortheme { lily}
}
\mode <beamer>
{
\usetheme { CambridgeUS}
}
\AtBeginSection []
{
\begin { frame}
\frametitle { Outline}
\tableofcontents [currentsection]
\end { frame}
}
\setbeamerfont { frametitle} { family=\rmfamily ,series=\bfseries ,size={ \fontsize { 10} { 10} } }
\setbeamertemplate { frametitle continuation} [from second]
2014-05-06 18:05:14 +02:00
\title { Dynare Time Series \& Reporting}
2014-05-26 12:12:44 +02:00
\author [Houtan Bastani] { Houtan Bastani\newline \href { mailto:houtan@dynare.org} { houtan@dynare.org} }
2014-05-06 18:05:14 +02:00
\institute { CEPREMAP}
\date { 13 June 2014}
2014-04-29 17:56:45 +02:00
2014-05-26 12:12:44 +02:00
\newcommand { \myitem } { \item [$\bullet$] }
2014-04-29 17:56:45 +02:00
\begin { document}
\begin { frame}
\titlepage
\end { frame}
\begin { frame} [t]
\frametitle { Outline}
\tableofcontents
\end { frame}
%
2014-05-06 18:05:14 +02:00
% DATES
2014-04-29 17:56:45 +02:00
%
\section { Time Series}
\subsection { Overview}
\begin { frame} [fragile,t]
\frametitle { Overview}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Provide support for time series (\texttt { dseries} )
\begin { itemize}
\myitem Based on an implementation for handling dates (\texttt { dates} )
\end { itemize}
\myitem Introduced in Dynare 4.4
\myitem Currently only used for reporting, though use will increase with time
(\textit { e.g.,} to be included in new estimation code)
\myitem Compatible with all setups that are supported by Dynare
\begin { itemize}
\myitem Windows, Mac OS X, Linux
\myitem Matlab 7.5 (R2007b) or later, Octave
\end { itemize}
\myitem NB: More complete information is included in the Dynare manual
\end { itemize}
\end { frame}
\subsection { A Programming Note}
\begin { frame} [fragile,t]
\frametitle { A Programming Note (1/2)}
\begin { itemize}
\myitem Time series and dates are implemented as Matlab/Octave classes
\myitem Inplace modification of instantiated objects not supported. Let me explain \dots
\begin { itemize}
\myitem A class is a template for defining objects, defining their member
variables and methods.
\begin { itemize}
\myitem \textit { e.g.,} The \texttt { dates} class defines 3 member
variables--\texttt { ndat} , \texttt { freq} , and \texttt { time} --and many
methods (analogous to functions)
\end { itemize}
\myitem An object is an instance of a specific class. For exemplary
purposes, imagine an object \texttt { X} , which is an instantiation of the
class ``Integer''. The object has value \texttt { 1} :
\begin { verbatim}
>> X
X =
1
\end { verbatim}
\myitem You can call any method defined for the integer class on integer
object \texttt { X} . Imagine such a method is called
\texttt { multiplyByTwo()} .
\myitem In most object-oriented
languages, writing \texttt { X.multiplyByTwo();} will change the value
contained in \texttt { X} to \texttt { 2/2}
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { A Programming Note (2)}
\begin { itemize}
\item [] \begin { itemize}
\myitem But! For Matlab/Octave's implementation of classes this is not the
case as it does not support inplace modification
\begin { verbatim}
>> X.multiplyByTwo()
ans =
2
>> X
X =
1
\end { verbatim}
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { A Programming Note (concluded)}
\begin { itemize}
\item [] \begin { itemize}
\myitem To get the desired change, you must overwrite \texttt { X}
\begin { verbatim}
>> X=X.multiplyByTwo()
X =
2
\end { verbatim}
\myitem Keep this in mind when using Dynare dates, time series, and reporting
\end { itemize}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
\subsection { Syntax}
\begin { frame} [fragile,t]
\frametitle { Syntax}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Two components of a time series:
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem A time component. In Dynare: \texttt { dates}
\myitem A data component mapped to time. In Dynare: \texttt { dseries}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\subsubsection { \texttt { dates} Syntax}
\begin { frame} [fragile,t]
\frametitle { \texttt { dates} Syntax}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem The \texttt { dates} command creates an object that represents at least one date at a given frequency
\myitem A \texttt { dates} object contains 3 members (fields):
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem { \textbf { \texttt { freq} } } : 1 (Annual), 4 (Quarterly), 12 (Monthly), 52 (Weekly)
\myitem { \textbf { \texttt { ndat} } } : The number of dates
\myitem { \textbf { \texttt { time} } } : An \texttt { ndat$ \times $ 2} matrix; the 1\textsuperscript { st} col is the year and the 2\textsuperscript { nd} col is the period
2014-04-29 17:56:45 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Date members cannot be modified. Thus, this is not allowed:
\begin { alltt}
>> dd.freq = 12;
\end { alltt}
\myitem Can index a \texttt { dates} object. If \texttt { t} is a \texttt { dates} object, then
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { t(1) \% refers to the first date}
\myitem \texttt { t(1:3) \% refers to the first three dates}
\myitem \texttt { t([1,4,5]) \% refers to the first, fourth, and fifth dates}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
2014-05-26 12:12:44 +02:00
\frametitle { Creating a new \texttt { dates} object in Matlab/Octave}
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem { A single date}
\begin { alltt}
>> t = dates(`1999y');
\end { alltt}
\myitem { Multiple dates}
\begin { alltt}
>> t = dates(`1999q1', `2020q2', `-190q3');
\end { alltt}
Notice that noncontiguous and negative dates are possible
\myitem { A date range}
\begin { alltt}
>> dr = dates(`1999y'):dates(`2020y');
\end { alltt}
\myitem Can also create \texttt { dates} programatically
\begin { alltt}
>> t = dates(4, [1990; 1990; 1978], [1; 2; 3])
t = <dates: 1990Q1, 1990Q2, 1978Q3>
\end { alltt}
\myitem Can specify an empty \texttt { dates} \dots
\begin { alltt}
>> qq = dates(`Q');
>> qq = dates(4);
\end { alltt}
\myitem \dots and use it to instantiate new \texttt { dates}
\begin { alltt}
>> t = qq(1990, 1);
t = <dates: 1990Q1>
\end { alltt}
\begin { alltt}
>> t = qq([1990; 1990; 1978], [1; 2; 3])
t = <dates: 1990Q1, 1990Q2, 1978Q3>
\end { alltt}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
2014-05-26 12:12:44 +02:00
2014-04-29 17:56:45 +02:00
\begin { frame} [fragile,t]
2014-05-26 12:12:44 +02:00
\frametitle { Creating a new \texttt { dates} object in a \texttt { .mod} file}
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem The preprocessor allows for syntax simplification when
\texttt { dates} are in \texttt { .mod} files
\myitem { A single date} \texttt { t = 1999y;}
\begin { alltt}
\( \Rightarrow \) t = dates(`1999y');
\end { alltt}
\myitem { Multiple dates} \texttt { t = [1999q1 2020q2 1960q3];}
\begin { alltt}
\( \Rightarrow \) t = [dates(`1999q1') dates(`2020q2') dates(`1960q3')];
\end { alltt}
\myitem { A date range} \texttt { dr = 1999y:2020y;}
\begin { alltt}
\( \Rightarrow \) dr = dates(`1999y'):dates(`2020y');
\end { alltt}
\myitem NB: This can cause problems when dates are included in strings. \textit { e.g.,}
\begin { alltt}
disp(`In 1999q1, ...')
\end { alltt}
would be transformed into
\begin { alltt}
disp(`In dates(`1999q1'), ...')
\end { alltt}
\myitem To fix this, simply escape any date that you don't want transformed by the preprocessor with a `\texttt { \$ } '
\begin { alltt}
disp(`In $ 1999 q 1 , ...' )
\end { alltt}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
2014-05-26 12:12:44 +02:00
\frametitle { Collections and Ranges of \texttt { dates} in a \texttt { .mod} file}
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem A collection of \texttt { dates}
\begin { alltt}
a = 1990Q1; b = 1957Q1; c = -52Q1;
d = [a b c];
\( \Rightarrow \) d = <dates: 1990Q1, 1957Q1, -52Q1>
\end { alltt}
\myitem A Range of \texttt { dates}
\begin { alltt}
a = 1990Q3:1991Q2
\( \Rightarrow \) a = <dates: 1990Q3, 1990Q4, 1991Q1, 1991Q2>
\end { alltt}
\myitem A set of regularly-spaced \texttt { dates}
\begin { alltt}
a = 1990Q3:2:1991Q2
\( \Rightarrow \) a = <dates: 1990Q3, 1991Q1, 1991Q3>
\end { alltt}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Comparing \texttt { dates} }
\begin { itemize}
\myitem The following comparison operators are supported: $ = = $ , $ \backsim = $ , $ < $ , $ \leq $ , $ > $ , and $ \geq $
\myitem Compared objects must have the same frequency
\myitem Compared objects must have the same number of elements (except for singletons)
\myitem Returns the result of an element-wise comparison
\myitem Let \texttt { a=[1999W1 2020W3]} , \texttt { b=1999W1} , and \texttt { c=[1888w1 2020w3]} . Then
\begin { alltt}
>> a == b >> a > b >> c < a
ans = ans = ans =
1 0 1
0 1 0
\end { alltt}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Arithmetic Operations on \texttt { dates} }
\begin { itemize}
\myitem The unary \texttt { +} and \texttt { -} operators
\begin { alltt}
>> a = dates(`1999q4');
>> +a \( \Rightarrow \) ans = 2000q1
>> -a \( \Rightarrow \) ans = 1999q3
>> ++-+a \( \Rightarrow \) ans = 2000q2
\end { alltt}
\myitem The binary \texttt { +} and \texttt { -} operators
\begin { itemize}
\myitem Objects must have the same frequency
\myitem Objects must have the same number of elements (except for singletons)
\myitem \texttt { 1999q4 + 2} $ \Rightarrow $ \texttt { ans = 2000q2}
\myitem \texttt { 1999w4 + 2} $ \Rightarrow $ \texttt { ans = 1999w6}
\myitem \texttt { 1999m4 - 2} $ \Rightarrow $ \texttt { ans = 1999m2}
\myitem \texttt { 1999m4 - 1999m2} $ \Rightarrow $ \texttt { ans = 2}
\myitem \texttt { 1999m4 + 1999m2} $ \Rightarrow $ \texttt { ans = <dates: 1999M4, 1999M2>}
\end { itemize}
\myitem The binary \texttt { *} operator
\begin { alltt}
>> a*3
ans = <dates: 1999Q4, 1999Q4, 1999Q4>
\end { alltt}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
2014-05-26 12:12:44 +02:00
2014-04-29 17:56:45 +02:00
\begin { frame} [fragile,t]
2014-05-06 18:05:14 +02:00
\frametitle { Set Operations on \texttt { dates} }
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Let \texttt { a = [1990Q1:1991Q1 1990Q1]; b = [1990Q3:1991Q3];}
\myitem \texttt { intersect} : returns the intersection of the arguments
\begin { alltt}
>> intersect(a, b)
ans = <dates: 1990Q3, 1990Q4, 1991Q1>
\end { alltt}
\myitem \texttt { setdiff} : returns dates present in first arg but not in second
\begin { alltt}
>> setdiff(a, b)
ans = <dates: 1900Y>
\end { alltt}
\myitem \texttt { union} : returns the union of two sets (repititions removed)
\begin { alltt}
union(a, b)
ans = <dates: 1990Q1, 1990Q2, ..., 1991Q2, 1991Q3>
\end { alltt}
\myitem \texttt { unique} : removes repititions from set (keeps last unique value)
\begin { alltt}
>> unique(a)
ans = <dates: 1990Q2, 1990Q3, 1990Q4, 1991Q1, 1990Q1>
\end { alltt}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
2014-05-06 18:05:14 +02:00
2014-05-26 12:12:44 +02:00
2014-05-06 18:05:14 +02:00
%
% DSERIES
%
2014-04-29 17:56:45 +02:00
\subsubsection { \texttt { dseries} Syntax}
2014-05-13 18:30:50 +02:00
\begin { frame} [fragile,t]
\frametitle { \texttt { dseries} Syntax}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem A \texttt { dseries} is composed of one or more individual series
\myitem All time series in a dseries must have the same frequency
\myitem A \texttt { dseries} runs from the earliest date to the latest date, with \texttt { NaN} 's inserted to pad the shorter series
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Creating a new \texttt { dseries} object}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Load series from data file (\texttt { .csv, .xls} ). Dates in first column, optional variable names in first row
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts=dseries(`data.csv');}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Load series from a Matlab/Octave file (\texttt { .m, .mat} ). Must define the variables \texttt { INIT\_ \_ } , \texttt { NAMES\_ \_ } , and, optionally, \texttt { TEX\_ \_ } .
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts=dseries(`data.m');}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Load data directly. Here: one variable, `MyVar1', with three annual observations starting in 1999. Only first argument is required.
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts=dseries([1;2;3], `1999y', \{ `MyVar1'\} , \{ `MyVar\_ 1'\} );}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Create an empty time series. Usefull for programatically creating a series.
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts=dseries();}
\myitem \texttt { ts=dseries(dates(`1999y'));}
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Referencing data from a \texttt { dseries} }
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem For the following, let
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1=dseries([1;2;3], `1999y', \{ `MyVar1'\} , \{ `MyVar\_ 1'\} )}
\myitem \texttt { ts2=dseries([4;5;6], `2000y', \{ `MyVar2'\} , \{ `MyVar\_ 2'\} )}
\myitem \texttt { ts3=[ts1 ts2]}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem To get \texttt { MyVar1} from \texttt { t3} , you have three options
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts3\{ 1\} }
\myitem \texttt { ts3.MyVar1}
\myitem \texttt { ts3\{ `MyVar1'\} }
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem To select a subsample of MyVar2 from 2001 to 2002:
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts3\{ 2\} (dates(`2001y'):dates(`2002y'))}
\myitem \texttt { ts3.MyVar2(dates(`2001y'):dates(`2002y'))}
\myitem \texttt { ts3\{ `MyVar2'\} (dates(`2001y'):dates(`2002y'))}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem To see the data for both variables in 2000:
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts3(`2000y')}
\myitem \texttt { ts3\{ [1 2] \} (`2000y')}
\myitem \texttt { ts3\{ `MyVar1',`MyVar2'\} (`2000y')}
\myitem \texttt { ts3\{ `MyVar@1,2@'\} (`2000y')}
\myitem \texttt { ts3\{ `MyVar[1-2]'\} (`2000y')}
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Getting info about \texttt { dseries} }
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { eq, ne} : returns boolean value of element-wise comparison; series must have same start dates and number of observations
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1==ts3.MyVar1(dates(`1999y'):dates(`2001y')) \% [1 1 1]'}
\myitem \texttt { ts1$ \thicksim $ =ts1 \% [0 0 0]'}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { isempty} : returns true if series is empty
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { isempty(dseries()) \% 1}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { isequal} : returns true if the series are equal
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { isequal(ts1,ts1) \% 1}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { size} : returns number of observations by number of variables
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts3.size() \% [4 2]}
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Working with \texttt { dseries} }
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { baxter\_ king\_ filter} : the Baxter and King (1999) band pass filter
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.baxter\_ king\_ filter(high freq, low freq, K)}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { hpcycle} : HP Filters the \texttt { dseries} , returning the business cycle component
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.hptrend(lambda) \% lambda = 1600 by default}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { hptrend} : HP Filters the \texttt { dseries} , returning the trend component
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.hptrend(lambda) \% lambda = 1600 by default}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { qdiff} : Quarterly difference; works on quarterly, monthly, and weekly series
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.qdiff()}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { qgrowth} : Quarterly growth rate: $ \frac { ts _ t - ts _ { t - 1 } } { ts _ { t - 1 } } $ . Works on quarterly, monthly, and weekly series
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.qgrowth()}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { yidff} : Yearly difference; works on yearly, quarterly, monthly, and weekly series
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.ydiff()}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ygrowth} : Annual growth rate: $ \frac { ts _ t - ts _ { t - 1 } } { ts _ { t - 1 } } $ . Works on yearly ($ t - 1 $ ), quarterly ($ t - 4 $ ), monthly ($ t - 12 $ ), and weekly ($ t - 52 $ ) series
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.ygrowth()}
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Operations on \texttt { dseries} }
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { abs} : The absolute value of each data point
\myitem \texttt { cumprod} /\texttt { cumsum} : Cumulative product/sum
\myitem \texttt { exp} /\texttt { log} : The exponential/log for each data point
\myitem \texttt { mrdivide} /\texttt { mtimes} : Division/Multiplication
\myitem \texttt { minus} /\texttt { plus} : Subtraction/Addition
\myitem \texttt { mpower} : Power
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1-ts2}
\myitem \texttt { ts1-3}
\myitem \texttt { ts1-[1:3]'}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { lag} /\texttt { lead} : lag/lead the series
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1(-1)} /\texttt { ts1(2)}
\myitem \texttt { ts1.lag()} /\texttt { ts1.lead(2)}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { uminus} : Equivalent to multiplying by $ - 1 $ .
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { -ts1}
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame} [fragile,t]
\frametitle { Modifying \texttt { dates} }
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { align} : Makes both series cover the same time range by padding with \texttt { NaN} 's
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { [ts1,ts2]=align(ts1,ts2)}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { chain} :
\myitem \texttt { horzcat} : Join two or more \texttt { dseries}
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts3=[ts1 ts2]}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { insert} : Inserts variables from one \texttt { dseries} into another
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.insert(ts2, 2)}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { merge} : Merge two series
\myitem \texttt { pop} : remove the last variable from \texttt { dseries}
\myitem \texttt { plot} : plot a \texttt { dseries}
\myitem \texttt { rename} : Rename a variable in a dseries
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.rename(`MyVar1',`MyFirstVar')}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { save} : Save a \texttt { dseries} in either \texttt { .csv} (default), \texttt { .m} , or \texttt { .mat}
\myitem \texttt { set\_ names} : Rename all variables in a \texttt { dseries}
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts3.set\_ names(`NewName1',`NewName2')}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { tex\_ rename} : Rename the \LaTeX \ name for a given variable
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { ts1.tex\_ rename(`MyVar1',`MyVar\textbackslash \_ 1')}
2014-05-13 18:30:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { vertcat} : Add more observations to existing \texttt { dseries}
2014-05-13 18:30:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { [ts1; dseries(4,`2002y',`MyVar1')]}
2014-05-13 18:30:50 +02:00
\end { itemize}
\end { itemize}
\end { frame}
2014-04-29 17:56:45 +02:00
\subsection { Examples}
2014-05-14 16:54:58 +02:00
2014-04-29 17:56:45 +02:00
%
% REPORTING
%
\section { Reporting}
\subsection { Overview}
\begin { frame}
\frametitle { Overview}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Introduced in Dynare 4.4
\myitem Introduce reporting functionality to Dynare
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Input: \texttt { dseries}
\myitem Output: \LaTeX \ report \& compiled \texttt { .pdf}
2014-04-29 17:56:45 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Graphs and Tables are modular
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Can easily be included in another document
2014-04-29 17:56:45 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Graphs are produced in Ti$ k $ Z/PGFPlots (standard in a TeX distribution)
2014-04-29 17:56:45 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Scales well
\myitem Formating follows that of enclosing document
2014-04-29 17:56:45 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Dynare provides a subset of the many Ti$ k $ Z options
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem You can easily modify the Ti$ k $ Z graph if the option you want is not in Dynare
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Works with Matlab \& Octave
\myitem Works much faster than similar softawre
\myitem NB: Must install a \LaTeX \ distribution to compile reports
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Windows: MiKTeX \url { http://miktex.org}
\myitem Mac OS X: MacTeX \url { http://tug.org/mactex}
\myitem Linux: TeX Live (from your package manager)
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-04-29 17:56:45 +02:00
\end { itemize}
\end { frame}
2014-05-14 16:54:58 +02:00
\begin { frame}
\frametitle { How Reporting Works}
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Reports are created command by command
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Hence the order of commands matters
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem All reporting commands act on the previously added object until an object of greater or equal hierarchy is added (see next slide)
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textit { e.g.,} Once you add a \texttt { Page} to your report with the \texttt { addPage()} command, every \texttt { Section} you add via the \texttt { addSection()} command will be placed on this page. Only when you add another \texttt { Page} will items go on a new page.
\myitem This will become more clear with an example
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem Options to reporting commands are passed in option name/value pairs
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textit { e.g.,} \texttt { addPage(`title', \{ `Page Title', `Page Subtitle'\} )}
2014-05-14 16:54:58 +02:00
\end { itemize}
\end { itemize}
\end { frame}
2014-04-29 17:56:45 +02:00
\begin { frame}
\frametitle { Reporting Class Hierarchy}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Class names on the top half of the box, constructor names on the bottom
\myitem Arrows represent what the new object can be added to
2014-05-14 16:54:58 +02:00
\end { itemize}
\begin { center}
2014-04-29 17:56:45 +02:00
\begin { tikzpicture} [
node distance = .45cm,
auto,
line/.style={ ->, >=stealth'} ,
]
\node (Report) [abstract, rectangle split, rectangle split parts=2]
{
\textbf { Report}
\nodepart { second} \texttt { report(...);}
} ;
\node (Page) [abstract, rectangle split, rectangle split parts=2, below=of Report]
{
\textbf { Page}
\nodepart { second} \texttt { addPage(...);}
} ;
\node (Section) [abstract, rectangle split, rectangle split parts=2, below=of Page]
{
\textbf { Section}
\nodepart { second} \texttt { addSection(...);}
} ;
\node (Vspace) [abstract, rectangle split, rectangle split parts=2, below=of Section]
{
\textbf { Vspace}
\nodepart { second} \texttt { addVspace(...);}
} ;
\node (Graph) [abstract, rectangle split, rectangle split parts=2, left=of Vspace]
{
\textbf { Graph}
\nodepart { second} \texttt { addGraph(...);}
} ;
\node (Table) [abstract, rectangle split, rectangle split parts=2, right=of Vspace, text height=]
{
\textbf { Table}
\nodepart { second} \texttt { addTable(...);}
} ;
\node (Series) [abstract, rectangle split, rectangle split parts=2, below=of Vspace]
{
\textbf { Series}
\nodepart { second} \texttt { addSeries(...);}
} ;
\draw [line] (Series) to node { } (Table);
\draw [line] (Series) to node { } (Graph);
\draw [line] (Table) to node { } (Section);
\draw [line] (Graph) to node { } (Section);
\draw [line] (Vspace) to node { } (Section);
\draw [line] (Section) to node { } (Page);
\draw [line] (Page) to node { } (Report);
\end { tikzpicture}
2014-05-14 16:54:58 +02:00
\end { center}
2014-04-29 17:56:45 +02:00
\end { frame}
2014-05-14 16:54:58 +02:00
2014-04-29 17:56:45 +02:00
\subsection { Syntax}
2014-05-14 16:54:58 +02:00
\begin { frame}
2014-05-26 12:12:44 +02:00
\frametitle { Reporting Syntax (1/2)}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { report(\ldots )} : Create a report
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { compiler} , \texttt { showDate} , \texttt { fileName} , \texttt { margin} , \texttt { marginUnit} , \texttt { orientation} , \texttt { paper} , \texttt { title}
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { addPage(\ldots )} : Add a page to the \texttt { Report}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { footnote} , \texttt { orientation} , \texttt { paper} , \texttt { title} , \texttt { titleFormat}
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { addSection(\ldots )} : Add a section to the current \texttt { Page}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem You can think of a section as a matrix. As graphs and/or tables are added section, it fills up from left to right. Once you have added \texttt { cols} objects, a new row is started.
\myitem \textbf { Options} : \texttt { cols} , \texttt { height}
2014-05-22 16:40:50 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { addVspace(\ldots )} : Add a vertical space to the current \texttt { Section}
2014-05-22 16:40:50 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { hline} , \texttt { number}
2014-05-14 16:54:58 +02:00
\end { itemize}
\end { itemize}
\end { frame}
2014-04-29 17:56:45 +02:00
2014-05-14 16:54:58 +02:00
\begin { frame}
2014-05-26 12:12:44 +02:00
\frametitle { Reporting Syntax (2/2)}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { addGraph(\ldots )} : Add a graph to the current \texttt { Section}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { data} , \texttt { graphDirName} , \texttt { graphName} , \texttt { graphSize} , \texttt { height} , \texttt { showGrid} , \texttt { showLegend} , \texttt { showLegendBox} , \texttt { legendLocation} , \texttt { legendOrientation} , \texttt { legendFontSize} , \texttt { miscTikzAxisOptions} , \texttt { miscTikzPictureOptions} , \texttt { seriesToUse} , \texttt { shade} , \texttt { shadeColor} , \texttt { shadeOpacity} , \texttt { title} , \texttt { titleFormat} , \texttt { width} , \texttt { xlabel} , \texttt { ylabel} , \texttt { xAxisTight} , \texttt { xrange} , \texttt { xTicks} , \texttt { xTickLabels} , \texttt { xTickLabelAnchor} , \texttt { xTickLabelRotation} , \texttt { yAxisTight} , \texttt { yrange} , \texttt { showZeroLine}
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { addTable(\ldots )} : Add a table to the current \texttt { Section}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { data} , \texttt { showHlines} , \texttt { precision} , \texttt { range} , \texttt { seriesToUse} , \texttt { tableDirName} , \texttt { tableName} , \texttt { title} , \texttt { titleFormat} , \texttt { vlineAfter} , \texttt { vlineAfterEndOfPeriod} , \texttt { showVlines}
2014-05-14 16:54:58 +02:00
\end { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { addSeries(\ldots )} : Add a series to the current \texttt { Graph} or \texttt { Table}
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { data} , \texttt { graphHline} , \texttt { graphLegendName} , \texttt { graphLineColor} , \texttt { graphLineStyle} , \texttt { graphLineWidth} , \texttt { graphMarker} , \texttt { graphMarkerEdgeColor} , \texttt { graphMarkerFaceColor} , \texttt { graphMarkerSize} , \texttt { graphMiscTikzAddPlotOptions} , \texttt { graphShowInLegend} , \texttt { graphVline} , \texttt { tableDataRhs} , \texttt { tableRowColor} , \texttt { tableRowIndent} , \texttt { tableShowMarkers} , \texttt { tableAlignRight} , \texttt { tableMarkerLimit} , \texttt { tableNegColor} , \texttt { tablePosColor} , \texttt { tableSubSectionHeader} , \texttt { zeroTol}
2014-05-14 16:54:58 +02:00
\end { itemize}
\end { itemize}
\end { frame}
\begin { frame}
\frametitle { Output}
To create a report:
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { write()} : Writes the report to a \LaTeX \ file
\myitem \texttt { compile(\ldots )} : Compiles the report
2014-05-14 16:54:58 +02:00
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \textbf { Options} : \texttt { compiler}
2014-05-14 16:54:58 +02:00
\end { itemize}
\end { itemize}
Report Output
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem Unless you pass the \texttt { fileName} option to \texttt { report(\ldots )} , the report will be located in your working directory with the name \texttt { report.tex} . The compiled version will be called \texttt { report.pdf} .
\myitem Unless you pass the \texttt { graphDirName} or \texttt { graphName} options to \texttt { addGraph(\ldots )} , your graphs will be in a subdirectory of your working directory called \texttt { tmpRepDir} . The default name will take the form \texttt { graph\_ pg9\_ sec1\_ row1\_ col5.tex}
\myitem The same holds for the tables (substituting `table' for `graph' above).
\myitem Thus you can easily modify these files and include them in another report.
2014-05-14 16:54:58 +02:00
\end { itemize}
\end { frame}
2014-04-29 17:56:45 +02:00
2014-05-14 16:54:58 +02:00
\subsection { Examples}
2014-05-13 18:30:50 +02:00
\section { Putting it All Together}
2014-05-16 17:12:12 +02:00
\begin { frame} [fragile=singleslide]
\frametitle { Create Report of IRFs from \texttt { example1.mod} }
\begin { itemize}
2014-05-26 12:12:44 +02:00
\myitem \texttt { example1.mod} is located in the Dynare \texttt { examples} directory
\myitem The lines below can be added at the end of that file.
2014-05-16 17:12:12 +02:00
\end { itemize}
\begin { block} { Create \texttt { dseries} from IRFs}
\begin { verbatim}
@#define endovars=["y", "c", "k", "a", "h", "b"]
@#for var in endovars
shocke.@{ var} = dseries(@{ var} _ e, 2014q3, `@{ var} ');
shocku.@{ var} = dseries(@{ var} _ u, 2014q3, `@{ var} ');
@#endfor
\end { verbatim}
\end { block}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Create Report of IRFs from \texttt { example1.mod} }
2014-05-26 12:12:44 +02:00
\begin { block} { Populate Report (1/2)}
2014-05-16 17:12:12 +02:00
\small {
\begin { verbatim}
@#for shock in ["e", "u"]
report = report.addPage(`title', { `Dseries \& Report Example', ...
`Shock to @{ shock} '} , ...
`titleFormat', { `\Large \bfseries ', ...
`\large \bfseries '} );
report = report.addSection(`cols', 2);
@# for var in endovars
report = report.addGraph(`data', shock@{ shock} .@{ var} , ...
`title', `@{ var} ', ...
`showGrid', false, ...
`showZeroLine', true);
@# endfor
2014-05-19 19:14:08 +02:00
\end { verbatim}
}
\end { block}
\end { frame}
\begin { frame} [fragile=singleslide]
\frametitle { Create Report of IRFs from \texttt { example1.mod} }
2014-05-26 12:12:44 +02:00
\begin { block} { Populate Report (2/2)}
2014-05-19 19:14:08 +02:00
\small {
\begin { verbatim}
report = report.addVspace(`number', 2);
2014-05-16 17:12:12 +02:00
report = report.addSection(`cols', 1);
2014-05-19 19:14:08 +02:00
report = report.addTable(`range', dates(`2022q1'):dates(`2024q1'),...
`precision', 5);
2014-05-16 17:12:12 +02:00
@# for var in endovars
report = report.addSeries(`data', shock@{ shock} .@{ var} );
@# endfor
@#endfor
\end { verbatim}
}
\end { block}
\begin { block} { Compile Report}
2014-05-19 19:14:08 +02:00
\small {
2014-05-16 17:12:12 +02:00
\begin { verbatim}
report.write();
report.compile();
\end { verbatim}
2014-05-19 19:14:08 +02:00
}
2014-05-16 17:12:12 +02:00
\end { block}
\end { frame}
2014-04-29 17:56:45 +02:00
\end { document}