time-shift
Johannes Pfeifer 2013-06-24 21:17:01 +02:00
commit f3415b628b
24 changed files with 786 additions and 22 deletions

40
matlab/@dynSeries/disp.m Normal file
View File

@ -0,0 +1,40 @@
function disp(A)
%@info:
%! @deftypefn {Function File} disp (@var{A})
%! @anchor{@dynSeries/disp}
%! @sp 1
%! Overloads the disp method for the Dynare time series class (@ref{dynSeries}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item A
%! Dynare time series object instantiated by @ref{dynSeries}.
%! @end table
%! @sp 1
%! @strong{Outputs}
%! @sp 1
%! None
%! @end deftypefn
%@eod:
separator = repmat(' | ',A.nobs+1,1);
vspace = ' ';
TABLE = ' ';
for t=1:A.nobs
TABLE = char(TABLE, format(A.time(t)));
end
for i = 1:A.vobs
TABLE = horzcat(TABLE,separator);
tmp = A.name{i};
for t=1:A.nobs
tmp = char(tmp,num2str(A.data(t,i)));
end
TABLE = horzcat(TABLE, tmp);
end
disp(vspace)
disp([inputname(1) ' is a dynSeries object:'])
disp(vspace);
disp(TABLE);
disp(vspace);

View File

@ -0,0 +1,21 @@
function display(A)
%@info:
%! @deftypefn {Function File} display (@var{A})
%! @anchor{@dynSeries/display}
%! @sp 1
%! Overloads the disp method for the Dynare time series class (@ref{dynSeries}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item A
%! Dynare time series object instantiated by @ref{dynSeries}.
%! @end table
%! @sp 1
%! @strong{Outputs}
%! @sp 1
%! None
%! @end deftypefn
%@eod:
disp(A)

View File

@ -28,7 +28,11 @@ end
switch format
case 'm'
fid = fopen([basename, '.m'],'w');
if exist([basename, '.m'],'file')
fid = fopen([basename, '.new', '.m'],'w');
else
fid = fopen([basename, '.m'],'w');
end
fprintf(fid,'%% File created on %s.\n',datestr(now));
fprintf(fid,'\n');
fprintf(fid,'FREQ__ = %s;\n',num2str(A.freq));
@ -66,9 +70,18 @@ switch format
str = [str, A.name{v} ' = A.data(:,' num2str(v) ');' ];
end
eval(str);
save([basename '.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
if exist([basename, '.mat'],'file')
save([basename '.new.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
else
save([basename '.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
end
case 'csv'
fid = fopen([basename, '.csv'],'w');
if exist([basename, '.csv'],'file')
fid = fopen([basename, '.new', '.csv'],'w');
else
fid = fopen([basename, '.csv'],'w');
end
fprintf(fid,', %s', A.name{:});
fprintf(fid,'\n');
for t=1:A.nobs

View File

@ -74,7 +74,7 @@ switch S(1).type
save(A,S(2).subs{:});
S = shiftS(S);
else
save(A);
save(A,inputname(1));
end
case {'size'}
if length(S)==2 && strcmp(S(2).type,'()') && ~isempty(S(2).subs)
@ -122,7 +122,7 @@ switch S(1).type
B.nobs = length(tdx);
B.vobs = A.vobs;
B.freq = A.freq;
B.init = A.init+tdx(1);
B.init = A.init+(tdx(1)-1);
B.time = A.time(tdx,:);
elseif isvector(S(1).subs{1}) && all(isint(S(1).subs{1}))
% Extract a subsample using a vector of integers (observation index).

View File

@ -170,6 +170,23 @@ else
addpath([dynareroot '../mex/matlab/']);
end
% matlab2tikz
if strncmp(computer, 'GLNX', 4) || ~isempty(regexpi(computer, '.*linux.*', 'once'))
if exist('matlab2tikz.m') == 0 && exist('/usr/share/matlab2tikz/matlab2tikz.m') == 2
addpath('/usr/share/matlab2tikz');
end
elseif strncmp(computer, 'MACI', 4) || ~isempty(regexpi(computer, '.*apple.*', 'once'))
if exist([dynareroot '/contrib/matlab2tikz/matlab2tikz.m']) == 2
addpath([dynareroot '/contrib/matlab2tikz']);
elseif exist('/usr/local/share/matlab2tikz/matlab2tikz.m') == 2
addpath('/usr/local/share/matlab2tikz');
end
else
if exist([dynareroot '/contrib/matlab2tikz/matlab2tikz.m']) == 2
addpath([dynareroot '/contrib/matlab2tikz']);
end
end
%% Set mex routine names
mex_status = cell(1,3);
mex_status(1,1) = {'mjdgges'};

View File

@ -518,7 +518,6 @@ else
xparam1 = bayestopt_.p5;
idNaN = isnan(xparam1);
xparam1(idNaN) = bayestopt_.p1(idNaN);
xparam1 = transpose(xparam1);
end
if ~options_.cova_compute

View File

@ -121,7 +121,6 @@ n_varobs = size(options_.varobs,1);
% Set priors over the estimated parameters.
if ~isempty(estim_params_)
[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
if ~isempty(options_.mode_file) && ~options_.mh_posterior_mode_estimation
junk=length(xparam1);
load(options_.mode_file,'xparam1');
@ -129,7 +128,6 @@ if ~isempty(estim_params_)
error([ 'ESTIMATION: the posterior mode file ' options_.mode_file ' has been generated using another specification. Please delete it and recompute the posterior mode.'])
end
end
if any(bayestopt_.pshape > 0)
% Plot prior densities.
if ~options_.nograph && options_.plot_priors
@ -372,14 +370,12 @@ nvx = estim_params_.nvx;
ncx = estim_params_.ncx;
nvn = estim_params_.nvn;
ncn = estim_params_.ncn;
if estim_params_.np,
if estim_params_.np
M.params(estim_params_.param_vals(:,1)) = xparam1(nvx+ncx+nvn+ncn+1:end);
end;
end
[oo_.steady_state, params] = evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
options_.noconstant = 1;
else
options_.noconstant = 0;
end
end

View File

@ -30,6 +30,10 @@ nspred = M.nspred;
if order>1 && options.loglinear
error('The loglinear-option currently only works at order 1')
end
if M.maximum_endo_lead == 0 && order>1
error(['2nd and 3rd order approximation not implemented for purely ' ...
'backward models'])
end
switch(order)
case 1

View File

@ -148,7 +148,12 @@ for t=1:sample_size
PredictionError = bsxfun(@minus,Y(:,t),tmp(mf1,:));
dPredictedObservedMean = bsxfun(@minus,tmp(mf1,:),PredictedObservedMean);
PredictedObservedVariance = bsxfun(@times,dPredictedObservedMean,weights)*dPredictedObservedMean' + H;
lnw = -.5*(const_lik+log(det(PredictedObservedVariance))+sum(PredictionError.*(PredictedObservedVariance\PredictionError),1));
if rcond(PredictedObservedVariance) > 1e-16
lnw = -.5*(const_lik+log(det(PredictedObservedVariance))+sum(PredictionError.*(PredictedObservedVariance\PredictionError),1));
else
LIK = NaN;
return
end
dfac = max(lnw);
wtilde = weights.*exp(lnw-dfac);
lik(t) = log(sum(wtilde))+dfac;
@ -156,8 +161,8 @@ for t=1:sample_size
if (strcmp(DynareOptions.particle.resampling.status,'generic') && neff(weights)<DynareOptions.particle.resampling.neff_threshold*sample_size ) || ...
strcmp(DynareOptions.particle.resampling.status,'systematic')
if pruning
temp = resample([tmp(mf0,:)' tmp_(mf0,:)'],weights,DynareOptions);
StateVectors = temp(:,1:number_of_state_variables)' ;
temp = resample([tmp(mf0,:)' tmp_(mf0,:)'],weights',DynareOptions);
StateVectors = temp(:,1:number_of_state_variables)';
StateVectors_ = temp(:,number_of_state_variables+1:2*number_of_state_variables)';
else
StateVectors = resample(tmp(mf0,:)',weights',DynareOptions)';

View File

@ -46,9 +46,9 @@ if ~exist(o.filename, 'file')
o.write();
end
middle = './';
middle = ' ./';
if exist('OCTAVE_VERSION')
echo = 0;
echo = 1;
else
echo = '-echo';
end

View File

@ -1,4 +1,4 @@
function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,varargin)
Xfunction [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,varargin)
% Nelder-Mead like optimization routine.
% By default, we use standard values for the reflection, the expansion, the contraction and the shrink coefficients (alpha = 1, chi = 2, psi = 1 / 2 and σ = 1 / 2).
% See http://en.wikipedia.org/wiki/Nelder-Mead_method
@ -201,7 +201,9 @@ max_simplex_algo_iterations = 3;
simplex_algo_iterations = 1;
best_point = v(:,1);
best_point_score = fv(1);
convergence = 0;
tooslow = 0;
iter_no_improvement_break = 0;
max_no_improvement_break = 1;
@ -213,6 +215,9 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
if critF <= max(f_tolerance,10*eps(fv(1))) && critX <= max(x_tolerance,10*eps(max(v(:,1))))
convergence = 1;
end
if critX <= x_tolerance^2 && critF>1
tooslow = 1;
end
% Set random reflection and expansion parameters if needed.
if randomize_rho
rho = -log(rand)/lambda_rho;
@ -435,7 +440,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
disp(' ')
end
end
if ((func_count==max_func_calls) || (iter_count==max_iterations) || (iter_no_improvement_break==max_no_improvement_break) || convergence)
if ((func_count==max_func_calls) || (iter_count==max_iterations) || (iter_no_improvement_break==max_no_improvement_break) || convergence || tooslow)
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,DELTA,1,varargin{:});
if func_count==max_func_calls
if verbose
@ -454,6 +459,8 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
max_no_improvements = Inf;% Do not stop until convergence is reached!
continue
end
elseif tooslow
disp(['CONVERGENCE NOT ACHIEVED AFTER ' int2str(simplex_iterations) ' ITERATIONS! IMPROVING TOO SLOWLY!'])
else
disp(['CONVERGENCE ACHIEVED AFTER ' int2str(simplex_iterations) ' ITERATIONS!'])
end

View File

@ -222,12 +222,12 @@ dsge-var/dsgevar_forward_estimated_lambda.o.trs: dsge-var/simul_hybrid.o.trs
# Matlab TRS Files
M_TRS_FILES = $(patsubst %.mod, %.m.trs, $(MODFILES))
M_TRS_FILES += run_block_byte_tests_matlab.m.trs
M_TRS_FILES += run_block_byte_tests_matlab.m.trs run_reporting_test_matlab.m.trs
M_XFAIL_TRS_FILES = $(patsubst %.mod, %.m.trs, $(XFAIL_MODFILES))
# Octave TRS Files
O_TRS_FILES = $(patsubst %.mod, %.o.trs, $(MODFILES))
O_TRS_FILES += run_block_byte_tests_octave.o.trs
O_TRS_FILES += run_block_byte_tests_octave.o.trs run_reporting_test_octave.o.trs
O_XFAIL_TRS_FILES = $(patsubst %.mod, %.o.trs, $(XFAIL_MODFILES))
EXTRA_DIST = \
@ -238,6 +238,18 @@ EXTRA_DIST = \
$(XFAIL_MODFILES) \
run_block_byte_tests_matlab.m \
run_block_byte_tests_octave.m \
run_reporting_test_matlab.m \
run_reporting_test_octave.m \
AnnualTable.m \
CommResidTablePage.m \
CountryGraphPage.m \
CountryTablePage.m \
ResidTablePage.m \
db_a.mat \
db_q.mat \
dc_a.mat \
dc_q.mat \
runDynareReport.m \
homotopy/common.mod \
block_bytecode/ls2003.mod \
fs2000_ssfile_aux.m \
@ -384,6 +396,8 @@ clean-local:
rm -rf block_bytecode/ls2003_tmp*
rm reporting/report.*
rm -f $(shell find -name wsOct) \
$(shell find -name wsMat.mat)

View File

@ -0,0 +1,32 @@
function rep = AnnualTable(rep, db_a, dc_a, seriesRootName, arange)
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
shortNames = {'US', 'EU', 'JA', 'EA6', 'LA6', 'RC6'};
longNames = {'Coca Cola', 'Kinder Bueno', 'Pizza', ...
'Vegetarianism Is Good', 'OS X', 'Dothraki'};
for i=1:length(shortNames)
db_a = db_a.tex_rename([seriesRootName shortNames{i}], longNames{i});
rep = rep.addSeries('data', db_a{[seriesRootName shortNames{i}]});
delta = dc_a{[seriesRootName shortNames{i}]}-db_a{[seriesRootName shortNames{i}]};
delta = delta.tex_rename('$\Delta$');
rep = rep.addSeries('data', delta, ...
'tableShowMarkers', true, ...
'tableAlignRight', true);
end
end

View File

@ -0,0 +1,38 @@
function rep = CommResidTablePage(rep, db_q, dc_q, trange, vline_after)
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
seriesNames = {{'RES_LRPOIL_GAP_WORLD'}, ...
{'RES_LRPOIL_BAR_WORLD'}, ...
{'RES_LRPOIL_G_WORLD'}, ...
{'RES_LRPFOOD_GAP_WORLD'}, ...
{'RES_LRPFOOD_BAR_WORLD'}, ...
{'RES_LRPFOOD_G_WORLD'}};
rep = rep.addTable('title', 'Commodities', ...
'range', trange, ...
'vlineAfter', vline_after);
for i=1:length(seriesNames)
rep = rep.addSeries('data', db_q{seriesNames{i}{1}});
delta = db_q{seriesNames{i}{1}} - dc_q{seriesNames{i}{1}};
delta = delta.tex_rename('$\Delta$');
rep = rep.addSeries('data', delta, ...
'tableShowMarkers', true, ...
'tableAlignRight', true);
end
end

View File

@ -0,0 +1,90 @@
function rep = CountryGraphPage(rep, countryAbbr, db_q, dc_q, prange, srange)
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
rep = rep.addGraph('title', 'Interest Rate', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true);
rep = rep.addSeries('data', db_q{['RS_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{['RS_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'Output Gap', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true);
rep = rep.addSeries('data', db_q{['Y_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{['Y_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'Headline Inflation (y/y)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true);
rep = rep.addSeries('data', db_q{['PCH_PIE4_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{['PCH_PIE4_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'Headline Inflation (q/q)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true);
rep = rep.addSeries('data', db_q{['PCH_PIE_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{['PCH_PIE_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'GDP Growth (q/q)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true);
rep = rep.addSeries('data', db_q{['PCH_GROWTH_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{['PCH_GROWTH_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'Core Inflation (y/y)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true);
rep = rep.addSeries('data', db_q{['PCH_PIEX4_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{['PCH_PIEX4_' countryAbbr]}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
end

View File

@ -0,0 +1,61 @@
function rep = CountryTablePage(rep, countryAbbr, countryName, db_q, dc_q, trange, vline_after)
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
seriesNames = {{'RS_', 'Short Term Interest Rate'}, ...
{'RR_', 'Real Interest Rate'}, ...
{'BLT_','Bank Lending Tightening' }, ...
{'PCH_GROWTH_', 'Real GDP Growth (@q ar)'}, ...
{'PCH_GROWTH4_', '\% y-o-y'}, ...
{'PCH_GROWTH_BAR_', 'Potential GDP Growth (@q ar)'}, ...
{'PCH_GROWTH4_BAR_', '\% y-o-y'}, ...
{'PCH_PIE_', 'Headline CPI Inflation (@q ar)'}, ...
{'PCH_PIE4_', '\% y-o-y'}, ...
{'PCH_PIEX_', 'Core CPI Inflation (@q ar)'}, ...
{'PCH_PIEX4_', '\% y-o-y'}, ...
{'PCH_PIE_GAS_', 'Gas Inflation (@q ar)'}, ...
{'PCH_PIE4_GAS_', '\% y-o-y'}, ...
{'PCH_PIE_CONSFOOD_', 'Food Inflation (@q ar)'}, ...
{'PCH_PIE4_CONSFOOD_', '\% y-o-y'}, ...
{'PCH_DOT_REER_T_', 'REER Depreciation (@q ar)'}, ...
{'PCH_DOT4_REER_T_', '\% y-o-y'}, ...
{'Y_', 'Output Gap'}, ...
{'UNR_', 'Unemployment Rate'}, ...
{'UNR_BAR_', 'NAIRU'}, ...
{'UNR_GAP_', 'Unemployment Gap'}};
otherThree = {'EA6','LA6','RC6'};
notForOtherThree = {'BLT_', 'UNR_', 'UNR_BAR_', 'UNR_GAP_'};
rep = rep.addTable('title', countryName, ...
'range', trange, ...
'vlineAfter', vline_after);
for i=1:length(seriesNames)
if any(strcmp(countryAbbr, otherThree)) && ...
any(strcmp(seriesNames{i}{1}, notForOtherThree))
continue
end
db_q = db_q.tex_rename([seriesNames{i}{1} countryAbbr], seriesNames{i}{2});
rep = rep.addSeries('data', db_q{[seriesNames{i}{1} countryAbbr]});
delta = db_q{[seriesNames{i}{1} countryAbbr]}-dc_q{[seriesNames{i}{1} countryAbbr]};
delta = delta.tex_rename('$\Delta$');
rep = rep.addSeries('data', delta, ...
'tableShowMarkers', true, ...
'tableAlignRight', true);
end
end

View File

@ -0,0 +1,65 @@
function rep = ResidTablePage(rep, countryAbbr, countryName, db_q, dc_q, trange, vline_after)
% Copyright (C) 2011-2013 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 <http://www.gnu.org/licenses/>.
seriesNames = {{'RES_RS_'}, ...
{'RES_RR_BAR_'}, ...
{'RES_BLT_'}, ...
{'RES_BLT_BAR_'}, ...
{'RES_YY_'}, ...
{'RES_Y_'}, ...
{'RES_LGDP_BAR_'}, ...
{'RES_G_'}, ...
{'RES_UNR_GAP_'}, ...
{'RES_UNR_G_'}, ...
{'RES_UNR_BAR_'}, ...
{'RES_RR_DIFF_'}, ...
{'RES_LZ_BAR_'}, ...
{'RES_DOT_LZ_BAR_'}, ...
{'RES_PIETAR_'}, ...
{'RES_PIE_'}, ...
{'RES_PIEX_'}, ...
{'RES_PIE_GAS_'}, ...
{'RES_PIE_CONSFOOD_'}};
otherThree = {'EA6', 'LA6', 'RC6'};
notForOtherThree = {'RES_BLT_', 'RES_BLT_BAR_', 'RES_UNR_GAP_', 'RES_UNR_G_', 'RES_UNR_BAR_'};
notForUS = {'RES_RR_DIFF_', 'RES_LZ_BAR_'};
firstThree = {'US', 'EU', 'JA'};
notForFirstThree = {'RES_DOT_LZ_BAR_', 'RES_PIETAR_'};
rep = rep.addTable('title', countryName, ...
'range', trange, ...
'vlineAfter', vline_after);
for i=1:length(seriesNames)
if (any(strcmp(countryAbbr, otherThree)) && ...
any(strcmp(seriesNames{i}{1}, notForOtherThree))) || ...
(any(strcmp(countryAbbr, 'US')) && any(strcmp(seriesNames{i}{1}, notForUS))) || ...
(any(strcmp(countryAbbr, firstThree)) && any(strcmp(seriesNames{i}{1}, notForFirstThree)))
continue
end
rep = rep.addSeries('data', db_q{[seriesNames{i}{1} countryAbbr]});
delta = db_q{[seriesNames{i}{1} countryAbbr]}-dc_q{[seriesNames{i}{1} countryAbbr]};
delta = delta.tex_rename('$\Delta$');
rep = rep.addSeries('data', delta, ...
'tableShowMarkers', true, ...
'tableAlignRight', true);
end
end

BIN
tests/reporting/db_a.mat Normal file

Binary file not shown.

BIN
tests/reporting/db_q.mat Normal file

Binary file not shown.

BIN
tests/reporting/dc_a.mat Normal file

Binary file not shown.

BIN
tests/reporting/dc_q.mat Normal file

Binary file not shown.

View File

@ -0,0 +1,233 @@
function runDynareReport(dc_a, dc_q, db_a, db_q)
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
larange= dynDate('2007'):dynDate('2014');
arange = dynDate('2012'):dynDate('2014');
trange = dynDate('2012q2'):dynDate('2014q4');
prange = dynDate('2007q1'):dynDate('2013q4');
forecast_date = dynDate('2012q2');
srange = forecast_date:prange(end);
shortNames = {'US', 'EU', 'JA', 'EA6', 'LA6', 'RC6'};
longNames = {'Coca Cola', 'Kinder Bueno', 'Pizza', ...
'Vegetarianism Is Good', 'OS X', 'Dothraki'};
%% Begin Report
rep = report();
%% Page 1: GDP
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = rep.addVspace();
% Table 1
rep = rep.addTable('title', 'Real GDP Growth', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_', larange);
rep = rep.addVspace('number', 2);
% Table 2
rep = rep.addTable('title', 'Potential GDP Growth', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_BAR_', larange);
%% Page 2: Headline & Core Inflation
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = rep.addVspace();
% Table 1
rep = rep.addTable('title', 'Headline CPI Inflation', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_', larange);
rep = rep.addVspace('number', 2);
% Table 2
rep = rep.addTable('title', 'Core CPI Inflation', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIEX4_', larange);
%% Page 3: Gas & Food Inflation
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = rep.addVspace();
% Table 1
rep = rep.addTable('title', 'Gas Inflation', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_GAS_', larange);
rep = rep.addVspace('number', 2);
% Table 2
rep = rep.addTable('title', 'Food Inflation', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_CONSFOOD_', larange);
%% Page 4: i & Output Gap
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = rep.addVspace();
% Table 1
rep = rep.addTable('title', 'Nominal Interest Rate', 'range', larange, ...
'vlineAfter', dynDate('2011'));
rep = AnnualTable(rep, db_a, dc_a, 'RS_', larange);
rep = rep.addVspace('number', 2);
% Table 2
rep = rep.addTable('title', 'Output Gap', 'range', larange, ...
'vlineAfter', dynDate('2011'));
db_a = db_a.tex_rename('Y_WORLD', 'World');
rep = rep.addSeries('data', db_a{'Y_WORLD'});
delta = db_a{'Y_WORLD'}-dc_a{'Y_WORLD'};
delta = delta.tex_rename('$\Delta$');
rep = rep.addSeries('data', delta, ...
'tableShowMarkers', true, ...
'tableAlignRight', true);
rep = AnnualTable(rep, db_a, dc_a, 'Y_', larange);
%% Country Pages
for i=1:length(shortNames)
rep = rep.addPage('title', {'Jan1 vs Jan2', longNames{i}}, ...
'titleFormat', {'\large\bfseries', '\large'});
rep = rep.addSection('cols', 2);
rep = CountryGraphPage(rep, shortNames{i}, db_q, dc_q, prange, srange);
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = CountryTablePage(rep, shortNames{i}, longNames{i}, db_q, dc_q, trange, dynDate('2012q2'));
end
%% Residual Reports
% Countries
for i=1:length(shortNames)
rep = rep.addPage('title', 'Residual Report Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = ResidTablePage(rep, shortNames{i}, longNames{i}, db_q, dc_q, trange, dynDate('2012q2'));
end
% Commodities
rep = rep.addPage('title', 'Residual Report Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection();
rep = CommResidTablePage(rep, db_q, dc_q, trange, dynDate('2012q2'));
%% Commodities Graphs
%Page 1
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
'titleFormat', '\large\bfseries');
rep = rep.addSection('height', '60mm');
rep = rep.addGraph('title', 'World Real Oil Price Index', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true);
db_q = db_q.tex_rename('LRPOIL_WORLD', 'Oil Price');
rep = rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
db_q = db_q.tex_rename('LRPOIL_BAR_WORLD', 'Equilibrium Oil Price');
rep = rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
'graphLineColor', 'g', ...
'graphLineStyle', '-', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'World Real Food Price Index', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true);
db_q = db_q.tex_rename('LRPFOOD_WORLD', 'Food Price');
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
db_q = db_q.tex_rename('LRPFOOD_BAR_WORLD', 'Equilibrium Food Price');
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
'graphLineColor', 'g', ...
'graphLineStyle', '-', ...
'graphLineWidth', 1.5);
% Pae 2
rep = rep.addPage('title', {'Jan1 vs Jan2', 'World Oil and Food Prices'}, ...
'titleFormat', {'\large\bfseries', '\large'});
rep = rep.addSection('cols', 2);
rep = rep.addGraph('title', 'World Real Oil Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true);
rep = rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{'LRPOIL_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'Equilibrium World Real Oil Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true);
rep = rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{'LRPOIL_BAR_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'World Real Food Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true);
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{'LRPFOOD_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
rep = rep.addGraph('title', 'Equilibrium World Real Food Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true);
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineWidth', 1.5);
rep = rep.addSeries('data', dc_q{'LRPFOOD_BAR_WORLD'}, ...
'graphLineColor', 'b', ...
'graphLineStyle', '--', ...
'graphLineWidth', 1.5);
%% Write & Compile Report
rep.write();
rep.compile();
end

View File

@ -0,0 +1,61 @@
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir filesep '..' filesep 'matlab']);
% Test Dynare Version
if ~strcmp(dynare_version(), getenv('DYNARE_VERSION'))
error('Incorrect version of Dynare is being tested')
end
try
% To add default directories
dynare('non_existant_mod_file.mod', 'console');
catch
end
disp('');
disp(['*** TESTING: run_reporting_test_matlab.m ***']);
try
cd([top_test_dir filesep 'reporting']);
load db_a.mat;
load db_q.mat;
load dc_a.mat;
load dc_q.mat;
runDynareReport(dc_a, dc_q, db_a, db_q);
testFailed = false;
catch
testFailed = true;
end
cd(getenv('TOP_TEST_DIR'));
fid = fopen('run_reporting_test_matlab.m.trs', 'w+');
if testFailed
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 1\n');
fprintf(fid,':list-of-failed-tests: run_reporting_test_matlab.m\n');
else
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 0\n');
fprintf(fid,':list-of-passed-tests: run_reporting_test_matlab.m\n');
end
fclose(fid);
exit;

View File

@ -0,0 +1,68 @@
## Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir filesep '..' filesep 'matlab']);
## Test Dynare Version
if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
error("Incorrect version of Dynare is being tested")
endif
## Ask gnuplot to create graphics in text mode
## Note that setenv() was introduced in Octave 3.0.2, for compatibility
## with MATLAB
putenv("GNUTERM", "dumb")
try
## To add default directories
dynare('non_existant_mod_file.mod', 'console');
catch
end
printf("\n*** TESTING: run_reporting_test_octave.m ***\n");
try
cd([top_test_dir filesep 'reporting']);
load db_a.mat;
load db_q.mat;
load dc_a.mat;
load dc_q.mat;
runDynareReport(dc_a, dc_q, db_a, db_q);
testFailed = false;
catch
testFailed = true;
end
cd(getenv('TOP_TEST_DIR'));
fid = fopen('run_reporting_test_octave.o.trs', 'w+');
if testFailed
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 1\n');
fprintf(fid,':list-of-failed-tests: run_reporting_test_octave.m\n');
else
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 0\n');
fprintf(fid,':list-of-passed-tests: run_reporting_test_octave.m\n');
end
fclose(fid);
## Local variables:
## mode: Octave
## End: