reporting.rst
Reporting
Dynare provides a simple interface for creating \text{\LaTeX}
reports, comprised of \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.
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:
