createReport.m 13.4 KB
Newer Older
1
function createReport(dc_a, dc_q, db_a, db_q)
2 3 4
%function createReport(dc_a, dc_q, db_a, db_q)
%
% Copyright (C) 2013-2019 Dynare Team
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
%
% 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 <http://www.gnu.org/licenses/>.

tic
larange= dates('2007a'):dates('2014a');
trange = dates('2012q2'):dates('2014q4');
prange = dates('2007q1'):dates('2013q4');
forecast_date = dates('2012q2');
srange = forecast_date:prange(end);

startpoint = strings(prange(1));
shaded = strings(srange(1));
endpoint = strings(prange(end));

shortNames = {'US', 'EU', 'JA', 'EA6', 'LA6', 'RC6'};
longNames  = {'Coca Cola', 'Kinder Bueno', 'Pizza', ...
              'Vegetarianism Is Good', 'OS X', 'Dothraki'};

%% Begin Report
Houtan Bastani's avatar
Houtan Bastani committed
37 38
rep = report('directory', 'my/report/dir', 'title', 'Report Title', ...
    'maketoc', true);
39 40

%% Page 1: GDP
41 42 43 44
rep.addPage('title', 'Jan1 vs Jan2', ...
    'titleFormat', '\large\bfseries');
rep.addSection();
rep.addVspace();
45 46

% Table 1
47 48 49 50
rep.addTable('title', {'Real GDP Growth','subtitle 1', 'subtitle 2'}, ...
    'range', larange, ...
    'vlineAfter', dates('2011y'), ...
    'highlightRows', {'gray!25','white','green!22'});
51
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_', larange);
52
rep.addVspace('number', 2);
53 54

% Table 2
55
rep.addTable('title', 'Potential GDP Growth', 'range', larange, ...
56 57 58 59 60
                   'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_BAR_', larange);


%% Page 2: Headline & Core Inflation
61
rep.addPage('title', 'Jan1 vs Jan2', ...
62
                  'titleFormat', '\large\bfseries');
63 64
rep.addSection();
rep.addVspace();
65 66

% Table 1
67
rep.addTable('title', 'Headline CPI Inflation', 'range', larange, ...
68 69
                   'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_', larange);
70
rep.addVspace('number', 2);
71 72

% Table 2
73
rep.addTable('title', 'Core CPI Inflation', 'range', larange, ...
74 75 76 77 78
                   'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIEX4_', larange);


%% Page 3: Gas & Food Inflation
79
rep.addPage('title', 'Jan1 vs Jan2', ...
80
                  'titleFormat', '\large\bfseries');
81 82
rep.addSection();
rep.addVspace();
83 84

% Table 1
85
rep.addTable('title', 'Gas Inflation', 'range', larange, ...
86 87
                   'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_GAS_', larange);
88
rep.addVspace('number', 2);
89 90

% Table 2
91
rep.addTable('title', 'Food Inflation', 'range', larange, ...
92 93 94 95 96
                   'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_CONSFOOD_', larange);


%% Page 4: i & Output Gap
97
rep.addPage('title', 'Jan1 vs Jan2', ...
98
                  'titleFormat', '\large\bfseries');
99 100
rep.addSection();
rep.addVspace();
101 102

% Table 1
103
rep.addTable('title', 'Nominal Interest Rate', 'range', larange, ...
104 105
                   'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'RS_', larange);
106
rep.addVspace('number', 2);
107 108

% Table 2
109
rep.addTable('title', 'Output Gap', 'range', larange, ...
110
                   'vlineAfter', dates('2011y'), 'tableDirName', 'page4table2');
111
db_a.tex_rename_('Y_WORLD', 'World');
112
rep.addSeries('data', db_a{'Y_WORLD'});
113
delta = db_a{'Y_WORLD'}-dc_a{'Y_WORLD'};
114
delta.tex_rename_('$\Delta$');
115
rep.addSeries('data', delta, ...
116 117 118 119 120 121
                    'tableShowMarkers', true, ...
                    'tableAlignRight', true);
rep = AnnualTable(rep, db_a, dc_a, 'Y_', larange);

%% Country Pages
for i=1:length(shortNames)
122
    rep.addPage('title', {'Jan1 vs Jan2', longNames{i}}, ...
123
                      'titleFormat', {'\large\bfseries', '\large'});
124
    rep.addSection('cols', 5);
125 126
    rep = CountryGraphPage(rep, shortNames{i}, db_q, dc_q, prange, srange);

127
    rep.addPage('title', 'Jan1 vs Jan2', ...
128
                      'titleFormat', '\large\bfseries');
129
    rep.addSection();
130 131 132 133 134 135 136
    rep = CountryTablePage(rep, shortNames{i}, longNames{i}, db_q, dc_q, ...
                           db_a, dc_a, trange, dates('2012q2'));
end

%% Residual Reports
% Countries
for i=1:length(shortNames)
137
    rep.addPage('title', 'Residual Report Jan1 vs Jan2', ...
138
                      'titleFormat', '\large\bfseries');
139
    rep.addSection();
140 141 142 143
    rep = ResidTablePage(rep, shortNames{i}, longNames{i}, db_q, dc_q, trange, dates('2012q2'));
end

% Commodities
144
rep.addPage('title', 'Residual Report Jan1 vs Jan2', ...
145
                  'titleFormat', '\large\bfseries');
146
rep.addSection();
147 148 149 150
rep = CommResidTablePage(rep, db_q, dc_q, trange, dates('2012q2'));

%% Commodities Graphs
%Page 24
151
rep.addPage('title', 'Jan1 vs Jan2', ...
152 153
                  'titleFormat', '\large\bfseries', ...
                  'removeHeaderAndFooter', true);
154
rep.addSection('height', '0.475\textheight');
155

156
rep.addGraph('title', {'World Real Oil Price Index','SUBTITLE'}, ...
157 158 159 160 161
                   'xrange', prange, ...
                   'shade', srange, ...
                   'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
                   'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
                   'xTickLabelRotation', 0);
162
rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
163 164 165 166
                    'graphBar', true, ...
                    'graphBarColor', 'red', ...
                    'graphBarFillColor', 'gray', ...
                    'graphBarWidth', 1);
167
db_q.tex_rename_('LRPOIL_WORLD', 'Oil Price');
168
rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
169 170 171 172 173
                    'graphLineColor', 'blue', ...
                    'graphLineWidth', 1.5, ...
                    'graphMarker', 'triangle*', ...
                    'graphMarkerEdgeColor','black', ...
                    'graphMarkerSize',4);
174
db_q.tex_rename_('LRPOIL_BAR_WORLD', 'Equilibrium Oil Price');
175
rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
176 177 178 179
                    'graphLineColor', 'green', ...
                    'graphLineStyle', 'solid', ...
                    'graphLineWidth', 1.5);

180
rep.addGraph('title', 'World Real Food Price Index', ...
181 182 183 184 185 186 187
                   'xrange', prange, ...
                   'shade', srange, ...
                   'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
                   'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
                   'xTickLabelRotation', 0, ...
                   'showLegend', true, ...
                   'legendAt', [.5,.5]);
188
rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
189 190 191 192
                    'graphBar', true, ...
                    'graphBarColor', 'green', ...
                    'graphBarFillColor', 'yellow', ...
                    'graphBarWidth', 1);
193
db_q.tex_rename_('LRPFOOD_WORLD', 'Food Price');
194
rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
195 196
                    'graphLineColor', 'blue', ...
                    'graphLineWidth', 1.5);
197
db_q.tex_rename_('LRPFOOD_BAR_WORLD', 'Equilibrium Food Price');
198
rep.addSeries('graphVline', dates('2009q2'), ...
199 200 201 202
                    'graphLineColor', 'red', ...
                    'graphLineWidth', 1.5);

% Page 25
203
rep.addPage('title', {'Jan1 vs Jan2', 'World Oil and Food Prices'}, ...
204 205
                  'titleFormat', {'\large\bfseries', '\large'}, ...
                  'setPageNumber', 90);
206 207
rep.addSection('cols', 1);
rep.addParagraph('text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', ...
208 209
                       'cols', 2, ...
                       'heading', '\textbf{My First Paragraph Has Two Columns}');
210

211 212
rep.addSection('cols', 1);
rep.addParagraph('text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\newline', ...
213 214
                       'heading', '\textbf{My Next Paragraphs Only Have One}', ...
                       'indent', false);
215
rep.addParagraph('text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\newline');
216

217
rep.addSection('cols', 2);
218

219
rep.addGraph('title', 'World Real Oil Price', ...
220 221 222 223 224
                   'xrange', prange, ...
                   'shade', srange, ...
                   'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
                   'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
                   'xTickLabelRotation', 0);
225
rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
226 227
                    'graphLineColor', 'blue', ...
                    'graphLineWidth', 1.5);
228
rep.addSeries('data', dc_q{'LRPOIL_WORLD'}, ...
229 230 231 232 233
                    'graphLineColor', 'blue', ...
                    'graphLineStyle', 'dashed', ...
                    'graphLineWidth', 1.5);

srange1 = prange(1):forecast_date;
234
rep.addGraph('title', 'Equilibrium World Real Oil Price', ...
235 236
                   'xrange', prange, ...
                   'shade', srange1);
237
rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
238 239
                    'graphLineColor', 'blue', ...
                    'graphLineWidth', 1.5);
240
rep.addSeries('data', dc_q{'LRPOIL_BAR_WORLD'}, ...
241 242 243 244
                    'graphLineColor', 'blue', ...
                    'graphLineStyle', 'dashed', ...
                    'graphLineWidth', 1.5);

245
rep.addGraph('title', 'World Real Food Price', ...
246 247 248 249 250 251
                   'xrange', prange, ...
                   'shade', srange, ...
                   'xTickLabels','ALL',...
                   'xTickLabelRotation', 45,...
                   'xAxisTight',false,...
                   'yAxisTight',true);
252
rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
253 254
                    'graphLineColor', 'blue', ...
                    'graphLineWidth', 1.5);
255
rep.addSeries('data', dc_q{'LRPFOOD_WORLD'}, ...
256 257 258
                    'graphLineColor', 'blue', ...
                    'graphLineStyle', 'dashed', ...
                    'graphLineWidth', 1.5);
259
rep.addSeries('graphHline', 460, ...
260 261 262
                    'graphLineColor', 'red', ...
                    'graphLineWidth', 1.5);

Houtan Bastani's avatar
Houtan Bastani committed
263
a=dseries([1:200]', '1984q1');
264 265 266
b=dseries([1:200]', '1984q1');
c=dseries([1:200]', '1984q1');
d=dseries([1:200]', '1984q1');
Houtan Bastani's avatar
Houtan Bastani committed
267 268 269
b(dates('2012q2'):dates('2015q2'))=b(dates('2012q2'):dates('2015q2'))+2;
c(dates('2012q2'):dates('2015q2'))=c(dates('2012q2'):dates('2015q2'))+4;
d(dates('2012q2'):dates('2015q2'))=d(dates('2012q2'):dates('2015q2'))+6;
270

271
rep.addGraph('title', 'Equilibrium World Real Food Price', ...
272 273 274 275
                   'xrange', prange, ...
                   'shade', srange, ...
                   'showLegend', true, ...
                   'xTickLabelRotation', 0);
276
rep.addSeries('data', a, ...
277 278 279 280
                    'graphLineColor', 'blue', ...
                    'graphLineWidth', 1.5, ...
                    'graphLegendName', 'baseline', ...
                    'graphMiscTikzAddPlotOptions', 'mark=halfcircle*,color=red');
281
rep.addSeries('data', b, ...
Houtan Bastani's avatar
Houtan Bastani committed
282 283 284 285 286 287
                    'graphLineColor', 'blue', ...
                    'graphLineStyle', 'dashed', ...
                    'graphLineWidth', 1.5, ...
                    'graphLegendName', 'control', ...
                    'graphMiscTikzAddPlotOptions', 'mark=halfcircle*,mark options={rotate=90,scale=3}', ...
                    'graphFanShadeColor', 'red', 'graphFanShadeOpacity', 40);
288
rep.addSeries('data', c, ...
289 290 291 292
                    'graphLineColor', 'blue', ...
                    'graphLineStyle', 'dashed', ...
                    'graphLineWidth', 1.5, ...
                    'graphLegendName', 'control', ...
Houtan Bastani's avatar
Houtan Bastani committed
293
                    'graphFanShadeColor', 'red', 'graphFanShadeOpacity', 30);
294
rep.addSeries('data', d, ...
Houtan Bastani's avatar
Houtan Bastani committed
295 296 297 298 299
                    'graphLineColor', 'blue', ...
                    'graphLineStyle', 'dashed', ...
                    'graphLineWidth', 1.5, ...
                    'graphLegendName', 'control', ...
                    'graphFanShadeColor', 'red', 'graphFanShadeOpacity', 20);
300

Houtan Bastani's avatar
Houtan Bastani committed
301 302 303 304 305 306 307 308 309 310
%% Page 26
rep.addPage('title', {'report\_data test'}, ...
    'titleFormat', {'\large\bfseries', '\large'});
rep.addSection('cols', 1);
rep.addTable('title', {'Table Data 0', 'subtitle 2'});
rep.addData('data', [repmat({'a'},10,1) num2cell(rand(10,6))]);
rep.addVspace();
rep.addSection('cols', 1);
rep.addTable('title', {'Table Data 1', 'subtitle 3'});
rep.addData('data', [repmat({'a'},10,1) repmat({'b'},10,1) num2cell(rand(10,1))], 'column_names', {'Name', '', 'Var2'});
Houtan Bastani's avatar
Houtan Bastani committed
311

312 313 314 315
%% Write & Compile Report
rep.write();
rep.compile();
toc
Houtan Bastani's avatar
Houtan Bastani committed
316
end