Merge branch 'master' of https://github.com/DynareTeam/dynare
commit
834e18c02c
778
doc/dynare.texi
778
doc/dynare.texi
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,81 @@
|
|||
function us = lag(ts,p)
|
||||
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{us} =} lag (@var{ts})
|
||||
%! @anchor{lag}
|
||||
%! @sp 1
|
||||
%! Computes lagged time series.
|
||||
%! @sp 2
|
||||
%! @strong{Inputs}
|
||||
%! @sp 1
|
||||
%! @table @var
|
||||
%! @item ts
|
||||
%! Dynare time series object, instantiated by @ref{dynSeries}
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{Outputs}
|
||||
%! @sp 1
|
||||
%! @table @var
|
||||
%! @item us
|
||||
%! Dynare time series object with transformed data field.
|
||||
%! @end table
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% 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/>.
|
||||
|
||||
% Set default number of lags
|
||||
if nargin<2
|
||||
p = 1;
|
||||
end
|
||||
|
||||
% Copy of ts dynSeries object
|
||||
us = ts;
|
||||
|
||||
% Update data member
|
||||
us.data = [NaN(p,ts.vobs); ts.data(1:end-p,:)];
|
||||
|
||||
for i=1:ts.vobs
|
||||
us.name(i) = {[ 'lag(' ts.name{i} ',' int2str(p) ')']};
|
||||
us.tex(i) = {[ ts.tex{i} '_{-' int2str(p) '}']};
|
||||
end
|
||||
|
||||
%@test:1
|
||||
%$ t = zeros(4,1);
|
||||
%$
|
||||
%$ try
|
||||
%$ data = transpose(0:1:50);
|
||||
%$ ts = dynSeries(data,'1950Q1');
|
||||
%$ a = ts.lag;
|
||||
%$ b = ts.lag.lag;
|
||||
%$ c = lag(ts,2);
|
||||
%$ t(1) = 1;
|
||||
%$ catch
|
||||
%$ t = 0;
|
||||
%$ end
|
||||
%$
|
||||
%$ if length(t)>1
|
||||
%$ DATA = [NaN(1,ts.vobs); transpose(0:1:49)];
|
||||
%$ t(2) = dyn_assert(a.data,DATA,1e-15);
|
||||
%$ DATA = [NaN(2,ts.vobs); transpose(0:1:48)];
|
||||
%$ t(3) = dyn_assert(b.data,DATA,1e-15);
|
||||
%$ t(4) = dyn_assert(b.data,c.data,1e-15);
|
||||
%$ end
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:1b
|
|
@ -66,7 +66,7 @@ switch S(1).type
|
|||
switch S(1).subs
|
||||
case {'data','nobs','vobs','name','tex','freq','time','init'} % Public members.
|
||||
B = builtin('subsref', A, S(1));
|
||||
case {'log','exp','ygrowth','qgrowth','ydiff','qdiff'} % Give "dot access" to public methods.
|
||||
case {'log','exp','ygrowth','qgrowth','ydiff','qdiff','lag'} % Give "dot access" to public methods.
|
||||
B = feval(S(1).subs,A);
|
||||
case {'save'} % Save dynSeries object on disk (default is a csv file).
|
||||
B = NaN;
|
||||
|
|
|
@ -0,0 +1,560 @@
|
|||
function oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,table_title,field_name)
|
||||
%function oo_=display_results_table(xparam1,stdh,M_,estim_params_,bayestopt_,oo_,pnames,table_title,field_name)
|
||||
% Display estimation results on screen and write them to TeX-file
|
||||
%
|
||||
% INPUTS
|
||||
% o xparam1 [double] (p*1) vector of estimate parameters.
|
||||
% o stdh [double] (p*1) vector of estimate parameters.
|
||||
% o M_ Matlab's structure describing the Model (initialized by dynare, see @ref{M_}).
|
||||
% o estim_params_ Matlab's structure describing the estimated_parameters (initialized by dynare, see @ref{estim_params_}).
|
||||
% o options_ Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
|
||||
% o bayestopt_ Matlab's structure describing the priors (initialized by dynare, see @ref{bayesopt_}).
|
||||
% o oo_ Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
|
||||
% o pnames [string] Character Array storing the names for prior distributions
|
||||
% o table_title [string] Title of the Table
|
||||
% o field_name [string] String storing the name of the fields for oo_ where the parameters are stored
|
||||
%
|
||||
% OUTPUTS
|
||||
% o oo_ Matlab's structure gathering the results
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% None.
|
||||
|
||||
% 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/>.
|
||||
|
||||
nvx = estim_params_.nvx; % Variance of the structural innovations (number of parameters).
|
||||
nvn = estim_params_.nvn; % Variance of the measurement innovations (number of parameters).
|
||||
ncx = estim_params_.ncx; % Covariance of the structural innovations (number of parameters).
|
||||
ncn = estim_params_.ncn; % Covariance of the measurement innovations (number of parameters).
|
||||
np = estim_params_.np ; % Number of deep parameters.
|
||||
nx = nvx+nvn+ncx+ncn+np; % Total number of parameters to be estimated.
|
||||
|
||||
disp(' ')
|
||||
disp(['RESULTS FROM ' upper(table_title) ' ESTIMATION'])
|
||||
LaTeXtitle=strrep(table_title,' ','_');
|
||||
tstath = abs(xparam1)./stdh;
|
||||
|
||||
header_width = row_header_width(M_,estim_params_,bayestopt_);
|
||||
if strcmp(field_name,'posterior')
|
||||
tit1 = sprintf('%-*s %7s %8s %7s %4s %6s\n',header_width-2,' ','prior mean', ...
|
||||
'mode','s.d.','prior','pstdev');
|
||||
else
|
||||
tit1 = sprintf('%-*s %10s %7s %6s\n',header_width-2,' ','Estimate','s.d.','t-stat');
|
||||
end
|
||||
if np
|
||||
ip = nvx+nvn+ncx+ncn+1;
|
||||
disp('parameters')
|
||||
disp(tit1)
|
||||
for i=1:np
|
||||
name = bayestopt_.name{ip};
|
||||
if strcmp(field_name,'posterior')
|
||||
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
|
||||
header_width,name, ...
|
||||
bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p2(ip));
|
||||
else
|
||||
fprintf('%-*s %8.4f %7.4f %7.4f \n', ...
|
||||
header_width,name,xparam1(ip),stdh(ip),tstath(ip));
|
||||
end
|
||||
eval(['oo_.' field_name '_mode.parameters.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.' field_name '_std.parameters.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
disp(' ')
|
||||
end
|
||||
if nvx
|
||||
ip = 1;
|
||||
disp('standard deviation of shocks')
|
||||
disp(tit1)
|
||||
for i=1:nvx
|
||||
k = estim_params_.var_exo(i,1);
|
||||
name = deblank(M_.exo_names(k,:));
|
||||
if strcmp(field_name,'posterior')
|
||||
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
|
||||
header_width,name,bayestopt_.p1(ip),xparam1(ip), ...
|
||||
stdh(ip),pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p2(ip));
|
||||
else
|
||||
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip));
|
||||
end
|
||||
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
|
||||
eval(['oo_.' field_name '_mode.shocks_std.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.' field_name '_std.shocks_std.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
disp(' ')
|
||||
end
|
||||
if nvn
|
||||
disp('standard deviation of measurement errors')
|
||||
disp(tit1)
|
||||
ip = nvx+1;
|
||||
for i=1:nvn
|
||||
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
|
||||
if strcmp(field_name,'posterior')
|
||||
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
|
||||
header_width,name,bayestopt_.p1(ip), ...
|
||||
xparam1(ip),stdh(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p2(ip));
|
||||
else
|
||||
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip))
|
||||
end
|
||||
eval(['oo_.' field_name '_mode.measurement_errors_std.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.' field_name '_std.measurement_errors_std.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
disp(' ')
|
||||
end
|
||||
|
||||
if ncx
|
||||
disp('correlation of shocks')
|
||||
disp(tit1)
|
||||
ip = nvx+nvn+1;
|
||||
for i=1:ncx
|
||||
k1 = estim_params_.corrx(i,1);
|
||||
k2 = estim_params_.corrx(i,2);
|
||||
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
|
||||
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
|
||||
if strcmp(field_name,'posterior')
|
||||
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
|
||||
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip));
|
||||
else
|
||||
fprintf('%-*s %8.4f %7.4f %7.4f \n', header_width,name,xparam1(ip),stdh(ip),tstath(ip));
|
||||
end
|
||||
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
|
||||
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
|
||||
eval(['oo_.' field_name '_mode.shocks_corr.' NAME ' = xparam1(ip);']);
|
||||
eval(['oo_.' field_name '_std.shocks_corr.' NAME ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
disp(' ')
|
||||
end
|
||||
|
||||
if ncn
|
||||
disp('correlation of measurement errors')
|
||||
disp(tit1)
|
||||
ip = nvx+nvn+ncx+1;
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
|
||||
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
|
||||
if strcmp(field_name,'posterior')
|
||||
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
|
||||
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip));
|
||||
else
|
||||
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip));
|
||||
end
|
||||
eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']);
|
||||
eval(['oo_.' field_name '_std.measurement_errors_corr.' NAME ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
disp(' ')
|
||||
end
|
||||
|
||||
OutputDirectoryName = CheckPath('Output',M_.dname);
|
||||
|
||||
if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output
|
||||
if np
|
||||
filename = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_1.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (parameters)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior maximization (parameters)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+ncx+ncn+1;
|
||||
for i=1:np
|
||||
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
|
||||
M_.param_names_tex(estim_params_.param_vals(i,1),:),...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
|
||||
bayestopt_.p1(ip),...
|
||||
bayestopt_.p2(ip),...
|
||||
xparam1(ip),...
|
||||
stdh(ip));
|
||||
ip = ip + 1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if nvx
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_2.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of structural shocks)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of structural shocks)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = 1;
|
||||
for i=1:nvx
|
||||
k = estim_params_.var_exo(i,1);
|
||||
fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
|
||||
deblank(M_.exo_names_tex(k,:)),...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
|
||||
bayestopt_.p1(ip),...
|
||||
bayestopt_.p2(ip),...
|
||||
xparam1(ip), ...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if nvn
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_3.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of measurement errors)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of measurement errors)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+1;
|
||||
for i=1:nvn
|
||||
idx = strmatch(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:),M_.endo_names);
|
||||
fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
|
||||
deblank(M_.endo_names_tex(idx,:)), ...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
|
||||
bayestopt_.p1(ip), ...
|
||||
bayestopt_.p2(ip),...
|
||||
xparam1(ip),...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if ncx
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_4.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of structural shocks)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+1;
|
||||
for i=1:ncx
|
||||
k1 = estim_params_.corrx(i,1);
|
||||
k2 = estim_params_.corrx(i,2);
|
||||
fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
|
||||
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
|
||||
bayestopt_.p1(ip), ...
|
||||
bayestopt_.p2(ip), ...
|
||||
xparam1(ip), ...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if ncn
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_5.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of measurement errors)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+ncx+1;
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
|
||||
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p1(ip), ...
|
||||
bayestopt_.p2(ip), ...
|
||||
xparam1(ip), ...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
|
||||
if np
|
||||
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_1.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (parameters)\n']);
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
|
||||
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (parameters)}\n ']);
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':1}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':1}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+ncx+ncn+1;
|
||||
for i=1:np
|
||||
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n',...
|
||||
M_.param_names_tex(estim_params_.param_vals(i,1),:),...
|
||||
xparam1(ip),...
|
||||
stdh(ip),...
|
||||
tstath(ip));
|
||||
ip = ip + 1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if nvx
|
||||
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_2.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (standard deviation of structural shocks)\n']);
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
|
||||
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (standard deviation of structural shocks)}\n ']);
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':2}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':2}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = 1;
|
||||
for i=1:nvx
|
||||
k = estim_params_.var_exo(i,1);
|
||||
fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n'],...
|
||||
deblank(M_.exo_names_tex(k,:)),...
|
||||
xparam1(ip), ...
|
||||
stdh(ip),...
|
||||
tstath(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if nvn
|
||||
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_3.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (standard deviation of measurement errors)\n']);
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
|
||||
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (standard deviation of measurement errors)}\n ']);
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':3}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':3}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+1;
|
||||
for i=1:nvn
|
||||
idx = strmatch(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:),M_.endo_names);
|
||||
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n',...
|
||||
deblank(M_.endo_names_tex(idx,:)), ...
|
||||
xparam1(ip),...
|
||||
stdh(ip),...
|
||||
tstath(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if ncx
|
||||
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_4.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (correlation of structural shocks)\n']);
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
|
||||
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (correlation of structural shocks)}\n ']);
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':4}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':4}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+1;
|
||||
for i=1:ncx
|
||||
k1 = estim_params_.corrx(i,1);
|
||||
k2 = estim_params_.corrx(i,2);
|
||||
fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n'],...
|
||||
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
|
||||
xparam1(ip), ...
|
||||
stdh(ip),...
|
||||
tstath(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if ncn
|
||||
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_5.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (correlation of measurement errors)\n']);
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
|
||||
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (correlation of measurement errors)}\n ']);
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':5}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':5}\\\\\n']);
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+ncx+1;
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n',...
|
||||
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
|
||||
xparam1(ip), ...
|
||||
stdh(ip),...
|
||||
tstath(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
|
||||
end
|
|
@ -523,102 +523,8 @@ if ~options_.cova_compute
|
|||
end
|
||||
|
||||
if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
|
||||
disp(' ')
|
||||
disp('RESULTS FROM POSTERIOR MAXIMIZATION')
|
||||
tstath = zeros(nx,1);
|
||||
for i = 1:nx
|
||||
tstath(i) = abs(xparam1(i))/stdh(i);
|
||||
end
|
||||
|
||||
header_width = row_header_width(M_,estim_params_,bayestopt_);
|
||||
|
||||
tit1 = sprintf('%-*s %7s %8s %7s %6s %4s %6s\n',header_width-2,' ','prior mean', ...
|
||||
'mode','s.d.','t-stat','prior','pstdev');
|
||||
if np
|
||||
ip = nvx+nvn+ncx+ncn+1;
|
||||
disp('parameters')
|
||||
disp(tit1)
|
||||
for i=1:np
|
||||
name = bayestopt_.name{ip};
|
||||
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
|
||||
header_width,name, ...
|
||||
bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p2(ip)));
|
||||
eval(['oo_.posterior_mode.parameters.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.posterior_std.parameters.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if nvx
|
||||
ip = 1;
|
||||
disp('standard deviation of shocks')
|
||||
disp(tit1)
|
||||
for i=1:nvx
|
||||
k = estim_params_.var_exo(i,1);
|
||||
name = deblank(M_.exo_names(k,:));
|
||||
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
|
||||
header_width,name,bayestopt_.p1(ip),xparam1(ip), ...
|
||||
stdh(ip),tstath(ip),pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p2(ip)));
|
||||
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
|
||||
eval(['oo_.posterior_mode.shocks_std.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.posterior_std.shocks_std.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if nvn
|
||||
disp('standard deviation of measurement errors')
|
||||
disp(tit1)
|
||||
ip = nvx+1;
|
||||
for i=1:nvn
|
||||
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
|
||||
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
|
||||
header_width,name,bayestopt_.p1(ip), ...
|
||||
xparam1(ip),stdh(ip),tstath(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p2(ip)));
|
||||
eval(['oo_.posterior_mode.measurement_errors_std.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.posterior_std.measurement_errors_std.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if ncx
|
||||
disp('correlation of shocks')
|
||||
disp(tit1)
|
||||
ip = nvx+nvn+1;
|
||||
for i=1:ncx
|
||||
k1 = estim_params_.corrx(i,1);
|
||||
k2 = estim_params_.corrx(i,2);
|
||||
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
|
||||
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
|
||||
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
|
||||
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip)));
|
||||
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
|
||||
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
|
||||
eval(['oo_.posterior_mode.shocks_corr.' NAME ' = xparam1(ip);']);
|
||||
eval(['oo_.posterior_std.shocks_corr.' NAME ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if ncn
|
||||
disp('correlation of measurement errors')
|
||||
disp(tit1)
|
||||
ip = nvx+nvn+ncx+1;
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
|
||||
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
|
||||
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
|
||||
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip)));
|
||||
eval(['oo_.posterior_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']);
|
||||
eval(['oo_.posterior_std.measurement_errors_corr.' NAME ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
%% display results table and store parameter estimates and standard errors in results
|
||||
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Posterior','posterior');
|
||||
%% Laplace approximation to the marginal log density:
|
||||
if options_.cova_compute
|
||||
estim_params_nbr = size(xparam1,1);
|
||||
|
@ -631,289 +537,11 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
|
|||
disp(' ')
|
||||
end
|
||||
elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
|
||||
disp(' ')
|
||||
disp('RESULTS FROM MAXIMUM LIKELIHOOD')
|
||||
tstath = zeros(nx,1);
|
||||
for i = 1:nx
|
||||
tstath(i) = abs(xparam1(i))/stdh(i);
|
||||
end
|
||||
header_width = row_header_width(M_,estim_params_,bayestopt_);
|
||||
tit1 = sprintf('%-*s %10s %7s %6s\n',header_width-2,' ','Estimate','s.d.','t-stat');
|
||||
if np
|
||||
ip = nvx+nvn+ncx+ncn+1;
|
||||
disp('parameters')
|
||||
disp(tit1)
|
||||
for i=1:np
|
||||
name = bayestopt_.name{ip};
|
||||
disp(sprintf('%-*s %8.4f %7.4f %7.4f', ...
|
||||
header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
|
||||
eval(['oo_.mle_mode.parameters.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.mle_std.parameters.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if nvx
|
||||
ip = 1;
|
||||
disp('standard deviation of shocks')
|
||||
disp(tit1)
|
||||
for i=1:nvx
|
||||
k = estim_params_.var_exo(i,1);
|
||||
name = deblank(M_.exo_names(k,:));
|
||||
disp(sprintf('%-*s %8.4f %7.4f %7.4f',header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
|
||||
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
|
||||
eval(['oo_.mle_mode.shocks_std.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.mle_std.shocks_std.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if nvn
|
||||
disp('standard deviation of measurement errors')
|
||||
disp(tit1)
|
||||
ip = nvx+1;
|
||||
for i=1:nvn
|
||||
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
|
||||
disp(sprintf('%-*s %8.4f %7.4f %7.4f',header_width,name,xparam1(ip),stdh(ip),tstath(ip)))
|
||||
eval(['oo_.mle_mode.measurement_errors_std.' name ' = xparam1(ip);']);
|
||||
eval(['oo_.mle_std.measurement_errors_std.' name ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if ncx
|
||||
disp('correlation of shocks')
|
||||
disp(tit1)
|
||||
ip = nvx+nvn+1;
|
||||
for i=1:ncx
|
||||
k1 = estim_params_.corrx(i,1);
|
||||
k2 = estim_params_.corrx(i,2);
|
||||
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
|
||||
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
|
||||
disp(sprintf('%-*s %8.4f %7.4f %7.4f', header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
|
||||
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
|
||||
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
|
||||
eval(['oo_.mle_mode.shocks_corr.' NAME ' = xparam1(ip);']);
|
||||
eval(['oo_.mle_std.shocks_corr.' NAME ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
if ncn
|
||||
disp('correlation of measurement errors')
|
||||
disp(tit1)
|
||||
ip = nvx+nvn+ncx+1;
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
|
||||
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
|
||||
disp(sprintf('%-*s %8.4f %7.4f %7.4f',header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
|
||||
eval(['oo_.mle_mode.measurement_error_corr.' NAME ' = xparam1(ip);']);
|
||||
eval(['oo_.mle_std.measurement_error_corr.' NAME ' = stdh(ip);']);
|
||||
ip = ip+1;
|
||||
end
|
||||
end
|
||||
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Maximum Likelihood','mle');
|
||||
end
|
||||
|
||||
|
||||
OutputDirectoryName = CheckPath('Output',M_.dname);
|
||||
|
||||
if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output
|
||||
if np
|
||||
filename = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_1.TeX'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (parameters)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior maximization (parameters)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+ncx+ncn+1;
|
||||
for i=1:np
|
||||
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
|
||||
M_.param_names_tex(estim_params_.param_vals(i,1),:),...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
|
||||
bayestopt_.p1(ip),...
|
||||
bayestopt_.p2(ip),...
|
||||
xparam1(ip),...
|
||||
stdh(ip));
|
||||
ip = ip + 1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if nvx
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_2.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of structural shocks)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of structural shocks)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = 1;
|
||||
for i=1:nvx
|
||||
k = estim_params_.var_exo(i,1);
|
||||
fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
|
||||
deblank(M_.exo_names_tex(k,:)),...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
|
||||
bayestopt_.p1(ip),...
|
||||
bayestopt_.p2(ip),...
|
||||
xparam1(ip), ...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if nvn
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_3.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of measurement errors)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of measurement errors)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+1;
|
||||
for i=1:nvn
|
||||
idx = strmatch(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:),M_.endo_names);
|
||||
fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
|
||||
deblank(M_.endo_names_tex(idx,:)), ...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
|
||||
bayestopt_.p1(ip), ...
|
||||
bayestopt_.p2(ip),...
|
||||
xparam1(ip),...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if ncx
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_4.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of structural shocks)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+1;
|
||||
for i=1:ncx
|
||||
k1 = estim_params_.corrx(i,1);
|
||||
k2 = estim_params_.corrx(i,2);
|
||||
fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
|
||||
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
|
||||
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
|
||||
bayestopt_.p1(ip), ...
|
||||
bayestopt_.p2(ip), ...
|
||||
xparam1(ip), ...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
if ncn
|
||||
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_5.TeX'];
|
||||
fidTeX = fopen(TeXfile,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
|
||||
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of measurement errors)\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,' \n');
|
||||
fprintf(fidTeX,'\\begin{center}\n');
|
||||
fprintf(fidTeX,'\\begin{longtabe}{l|lcccc} \n');
|
||||
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||
fprintf(fidTeX,'\\caption{(continued)}\n ');
|
||||
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
|
||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
|
||||
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||
ip = nvx+nvn+ncx+1;
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
|
||||
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
|
||||
pnames(bayestopt_.pshape(ip)+1,:), ...
|
||||
bayestopt_.p1(ip), ...
|
||||
bayestopt_.p2(ip), ...
|
||||
xparam1(ip), ...
|
||||
stdh(ip));
|
||||
ip = ip+1;
|
||||
end
|
||||
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||
fprintf(fidTeX,'\\end{center}\n');
|
||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
end
|
||||
|
||||
if np > 0
|
||||
pindx = estim_params_.param_vals(:,1);
|
||||
save([M_.fname '_params.mat'],'pindx');
|
||||
|
@ -927,9 +555,12 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
|
|||
bayestopt_.lb = bounds(:,1);
|
||||
bayestopt_.ub = bounds(:,2);
|
||||
if any(xparam1 < bounds(:,1)) || any(xparam1 > bounds(:,2))
|
||||
find(xparam1 < bounds(:,1))
|
||||
find(xparam1 > bounds(:,2))
|
||||
error('Mode values are outside prior bounds. Reduce prior_trunc.')
|
||||
outside_bound_vars=bayestopt_.name([find(xparam1 < bounds(:,1)); find(xparam1 > bounds(:,2))],:);
|
||||
disp_string=[outside_bound_vars{1,:}];
|
||||
for ii=2:size(outside_bound_vars,1)
|
||||
disp_string=[disp_string,', ',outside_bound_vars{ii,:}];
|
||||
end
|
||||
error(['Mode value(s) of ', disp_string ,' are outside parameter bounds. Potentially, you should set prior_trunc=0.'])
|
||||
end
|
||||
% runs MCMC
|
||||
if options_.mh_replic
|
||||
|
|
|
@ -163,9 +163,9 @@ for j=1:size(anamendo,1)
|
|||
disp([M_.param_names(estim_params_.param_vals(indsmirnov(jp),1),:),' d-stat = ', num2str(dproba(indsmirnov(jp)),'%1.3f'),' p-value = ', num2str(proba(indsmirnov(jp)),'%1.3f')])
|
||||
end
|
||||
disp(' ');
|
||||
stab_map_1(x0, iy, iyc, 'threshold',pvalue_ks,indsmirnov,xdir,[],['Reduced Form Mapping (Threshold) for ', namendo,' vs. lagged ', namlagendo]);
|
||||
stab_map_2(x0(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir,[],['Reduced Form Mapping (Inside Threshold)for ', namendo,' vs. lagged ', namlagendo])
|
||||
stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir,[],['Reduced Form Mapping (Outside Threshold) for ', namendo,' vs. lagged ', namlagendo])
|
||||
stab_map_1(x0, iy, iyc, 'threshold',pvalue_ks,indsmirnov,xdir,[],['Reduced Form Mapping (Threshold) for ', namendo,' vs. lagged ', namexo]);
|
||||
stab_map_2(x0(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir,[],['Reduced Form Mapping (Inside Threshold)for ', namendo,' vs. lagged ', namexo])
|
||||
stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir,[],['Reduced Form Mapping (Outside Threshold) for ', namendo,' vs. lagged ', namexo])
|
||||
lpmat=x0(iy,:);
|
||||
if nshocks,
|
||||
lpmat0=xx0(iy,:);
|
||||
|
|
|
@ -39,20 +39,6 @@ switch(order)
|
|||
return;
|
||||
end
|
||||
dr.g_1 = g_1;
|
||||
|
||||
dr.ghx = dr.g_1(:,1:nspred);
|
||||
dr.ghu = dr.g_1(:,nspred+1:end);
|
||||
|
||||
if options.loglinear == 1
|
||||
k = find(dr.kstate(:,2) <= M.maximum_endo_lag+1);
|
||||
klag = dr.kstate(k,[1 2]);
|
||||
k1 = dr.order_var;
|
||||
|
||||
dr.ghx = repmat(1./dr.ys(k1),1,size(dr.ghx,2)).*dr.ghx.* ...
|
||||
repmat(dr.ys(k1(klag(:,1)))',size(dr.ghx,1),1);
|
||||
dr.ghu = repmat(1./dr.ys(k1),1,size(dr.ghu,2)).*dr.ghu;
|
||||
end
|
||||
|
||||
case 2
|
||||
[err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options);
|
||||
if err
|
||||
|
@ -62,61 +48,14 @@ switch(order)
|
|||
dr.g_0 = g_0;
|
||||
dr.g_1 = g_1;
|
||||
dr.g_2 = g_2;
|
||||
|
||||
dr.ghx = dr.g_1(:,1:nspred);
|
||||
dr.ghu = dr.g_1(:,nspred+1:end);
|
||||
|
||||
dr.ghs2 = 2*g_0;
|
||||
s0 = 0;
|
||||
s1 = 0;
|
||||
ghxx=zeros(endo_nbr, nspred^2);
|
||||
ghxu=zeros(endo_nbr, nspred*exo_nbr);
|
||||
ghuu=zeros(endo_nbr, exo_nbr^2);
|
||||
for i=1:size(g_2,2)
|
||||
if s0 < nspred && s1 < nspred
|
||||
ghxx(:,s0*nspred+s1+1) = 2*g_2(:,i);
|
||||
if s1 > s0
|
||||
ghxx(:,s1*nspred+s0+1) = 2*g_2(:,i);
|
||||
end
|
||||
elseif s0 < nspred && s1 < nspred+exo_nbr
|
||||
ghxu(:,(s0*exo_nbr+s1-nspred+1)) = 2*g_2(:,i);
|
||||
elseif s0 < nspred+exo_nbr && s1 < nspred+exo_nbr
|
||||
ghuu(:,(s0-nspred)*exo_nbr+s1-nspred +1) = 2*g_2(:,i);
|
||||
if s1 > s0
|
||||
ghuu(:,(s1-nspred)*exo_nbr+s0-nspred+1) = 2*g_2(:,i);
|
||||
end
|
||||
else
|
||||
error('dr1:k_order_perturbation:g_2','Unaccounted columns in g_2');
|
||||
end
|
||||
s1 = s1+1;
|
||||
if s1 == nspred+exo_nbr
|
||||
s0 = s0+1;
|
||||
s1 = s0;
|
||||
end
|
||||
end % for loop
|
||||
dr.ghxx = ghxx;
|
||||
dr.ghxu = ghxu;
|
||||
dr.ghuu = ghuu;
|
||||
case 3
|
||||
if options.pruning
|
||||
if options.pruning
|
||||
[err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr, ...
|
||||
M,options);
|
||||
if err
|
||||
info(1)=9;
|
||||
return;
|
||||
end
|
||||
dr.ghx = derivs.gy;
|
||||
dr.ghu = derivs.gu;
|
||||
dr.ghxx = unfold2(derivs.gyy,nspred);
|
||||
dr.ghxu = derivs.gyu;
|
||||
dr.ghuu = unfold2(derivs.guu,exo_nbr);
|
||||
dr.ghs2 = derivs.gss;
|
||||
dr.ghxxx = unfold3(derivs.gyyy,nspred);
|
||||
dr.ghxxu = unfold21(derivs.gyyu,nspred,exo_nbr);
|
||||
dr.ghxuu = unfold12(derivs.gyuu,nspred,exo_nbr);
|
||||
dr.ghuuu = unfold3(derivs.guuu,exo_nbr);
|
||||
dr.ghxss = derivs.gyss;
|
||||
dr.ghuss = derivs.guss;
|
||||
else
|
||||
[err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr, ...
|
||||
M,options);
|
||||
|
@ -133,7 +72,71 @@ switch(order)
|
|||
error('order > 3 isn''t implemented')
|
||||
end
|
||||
|
||||
% Now fill in dr.ghx, dr.ghu...
|
||||
|
||||
if options.pruning && order == 3
|
||||
dr.ghx = derivs.gy;
|
||||
dr.ghu = derivs.gu;
|
||||
dr.ghxx = unfold2(derivs.gyy,nspred);
|
||||
dr.ghxu = derivs.gyu;
|
||||
dr.ghuu = unfold2(derivs.guu,exo_nbr);
|
||||
dr.ghs2 = derivs.gss;
|
||||
dr.ghxxx = unfold3(derivs.gyyy,nspred);
|
||||
dr.ghxxu = unfold21(derivs.gyyu,nspred,exo_nbr);
|
||||
dr.ghxuu = unfold12(derivs.gyuu,nspred,exo_nbr);
|
||||
dr.ghuuu = unfold3(derivs.guuu,exo_nbr);
|
||||
dr.ghxss = derivs.gyss;
|
||||
dr.ghuss = derivs.guss;
|
||||
else
|
||||
nspred = M.nspred;
|
||||
|
||||
dr.ghx = dr.g_1(:,1:nspred);
|
||||
dr.ghu = dr.g_1(:,nspred+1:end);
|
||||
|
||||
if options.loglinear == 1
|
||||
k = find(dr.kstate(:,2) <= M.maximum_endo_lag+1);
|
||||
klag = dr.kstate(k,[1 2]);
|
||||
k1 = dr.order_var;
|
||||
|
||||
dr.ghx = repmat(1./dr.ys(k1),1,size(dr.ghx,2)).*dr.ghx.* ...
|
||||
repmat(dr.ys(k1(klag(:,1)))',size(dr.ghx,1),1);
|
||||
dr.ghu = repmat(1./dr.ys(k1),1,size(dr.ghu,2)).*dr.ghu;
|
||||
end
|
||||
|
||||
if order > 1
|
||||
dr.ghs2 = 2*g_0;
|
||||
s0 = 0;
|
||||
s1 = 0;
|
||||
ghxx=zeros(endo_nbr, nspred^2);
|
||||
ghxu=zeros(endo_nbr, nspred*exo_nbr);
|
||||
ghuu=zeros(endo_nbr, exo_nbr^2);
|
||||
for i=1:size(g_2,2)
|
||||
if s0 < nspred && s1 < nspred
|
||||
ghxx(:,s0*nspred+s1+1) = 2*g_2(:,i);
|
||||
if s1 > s0
|
||||
ghxx(:,s1*nspred+s0+1) = 2*g_2(:,i);
|
||||
end
|
||||
elseif s0 < nspred && s1 < nspred+exo_nbr
|
||||
ghxu(:,(s0*exo_nbr+s1-nspred+1)) = 2*g_2(:,i);
|
||||
elseif s0 < nspred+exo_nbr && s1 < nspred+exo_nbr
|
||||
ghuu(:,(s0-nspred)*exo_nbr+s1-nspred +1) = 2*g_2(:,i);
|
||||
if s1 > s0
|
||||
ghuu(:,(s1-nspred)*exo_nbr+s0-nspred+1) = 2*g_2(:,i);
|
||||
end
|
||||
else
|
||||
error('dr1:k_order_perturbation:g_2','Unaccounted columns in g_2');
|
||||
end
|
||||
s1 = s1+1;
|
||||
if s1 == nspred+exo_nbr
|
||||
s0 = s0+1;
|
||||
s1 = s0;
|
||||
end
|
||||
end % for loop
|
||||
dr.ghxx = ghxx;
|
||||
dr.ghxu = ghxu;
|
||||
dr.ghuu = ghuu;
|
||||
end
|
||||
end
|
||||
|
||||
function y = unfold2(x,n)
|
||||
y=zeros(size(x,1),n*n);
|
||||
|
|
|
@ -90,7 +90,7 @@ init = dynDate(1);
|
|||
varlist = [];
|
||||
if ~exist('OCTAVE_VERSION')
|
||||
% Under Matlab, save time by using importdata
|
||||
assert(exist(file, 'file'), 'load_csv_file_data: I can''t find file ' file '!');
|
||||
assert(exist(file, 'file') == 2, ['load_csv_file_data: I can''t find file ' file '!']);
|
||||
A = importdata(file, ',', withnames);
|
||||
if withnames && withtime
|
||||
if size(A.textdata, 1) == 1
|
||||
|
|
|
@ -93,7 +93,11 @@ varlist = {};
|
|||
|
||||
if isempty(varlist0)
|
||||
for i=1:length(list_of_variables)
|
||||
if isequal(list_of_variables(i).name,'freq') || isequal(list_of_variables(i).name,'time') || isequal(list_of_variables(i).name,'data') || isequal(list_of_variables(i).name,'varlist')
|
||||
if isequal(list_of_variables(i).name,'freq') || isequal(list_of_variables(i).name,'time') || isequal(list_of_variables(i).name,'data') ...
|
||||
|| isequal(list_of_variables(i).name,'varlist') ...
|
||||
|| isequal(list_of_variables(i).name,'varlist0') ...
|
||||
|| isequal(list_of_variables(i).name,'list_of_variables') ...
|
||||
|| isequal(list_of_variables(i).name,'tex') ...
|
||||
continue
|
||||
end
|
||||
if list_of_variables(i).global || list_of_variables(i).persistent
|
||||
|
|
|
@ -3,7 +3,7 @@ function display(o)
|
|||
% Display a Elements object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [elements] elements object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,9 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page.section.elements';
|
||||
disp(' ');
|
||||
disp([name ' = ']);
|
||||
disp(' ');
|
||||
disp(getElements(o));
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -18,5 +18,5 @@ function n = numElements(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
n = o.objArray.numObjs();
|
||||
n = o.objArray.numObjArray();
|
||||
end
|
|
@ -33,7 +33,7 @@ if ~isempty(o.figname)
|
|||
o.figname);
|
||||
end
|
||||
|
||||
if ~o.seriesElements.numElements()
|
||||
if ~o.seriesElements.numSeriesElements()
|
||||
warning('@graph.crepateGraph: no series to plot, returning');
|
||||
return;
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ end
|
|||
h = figure('visible','off');
|
||||
hold on;
|
||||
box on;
|
||||
if o.grid
|
||||
if o.showGrid
|
||||
grid on;
|
||||
set(gca, 'GridLineStyle', '--');
|
||||
end
|
||||
|
@ -52,7 +52,7 @@ else
|
|||
dd = o.xrange;
|
||||
end
|
||||
|
||||
ne = o.seriesElements.numElements();
|
||||
ne = o.seriesElements.numSeriesElements();
|
||||
line_handles = zeros(ne, 1);
|
||||
for i=1:ne
|
||||
line_handles(i) = o.seriesElements(i).getLine(dd);
|
||||
|
@ -66,7 +66,7 @@ if ~isempty(o.yrange)
|
|||
ylim(o.yrange);
|
||||
end
|
||||
|
||||
if o.zeroline
|
||||
if o.showZeroline
|
||||
a = ylim;
|
||||
if 0 > a(1) && 0 < a(2)
|
||||
lh = line(xlim, [0 0], 'color', 'k', 'LineWidth', 0.25);
|
||||
|
@ -87,24 +87,32 @@ if ~isempty(o.shade)
|
|||
% From ShadePlotForEmpahsis (Matlab Exchange)
|
||||
% use patch bc area doesn't work with matlab2tikz
|
||||
sh = patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], ...
|
||||
[yrange fliplr(yrange)], o.shade_color, ...
|
||||
'facealpha', o.shade_opacity);
|
||||
children =get(gca(), 'children');
|
||||
[yrange fliplr(yrange)], o.shadeColor, ...
|
||||
'facealpha', o.shadeOpacity);
|
||||
children = get(gca, 'children');
|
||||
children = [children(2:end); sh];
|
||||
set(gca(), 'children', children);
|
||||
set(gca, 'children', children);
|
||||
end
|
||||
|
||||
xticks = get(gca, 'XTick');
|
||||
[junk, ix, junk] = intersect(x, xticks);
|
||||
set(gca, 'XTickLabel', xlabels(ix));
|
||||
xTickLabels = cell(1, length(xticks));
|
||||
for i=1:length(xticks)
|
||||
if xticks(i) >= x(1) && ...
|
||||
xticks(i) <= x(end)
|
||||
xTickLabels{i} = xlabels{xticks(i)};
|
||||
else
|
||||
xTickLabels{i} = '';
|
||||
end
|
||||
end
|
||||
set(gca, 'XTickLabel', xTickLabels);
|
||||
|
||||
if o.legend
|
||||
if o.showLegend
|
||||
lh = legend(line_handles, o.seriesElements.getTexNames(), ...
|
||||
'orientation', o.legend_orientation, ...
|
||||
'location', o.legend_location);
|
||||
set(lh, 'FontSize', o.legend_font_size);
|
||||
'orientation', o.legendOrientation, ...
|
||||
'location', o.legendLocation);
|
||||
set(lh, 'FontSize', o.legendFontSize);
|
||||
set(lh, 'interpreter', 'latex');
|
||||
if o.legend_boxoff
|
||||
if ~o.showLegendBox
|
||||
legend('boxoff');
|
||||
end
|
||||
end
|
||||
|
@ -118,12 +126,18 @@ if ~isempty(o.ylabel)
|
|||
end
|
||||
drawnow;
|
||||
|
||||
o.figname = [tempname '.tex'];
|
||||
if isempty(o.figname)
|
||||
o.figname = [tempname '.tex'];
|
||||
end
|
||||
disp(' converting to tex....');
|
||||
matlab2tikz('filename', o.figname, ...
|
||||
'showInfo', false, ...
|
||||
'showWarnings', false, ...
|
||||
'checkForUpdates', false);
|
||||
if exist('OCTAVE_VERSION') && isempty(regexpi(computer, '.*apple.*', 'once'))
|
||||
print(o.figname, '-dtikz');
|
||||
else
|
||||
matlab2tikz('filename', o.figname, ...
|
||||
'showInfo', false, ...
|
||||
'showWarnings', false, ...
|
||||
'checkForUpdates', false);
|
||||
end
|
||||
|
||||
grid off;
|
||||
box off;
|
||||
|
|
|
@ -28,49 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page.section.graph';
|
||||
disp(' ');
|
||||
disp([name '.title = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.title '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.xlabel = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.xlabel '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.ylabel = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.ylabel '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.footnote = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.footnote '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.figname = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.figname '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.config = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.config '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.legend = ']);
|
||||
disp(' ');
|
||||
disp(o.legend);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.shade = ']);
|
||||
disp(' ');
|
||||
disp(o.shade);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.seriesElements = ']);
|
||||
disp(' ');
|
||||
o.seriesElements.getSeriesElements()
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -31,5 +31,5 @@ function lastIndex = end(o, k, n)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(k==1 && n==1, '@graph/end: graph only has one dimension');
|
||||
lastIndex = o.seriesElements.numElements();
|
||||
lastIndex = o.seriesElements.numSeriesElements();
|
||||
end
|
|
@ -33,34 +33,31 @@ function o = graph(varargin)
|
|||
|
||||
o = struct;
|
||||
|
||||
o.config = '';
|
||||
|
||||
o.seriesElements = seriesElements();
|
||||
|
||||
o.title = '';
|
||||
o.ylabel = '';
|
||||
o.xlabel = '';
|
||||
o.footnote = '';
|
||||
|
||||
o.figname = '';
|
||||
o.data = '';
|
||||
o.seriestouse = '';
|
||||
o.seriesToUse = '';
|
||||
o.xrange = '';
|
||||
o.yrange = '';
|
||||
|
||||
o.shade = '';
|
||||
o.shade_color = [0 1 0];
|
||||
o.shade_opacity = .2;
|
||||
o.shadeColor = 'green';
|
||||
o.shadeOpacity = .2;
|
||||
|
||||
o.grid = true;
|
||||
o.showGrid = true;
|
||||
|
||||
o.legend = false;
|
||||
o.legend_boxoff = false;
|
||||
o.legend_location = 'SouthEast';
|
||||
o.legend_orientation = 'horizontal';
|
||||
o.legend_font_size = 8;
|
||||
o.showLegend = false;
|
||||
o.showLegendBox = false;
|
||||
o.legendLocation = 'SouthEast';
|
||||
o.legendOrientation = 'horizontal';
|
||||
o.legendFontSize = 8;
|
||||
|
||||
o.zeroline = false;
|
||||
o.showZeroline = false;
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ...
|
||||
|
@ -73,34 +70,34 @@ elseif nargin > 1
|
|||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@graph.graph: %s is not a recognized option.', field);
|
||||
error('@graph.graph: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
assert(ischar(o.title), '@graph.graph: title must be a string');
|
||||
assert(ischar(o.footnote), '@graph.graph: footnote must be a string');
|
||||
assert(ischar(o.config), '@graph.graph: config file must be a string');
|
||||
assert(ischar(o.xlabel), '@graph.graph: xlabel file must be a string');
|
||||
assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string');
|
||||
assert(ischar(o.figname), '@graph.graph: figname must be a string');
|
||||
assert(islogical(o.grid), '@graph.graph: grid must be either true or false');
|
||||
assert(islogical(o.legend), '@graph.graph: legend must be either true or false');
|
||||
assert(islogical(o.legend_boxoff), '@graph.graph: legend_boxoff must be either true or false');
|
||||
assert(isint(o.legend_font_size), '@graph.graph: legend_font_size must be an integer');
|
||||
assert(islogical(o.zeroline), '@graph.graph: zeroline must be either true or false');
|
||||
assert(isfloat(o.shade_opacity) && length(o.shade_opacity)==1 && ...
|
||||
o.shade_opacity >= 0 && o.shade_opacity <= 1, ...
|
||||
'@graph.graph: o.shade_opacity must be a real in [0 1]');
|
||||
assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false');
|
||||
assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false');
|
||||
assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false');
|
||||
assert(isint(o.legendFontSize), '@graph.graph: legendFontSize must be an integer');
|
||||
assert(islogical(o.showZeroline), '@graph.graph: showZeroline must be either true or false');
|
||||
assert(ischar(o.shadeColor), '@graph.graph: shadeColor must be a string');
|
||||
assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
|
||||
o.shadeOpacity >= 0 && o.shadeOpacity <= 1, ...
|
||||
'@graph.graph: o.shadeOpacity must be a real in [0 1]');
|
||||
valid_legend_locations = ...
|
||||
{'North', 'South', 'East', 'West', ...
|
||||
'NorthEast', 'SouthEast', 'NorthWest', 'SouthWest', ...
|
||||
|
@ -108,12 +105,12 @@ valid_legend_locations = ...
|
|||
'NorthEastOutside', 'SouthEastOutside', 'NorthWestOutside', 'SouthWestOutside', ...
|
||||
'Best', 'BestOutside', ...
|
||||
};
|
||||
assert(any(strcmp(o.legend_location, valid_legend_locations)), ...
|
||||
['@graph.graph: legend_location must be one of ' strjoin(valid_legend_locations, ' ')]);
|
||||
assert(any(strcmp(o.legendLocation, valid_legend_locations)), ...
|
||||
['@graph.graph: legendLocation must be one of ' strjoin(valid_legend_locations, ' ')]);
|
||||
|
||||
valid_legend_orientations = {'vertical', 'horizontal'};
|
||||
assert(any(strcmp(o.legend_orientation, valid_legend_orientations)), ...
|
||||
['@graph.graph: legend_orientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
|
||||
assert(any(strcmp(o.legendOrientation, valid_legend_orientations)), ...
|
||||
['@graph.graph: legendOrientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
|
||||
|
||||
assert(isempty(o.shade) || (isa(o.shade, 'dynDates') && o.shade.ndat >= 2), ...
|
||||
['@graph.graph: shade is specified as a dynDates range, e.g. ' ...
|
||||
|
@ -127,22 +124,22 @@ assert(isempty(o.yrange) || (isfloat(o.yrange) && length(o.yrange) == 2 && ...
|
|||
'the lower bound and upper bound.']);
|
||||
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ['@graph.graph: data must ' ...
|
||||
'be a dynSeries']);
|
||||
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ['@graph.graph: ' ...
|
||||
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
|
||||
'series to use must be a cell array of string(s)']);
|
||||
|
||||
% using o.seriestouse, create series objects and put them in o.seriesElements
|
||||
% using o.seriesToUse, create series objects and put them in o.seriesElements
|
||||
if ~isempty(o.data)
|
||||
if isempty(o.seriestouse)
|
||||
if isempty(o.seriesToUse)
|
||||
for i=1:o.data.vobs
|
||||
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.data.name{i}});
|
||||
end
|
||||
else
|
||||
for i=1:length(o.seriestouse)
|
||||
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
|
||||
for i=1:length(o.seriesToUse)
|
||||
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriesToUse{i}});
|
||||
end
|
||||
end
|
||||
end
|
||||
o = rmfield(o, 'seriestouse');
|
||||
o = rmfield(o, 'seriesToUse');
|
||||
o = rmfield(o, 'data');
|
||||
|
||||
% Create graph object
|
||||
|
|
|
@ -3,7 +3,7 @@ function display(oa)
|
|||
% Display an objArray object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [objArray] objArray object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,8 +28,5 @@ function display(oa)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
disp(' ');
|
||||
disp([inputname(1) '.objs = ']);
|
||||
disp(' ');
|
||||
disp(oa.objs);
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
function no = numObjs(oa)
|
||||
%function no = numObjs(oa)
|
||||
function n = numObjArray(o)
|
||||
%function n = numObjArray(o)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
|
@ -18,5 +18,5 @@ function no = numObjs(oa)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
no = size(oa.objs, 2);
|
||||
n = size(o.objs, 2);
|
||||
end
|
|
@ -3,7 +3,7 @@ function display(o)
|
|||
% Display a Page object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [page] page object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,9 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page';
|
||||
disp(' ');
|
||||
disp([name '.sections = ']);
|
||||
disp(' ');
|
||||
disp(o.sections());
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -32,7 +32,7 @@ function o = page(varargin)
|
|||
o = struct;
|
||||
o.paper = '';
|
||||
o.title = {};
|
||||
o.title_format = {};
|
||||
o.titleFormat = {};
|
||||
o.orientation = '';
|
||||
o.footnote = {};
|
||||
o.sections = sections();
|
||||
|
@ -48,15 +48,16 @@ elseif nargin > 1
|
|||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@page.page: %s is not a recognized option.', field);
|
||||
error('@page.page: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -65,15 +66,15 @@ end
|
|||
if ischar(o.title)
|
||||
o.title = {o.title};
|
||||
end
|
||||
if ischar(o.title_format)
|
||||
o.title_format = {o.title_format};
|
||||
if ischar(o.titleFormat)
|
||||
o.titleFormat = {o.titleFormat};
|
||||
end
|
||||
assert(iscellstr(o.title), ...
|
||||
'@page.page: title must be a cell array of strings');
|
||||
assert(iscellstr(o.title_format), ...
|
||||
'@page.page: title_format must be a cell array of strings');
|
||||
assert(length(o.title)==length(o.title_format), ...
|
||||
'@page.page: title and title_format must be of the same length');
|
||||
assert(iscellstr(o.titleFormat), ...
|
||||
'@page.page: titleFormat must be a cell array of strings');
|
||||
assert(length(o.title)==length(o.titleFormat), ...
|
||||
'@page.page: title and titleFormat must be of the same length');
|
||||
|
||||
valid_paper = {'a4', 'letter'};
|
||||
assert(any(strcmp(o.paper, valid_paper)), ...
|
||||
|
|
|
@ -43,7 +43,7 @@ fprintf(fid,'\n');
|
|||
|
||||
fprintf(fid, '\\begin{tabular}[t]{c}\n');
|
||||
for i=1:length(o.title)
|
||||
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.title_format{i}, o.title{i});
|
||||
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.titleFormat{i}, o.title{i});
|
||||
end
|
||||
|
||||
o.sections.write(fid);
|
||||
|
|
|
@ -3,7 +3,7 @@ function display(o)
|
|||
% Display a Pages object
|
||||
%
|
||||
% INPUTS
|
||||
% ps [pages] pages object
|
||||
% o [pages] pages object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,9 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.pages';
|
||||
disp(' ');
|
||||
disp([name ' = ']);
|
||||
disp(' ');
|
||||
disp(getPages(o));
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -1,6 +1,5 @@
|
|||
function n = numPages(o)
|
||||
% function n = numPages(o)
|
||||
% Sections Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] pages object
|
||||
|
@ -28,5 +27,5 @@ function n = numPages(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
n = o.objArray.numObjs();
|
||||
n = o.objArray.numObjArray();
|
||||
end
|
|
@ -1,9 +1,11 @@
|
|||
function o = compile(o)
|
||||
function o = compile(o, varargin)
|
||||
%function o = compile(o)
|
||||
% Compile Report Object
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% o [report] report object
|
||||
% varargin [char] allows user to change report compiler for a
|
||||
% given run of compile.
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] report object
|
||||
|
@ -28,20 +30,32 @@ function o = compile(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(length(varargin) == 0 || length(varargin) == 2, ...
|
||||
'@report.compile: calling form: compiler, ''/path/to/compiler''.');
|
||||
if length(varargin) == 2
|
||||
assert(ischar(varargin{1}) && strcmp(lower(varargin{1}), 'compiler'), ...
|
||||
'@report.compile: ''compiler'' is the only option.');
|
||||
assert(ischar(varargin{2}), ...
|
||||
'@report.compile: the argument to ''compiler'' must be a char');
|
||||
compiler = varargin{2};
|
||||
else
|
||||
compiler = o.compiler;
|
||||
end
|
||||
|
||||
if ~exist(o.filename, 'file')
|
||||
o.write();
|
||||
end
|
||||
|
||||
compiler = o.compiler;
|
||||
if isempty(compiler)
|
||||
if strcmp(computer, 'MACI') || strcmp(computer, 'MACI64')
|
||||
% Add most likely places for pdflatex to
|
||||
% exist outside of default $PATH
|
||||
if strncmp(computer, 'MACI', 4) || ~isempty(regexpi(computer, '.*apple.*', 'once'))
|
||||
% Add most likely places for pdflatex to exist outside of default $PATH
|
||||
[status, compiler] = ...
|
||||
system(['PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;' ...
|
||||
'which pdflatex'], '-echo');
|
||||
elseif strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64')
|
||||
% need to fill in for Windows
|
||||
error(['@report.compile: On Windows machines, you must explicitly ' ...
|
||||
'provide the ''compiler'' option or set the compiler ' ...
|
||||
'variable in the Report class']);
|
||||
else % gnu/linux
|
||||
[status, compiler] = system('which pdflatex', '-echo');
|
||||
end
|
||||
|
@ -50,7 +64,12 @@ if isempty(compiler)
|
|||
compiler = strtrim(compiler);
|
||||
o.compiler = compiler;
|
||||
end
|
||||
[status output] = system([compiler ' ./' o.filename], '-echo');
|
||||
|
||||
if exist('OCTAVE_VERSION')
|
||||
status = system([compiler ' ./' o.filename], 0);
|
||||
else
|
||||
status = system([compiler ' ./' o.filename], '-echo');
|
||||
end
|
||||
[junk, rfn, junk] = fileparts(o.filename);
|
||||
|
||||
if status ~= 0
|
||||
|
|
|
@ -28,39 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report';
|
||||
disp(' ');
|
||||
disp([name '.title = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.title '''']);
|
||||
|
||||
disp(' ')
|
||||
disp([name '.paper = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.paper '''']);
|
||||
|
||||
disp(' ')
|
||||
disp([name '.orientation = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.orientation '''']);
|
||||
|
||||
disp(' ')
|
||||
disp([name '.filename = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.filename '''']);
|
||||
|
||||
disp(' ')
|
||||
disp([name '.config = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.config '''']);
|
||||
|
||||
disp(' ')
|
||||
disp([name '.numPages() = ']);
|
||||
disp(' ');
|
||||
disp([' ' num2str(numPages(o))]);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.pages = ']);
|
||||
disp(' ');
|
||||
disp(o.pages.getPages());
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -36,11 +36,10 @@ o.title = '';
|
|||
o.orientation = 'portrait';
|
||||
o.paper = 'a4';
|
||||
o.margin = 2.5;
|
||||
o.margin_unit = 'cm';
|
||||
o.marginUnit = 'cm';
|
||||
o.pages = pages();
|
||||
o.filename = 'report.tex';
|
||||
o.config = '';
|
||||
o.showdate = true;
|
||||
o.showDate = true;
|
||||
o.compiler = '';
|
||||
|
||||
if nargin == 1
|
||||
|
@ -54,16 +53,16 @@ elseif nargin > 1
|
|||
'pairs']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@report.report: %s is not a recognized option.', ...
|
||||
field);
|
||||
error('@report.report: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -71,14 +70,13 @@ end
|
|||
% Check options provided by user
|
||||
assert(ischar(o.title), '@report.report: title must be a string');
|
||||
assert(ischar(o.filename), '@report.report: filename must be a string');
|
||||
assert(ischar(o.config), '@report.report: config file must be a string');
|
||||
assert(ischar(o.compiler), '@report.report: compiler file must be a string');
|
||||
assert(islogical(o.showdate), '@report.report: showdate must be either true or false');
|
||||
assert(islogical(o.showDate), '@report.report: showDate must be either true or false');
|
||||
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
|
||||
|
||||
valid_margin_unit = {'cm', 'in'};
|
||||
assert(any(strcmp(o.margin_unit, valid_margin_unit)), ...
|
||||
['@report.report: margin_unit must be one of ' strjoin(valid_margin_unit, ' ')]);
|
||||
assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
|
||||
['@report.report: marginUnit must be one of ' strjoin(valid_margin_unit, ' ')]);
|
||||
|
||||
valid_paper = {'a4', 'letter'};
|
||||
assert(any(strcmp(o.paper, valid_paper)), ...
|
||||
|
|
|
@ -36,16 +36,25 @@ end
|
|||
fprintf(fid, '%% Report Object\n');
|
||||
fprintf(fid, '\\documentclass[11pt]{article}\n');
|
||||
|
||||
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.margin_unit);
|
||||
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.marginUnit);
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid, ',landscape');
|
||||
end
|
||||
fprintf(fid, ']{geometry}\n');
|
||||
fprintf(fid, '\\usepackage{pdflscape, pgf, pgfplots, booktabs}\n');
|
||||
fprintf(fid, '\\usepackage{pdflscape, pgf, booktabs}\n');
|
||||
fprintf(fid, ['\\makeatletter\n' ...
|
||||
'\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n' ...
|
||||
'\\makeatother\n']);
|
||||
if o.showdate
|
||||
|
||||
if exist('OCTAVE_VERSION') && isempty(regexpi(computer, '.*apple.*', 'once'))
|
||||
fprintf(fid, '\\usepackage[T1]{fontenc}\n');
|
||||
fprintf(fid, '\\usepackage[utf8x]{inputenc}\n');
|
||||
fprintf(fid, '\\usepackage{gnuplot-lua-tikz}\n');
|
||||
else
|
||||
fprintf(fid, '\\usepackage{pgfplots}\n');
|
||||
end
|
||||
|
||||
if o.showDate
|
||||
fprintf(fid, '\\usepackage{fancyhdr, datetime}\n');
|
||||
fprintf(fid, '\\newdateformat{reportdate}{\\THEDAY\\ \\shortmonthname\\ \\THEYEAR}\n');
|
||||
fprintf(fid, '\\pagestyle{fancy}\n');
|
||||
|
|
|
@ -3,7 +3,7 @@ function display(o)
|
|||
% Display a Section object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [section] section object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,15 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page.section';
|
||||
|
||||
disp(' ');
|
||||
disp([name '.cols = ']);
|
||||
disp(' ');
|
||||
disp(o.cols);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.elements = ']);
|
||||
disp(' ');
|
||||
disp(o.elements.getElements());
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -36,16 +36,16 @@ elseif nargin > 1
|
|||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@section.section: %s is not a recognized option.', ...
|
||||
field);
|
||||
error('@section.section: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ function display(o)
|
|||
% Display a Sections object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [sections] sections object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,9 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'reports.page';
|
||||
disp(' ');
|
||||
disp([name '.sections = ']);
|
||||
disp(' ');
|
||||
disp(getSections(o));
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
function ns = numSections(ss)
|
||||
% function ns = numSections(ss)
|
||||
function n = numSections(o)
|
||||
% function n = numSections(o)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
|
@ -18,5 +18,5 @@ function ns = numSections(ss)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
ns = ss.objArray.numObjs();
|
||||
n = o.objArray.numObjArray();
|
||||
end
|
|
@ -28,44 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page.section.graph.series';
|
||||
disp(' ');
|
||||
disp([name '.data = ']);
|
||||
disp(' ');
|
||||
display(o.data);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.color = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.color '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.line_style = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.line_style '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.line_width = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.line_width '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.graph_marker = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.graph_marker '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.graph_marker_edge_color = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.graph_marker_edge_color '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.graph_marker_face_color = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.graph_marker_face_color '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.graph_marker_size = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.graph_marker_size '''']);
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -34,28 +34,28 @@ assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ['@series.getLine: must ' .
|
|||
'provide data as a dynSeries']);
|
||||
|
||||
% Line
|
||||
assert(ischar(o.color), '@series.getLine: color must be a string');
|
||||
assert(ischar(o.graphLineColor), '@series.getLine: graphLineColor must be a string');
|
||||
valid_line_style = {'none', '-', '--', ':', '-.'};
|
||||
assert(any(strcmp(o.line_style, valid_line_style)), ...
|
||||
['@series.getLine: line_style must be one of ' strjoin(valid_line_style, ' ')]);
|
||||
assert(isfloat(o.line_width), ['@series.getLine: line_width must be a ' ...
|
||||
assert(any(strcmp(o.graphLineStyle, valid_line_style)), ...
|
||||
['@series.getLine: graphLineStyle must be one of ' strjoin(valid_line_style, ' ')]);
|
||||
assert(isfloat(o.graphLineWidth), ['@series.getLine: graphLineWidth must be a ' ...
|
||||
'positive number']);
|
||||
|
||||
% Graph_Marker
|
||||
valid_graph_marker = {'+', 'o', '*', '.', 'x', 's', 'square', 'd', 'diamond', ...
|
||||
% GraphMarker
|
||||
valid_graphMarker = {'+', 'o', '*', '.', 'x', 's', 'square', 'd', 'diamond', ...
|
||||
'^', 'v', '>', '<', 'p', 'pentagram', 'h', 'hexagram', ...
|
||||
'none'};
|
||||
assert(isempty(o.graph_marker) || any(strcmp(o.graph_marker, valid_graph_marker)), ...
|
||||
['@series.getLine: graph_marker must be one of ' strjoin(valid_graph_marker)]);
|
||||
assert(isempty(o.graphMarker) || any(strcmp(o.graphMarker, valid_graphMarker)), ...
|
||||
['@series.getLine: graphMarker must be one of ' strjoin(valid_graphMarker)]);
|
||||
|
||||
assert(ischar(o.graph_marker_edge_color), '@series.getLine: graph_marker_edge_color must be a string');
|
||||
assert(ischar(o.graph_marker_face_color), '@series.getLine: graph_marker_face_color must be a string');
|
||||
assert(isfloat(o.graph_marker_size), ['@series.getLine: graph_marker_size must be a ' ...
|
||||
assert(ischar(o.graphMarkerEdgeColor), '@series.getLine: graphMarkerEdgeColor must be a string');
|
||||
assert(ischar(o.graphMarkerFaceColor), '@series.getLine: graphMarkerFaceColor must be a string');
|
||||
assert(isfloat(o.graphMarkerSize), ['@series.getLine: graphMarkerSize must be a ' ...
|
||||
'positive number']);
|
||||
|
||||
% Marker & Line
|
||||
assert(~(strcmp(o.line_style, 'none') && isempty(o.graph_marker)), ['@series.getLine: ' ...
|
||||
'you must provide at least one of line_style and graph_marker']);
|
||||
assert(~(strcmp(o.graphLineStyle, 'none') && isempty(o.graphMarker)), ['@series.getLine: ' ...
|
||||
'you must provide at least one of graphLineStyle and graphMarker']);
|
||||
|
||||
% Validate xrange
|
||||
assert(isempty(xrange) || isa(xrange, 'dynDates'));
|
||||
|
@ -70,15 +70,15 @@ end
|
|||
opt = {'XData', 1:length(ds.data)};
|
||||
opt = {opt{:}, 'YData', ds.data};
|
||||
|
||||
opt = {opt{:}, 'Color', o.color};
|
||||
opt = {opt{:}, 'LineStyle', o.line_style};
|
||||
opt = {opt{:}, 'LineWidth', o.line_width};
|
||||
opt = {opt{:}, 'Color', o.graphLineColor};
|
||||
opt = {opt{:}, 'LineStyle', o.graphLineStyle};
|
||||
opt = {opt{:}, 'LineWidth', o.graphLineWidth};
|
||||
|
||||
if ~isempty(o.graph_marker)
|
||||
opt = {opt{:}, 'Marker', o.graph_marker};
|
||||
opt = {opt{:}, 'MarkerSize', o.graph_marker_size};
|
||||
opt = {opt{:}, 'MarkerEdgeColor', o.graph_marker_edge_color};
|
||||
opt = {opt{:}, 'MarkerFaceColor', o.graph_marker_face_color};
|
||||
if ~isempty(o.graphMarker)
|
||||
opt = {opt{:}, 'Marker', o.graphMarker};
|
||||
opt = {opt{:}, 'MarkerSize', o.graphMarkerSize};
|
||||
opt = {opt{:}, 'MarkerEdgeColor', o.graphMarkerEdgeColor};
|
||||
opt = {opt{:}, 'MarkerFaceColor', o.graphMarkerFaceColor};
|
||||
end
|
||||
|
||||
h = line(opt{:});
|
||||
|
|
|
@ -35,20 +35,21 @@ o = struct;
|
|||
|
||||
o.data = '';
|
||||
|
||||
o.color = 'k';
|
||||
o.line_style = '-';
|
||||
o.line_width = 0.5;
|
||||
o.graphLineColor = 'k';
|
||||
o.graphLineStyle = '-';
|
||||
o.graphLineWidth = 0.5;
|
||||
|
||||
o.graph_marker = '';
|
||||
o.graph_marker_edge_color = 'auto';
|
||||
o.graph_marker_face_color = 'auto';
|
||||
o.graph_marker_size = 6;
|
||||
o.graphMarker = '';
|
||||
o.graphMarkerEdgeColor = 'auto';
|
||||
o.graphMarkerFaceColor = 'auto';
|
||||
o.graphMarkerSize = 6;
|
||||
|
||||
o.table_markers = false;
|
||||
o.table_neg_color = 'red';
|
||||
o.table_pos_color = 'blue';
|
||||
o.tableShowMarkers = false;
|
||||
o.tableNegColor = 'red';
|
||||
o.tablePosColor = 'blue';
|
||||
o.tableMarkerLimit = 1e-4;
|
||||
|
||||
o.table_align_right = false;
|
||||
o.tableAlignRight = false;
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'series'),['@series.series: with one arg you ' ...
|
||||
|
@ -61,15 +62,16 @@ elseif nargin > 1
|
|||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@series.series: %s is not a recognized option.', field);
|
||||
error('@series.series: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ function o = write(o, fid, dates, precision)
|
|||
%
|
||||
% INPUTS
|
||||
% o [series] series object
|
||||
% fid [int] file id
|
||||
% dates [dynDates] dates for series slice
|
||||
% precision [float] precision with which to print the data
|
||||
%
|
||||
|
@ -39,42 +40,40 @@ assert(isint(precision));
|
|||
assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ...
|
||||
'@series.write: must provide data as a dynSeries');
|
||||
|
||||
assert(ischar(o.color), '@series.write: color must be a string');
|
||||
assert(ischar(o.table_neg_color), '@series.write: table_neg_color must be a string');
|
||||
assert(ischar(o.table_pos_color), '@series.write: table_pos_color must be a string');
|
||||
assert(islogical(o.table_markers), '@series.write: table_markers must be a string');
|
||||
assert(islogical(o.table_align_right), '@series.write: table_align_right must be a string');
|
||||
assert(ischar(o.tableNegColor), '@series.write: tableNegColor must be a string');
|
||||
assert(ischar(o.tablePosColor), '@series.write: tablePosColor must be a string');
|
||||
assert(islogical(o.tableShowMarkers), '@series.write: tableShowMarkers must be true or false');
|
||||
assert(islogical(o.tableAlignRight), '@series.write: tableAlignRight must be true or false');
|
||||
assert(isfloat(o.tableMarkerLimit), '@series,write: tableMarkerLimit must be a float');
|
||||
|
||||
%% Write Output
|
||||
dataString = ['%.' num2str(precision) 'f'];
|
||||
precision = 10^precision;
|
||||
|
||||
fprintf(fid, '%% Table Row (series)\n');
|
||||
if o.table_align_right
|
||||
if o.tableAlignRight
|
||||
fprintf(fid, '\\multicolumn{1}{r}{');
|
||||
end
|
||||
fprintf(fid, '%s', o.data.tex{:});
|
||||
if o.table_align_right
|
||||
if o.tableAlignRight
|
||||
fprintf(fid, '}');
|
||||
end
|
||||
data = o.data(dates);
|
||||
data = data.data;
|
||||
for i=1:size(data,1)
|
||||
thisCellData = round(data(i)*precision)/precision;
|
||||
|
||||
fprintf(fid, ' &');
|
||||
if o.table_markers
|
||||
if thisCellData < 0
|
||||
fprintf(fid, '\\color{%s}', o.table_neg_color);
|
||||
elseif thisCellData > 0
|
||||
fprintf(fid, '\\color{%s}', o.table_pos_color);
|
||||
if o.tableShowMarkers
|
||||
if data(i) < -o.tableMarkerLimit
|
||||
fprintf(fid, '\\color{%s}', o.tableNegColor);
|
||||
elseif data(i) > o.tableMarkerLimit
|
||||
fprintf(fid, '\\color{%s}', o.tablePosColor);
|
||||
end
|
||||
fprintf(fid, '[');
|
||||
end
|
||||
|
||||
fprintf(fid, dataString, thisCellData);
|
||||
fprintf(fid, dataString, round(data(i)*precision)/precision);
|
||||
|
||||
if o.table_markers
|
||||
if o.tableShowMarkers
|
||||
fprintf(fid, ']');
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
function display(o)
|
||||
%function display(o)
|
||||
% Display a Elements object
|
||||
% Display a seriesElements object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [seriesElements] seriesElements object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,10 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page.section.elements.seriesElement';
|
||||
|
||||
disp(' ');
|
||||
disp([name ' = ']);
|
||||
disp(' ');
|
||||
disp(getSeriesElements(o));
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -18,7 +18,7 @@ function dd = getMaxRange(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
ne = numElements(o);
|
||||
ne = numSeriesElements(o);
|
||||
ddmin = dynDate();
|
||||
ddmax = dynDate();
|
||||
for i=1:ne
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function n = numElements(o)
|
||||
% function n = numElements(o)
|
||||
function n = numSeriesElements(o)
|
||||
% function n = numSeriesElements(o)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
|
@ -18,5 +18,5 @@ function n = numElements(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
n = o.objArray.numObjs();
|
||||
n = o.objArray.numObjArray();
|
||||
end
|
|
@ -3,7 +3,7 @@ function display(o)
|
|||
% Display a Table object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o [table] table object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
|
@ -28,34 +28,5 @@ function display(o)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
name = 'report.page.section.table';
|
||||
disp(' ');
|
||||
disp([name '.title = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.title '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.footnote = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.footnote '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.hlines = ']);
|
||||
disp(' ');
|
||||
disp(o.hlines);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.vlines = ']);
|
||||
disp(' ');
|
||||
disp(o.vlines);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.precision = ']);
|
||||
disp(' ');
|
||||
disp(o.precision);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.seriesElements = ']);
|
||||
disp(' ');
|
||||
o.seriesElements.getSeriesElements()
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -34,16 +34,14 @@ o = struct;
|
|||
o.seriesElements = seriesElements();
|
||||
|
||||
o.title = '';
|
||||
o.title_size = 'large';
|
||||
o.footnote = '';
|
||||
o.titleSize = 'large';
|
||||
|
||||
o.config = '';
|
||||
o.hlines = false;
|
||||
o.vlines = false;
|
||||
o.vline_after = '';
|
||||
o.showHlines = false;
|
||||
o.showVlines = false;
|
||||
o.vlineAfter = '';
|
||||
|
||||
o.data = '';
|
||||
o.seriestouse = '';
|
||||
o.seriesToUse = '';
|
||||
o.range = {};
|
||||
o.precision = 1;
|
||||
|
||||
|
@ -58,57 +56,55 @@ elseif nargin > 1
|
|||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('%s is not a recognized option to the Table constructor.', ...
|
||||
field);
|
||||
error('%s is not a recognized option to the Table constructor.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
assert(ischar(o.title), '@table.table: title must be a string');
|
||||
assert(ischar(o.footnote), '@table.table: footnote must be a string');
|
||||
assert(ischar(o.config), '@table.table: config file must be a string');
|
||||
assert(islogical(o.hlines), '@table.table: hlines must be true or false');
|
||||
assert(islogical(o.vlines), '@table.table: vlines must be true or false');
|
||||
assert(islogical(o.showHlines), '@table.table: showHlines must be true or false');
|
||||
assert(islogical(o.showVlines), '@table.table: showVlines must be true or false');
|
||||
assert(isint(o.precision), '@table.table: precision must be an int');
|
||||
assert(isempty(o.range) || (isa(o.range, 'dynDates') && o.range.ndat >= 2), ...
|
||||
['@table.table: range is specified as a dynDates range, e.g. ' ...
|
||||
'''dynDates(''1999q1''):dynDates(''1999q3'')''.']);
|
||||
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ...
|
||||
'@table.table: data must be a dynSeries');
|
||||
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ...
|
||||
'@table.table: seriestouse must be a cell array of string(s)');
|
||||
assert(isempty(o.vline_after) || isa(o.vline_after, 'dynDate'), ...
|
||||
'@table.table: vline_after must be a dynDate');
|
||||
if o.vlines
|
||||
o.vline_after = '';
|
||||
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
|
||||
'@table.table: seriesToUse must be a cell array of string(s)');
|
||||
assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dynDate'), ...
|
||||
'@table.table: vlineAfter must be a dynDate');
|
||||
if o.showVlines
|
||||
o.vlineAfter = '';
|
||||
end
|
||||
valid_title_sizes = {'Huge', 'huge', 'LARGE', 'Large', 'large', 'normalsize', ...
|
||||
'small', 'footnotesize', 'scriptsize', 'tiny'};
|
||||
assert(any(strcmp(o.title_size, valid_title_sizes)), ...
|
||||
['@table.table: title_size must be one of ' strjoin(valid_title_sizes, ' ')]);
|
||||
assert(any(strcmp(o.titleSize, valid_title_sizes)), ...
|
||||
['@table.table: titleSize must be one of ' strjoin(valid_title_sizes, ' ')]);
|
||||
|
||||
% using o.seriestouse, create series objects and put them in o.seriesElements
|
||||
% using o.seriesToUse, create series objects and put them in o.seriesElements
|
||||
if ~isempty(o.data)
|
||||
if isempty(o.seriestouse)
|
||||
if isempty(o.seriesToUse)
|
||||
for i=1:o.data.vobs
|
||||
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.data.name{i}});
|
||||
end
|
||||
else
|
||||
for i=1:length(o.seriestouse)
|
||||
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
|
||||
for i=1:length(o.seriesToUse)
|
||||
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriesToUse{i}});
|
||||
end
|
||||
end
|
||||
end
|
||||
o = rmfield(o, 'seriestouse');
|
||||
o = rmfield(o, 'seriesToUse');
|
||||
o = rmfield(o, 'data');
|
||||
|
||||
% Create table object
|
||||
|
|
|
@ -30,7 +30,7 @@ function o = write(o, fid)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(fid ~= -1);
|
||||
if ~o.seriesElements.numElements()
|
||||
if ~o.seriesElements.numSeriesElements()
|
||||
warning('@table.write: no series to plot, returning');
|
||||
return;
|
||||
end
|
||||
|
@ -54,12 +54,12 @@ fprintf(fid, '\\setlength{\\tabcolsep}{4pt}\n');
|
|||
fprintf(fid, '\\begin{tabular}{@{}l');
|
||||
|
||||
for i=1:ndates
|
||||
if o.vlines
|
||||
if o.showVlines
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
fprintf(fid, 'r');
|
||||
if ~isempty(o.vline_after)
|
||||
if dates(i) == o.vline_after
|
||||
if ~isempty(o.vlineAfter)
|
||||
if dates(i) == o.vlineAfter
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
end
|
||||
|
@ -67,7 +67,7 @@ end
|
|||
fprintf(fid, '@{}}%%\n');
|
||||
if ~isempty(o.title)
|
||||
fprintf(fid, '\\multicolumn{%d}{c}{\\%s %s}\\\\\n', ...
|
||||
ndates+nlhc, o.title_size, o.title);
|
||||
ndates+nlhc, o.titleSize, o.title);
|
||||
end
|
||||
fprintf(fid, '\\toprule%%\n');
|
||||
|
||||
|
@ -122,9 +122,12 @@ fprintf(fid, '\\\\%%\n');
|
|||
fprintf(fid, '%%\n');
|
||||
|
||||
% Write Table Data
|
||||
ne = o.seriesElements.numElements();
|
||||
ne = o.seriesElements.numSeriesElements();
|
||||
for i=1:ne
|
||||
o.seriesElements(i).write(fid, dates, o.precision);
|
||||
if o.showHlines
|
||||
fprintf(fid, '\\hline\n');
|
||||
end
|
||||
end
|
||||
|
||||
fprintf(fid, '\\bottomrule\n');
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
function display(o)
|
||||
%function display(o)
|
||||
% Display a Vspace object
|
||||
%
|
||||
% INPUTS
|
||||
% o [vspace] vspace object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% 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/>.
|
||||
|
||||
reporting_object_display(o);
|
||||
end
|
|
@ -44,15 +44,16 @@ elseif nargin > 1
|
|||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
optNames = fieldnames(o);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@vspace.vspace: %s is not a recognized option.', field);
|
||||
error('@vspace.vspace: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
function reporting_object_display(o)
|
||||
%function reporting_object_display(o)
|
||||
% Display a Reporting Object
|
||||
% i.e., one of: elements
|
||||
% graph
|
||||
% objArray
|
||||
% page
|
||||
% pages
|
||||
% report
|
||||
% section
|
||||
% sections
|
||||
% series
|
||||
% seriesElements
|
||||
% table
|
||||
% vspace
|
||||
%
|
||||
% INPUTS
|
||||
% o [object] reporting object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% 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/>.
|
||||
|
||||
fprintf('\n%s Object = \n\n', upper(class(o)));
|
||||
fields = fieldnames(o);
|
||||
for i=1:length(fields)
|
||||
fprintf(' %s: ', fields{i});
|
||||
val = o.(fields{i});
|
||||
if iscell(val)
|
||||
fprintf('{');
|
||||
for j=1:length(val)
|
||||
assert(ischar(val{j}));
|
||||
fprintf('''%s''', val{j});
|
||||
if j~=length(val)
|
||||
fprintf(', ');
|
||||
end
|
||||
end
|
||||
fprintf('}');
|
||||
elseif ischar(val)
|
||||
fprintf('''%s''', val);
|
||||
elseif isnumeric(val)
|
||||
fprintf('%s', num2str(val));
|
||||
elseif islogical(val)
|
||||
if val
|
||||
fprintf('true');
|
||||
else
|
||||
fprintf('false');
|
||||
end
|
||||
elseif isobject(val)
|
||||
if isa(val, 'dynDates')
|
||||
fprintf('<dynDates: %s, ..., %s>', ...
|
||||
val(1).format, val(end).format);
|
||||
elseif isa(val, 'dynSeries')
|
||||
if numel(val) == 1
|
||||
fprintf('<dynSeries: %s>', val.name{1});
|
||||
else
|
||||
fprintf('%s', class(val));
|
||||
end
|
||||
else
|
||||
cl = class(val);
|
||||
fprintf('%d', val.(['num' upper(cl(1)) cl(2:end)]));
|
||||
end
|
||||
else
|
||||
keyboard
|
||||
fprintf('fix this');
|
||||
end
|
||||
fprintf('\n');
|
||||
end
|
||||
fprintf('\n');
|
||||
end
|
|
@ -47,7 +47,7 @@ if options_.order == 3
|
|||
options_.k_order_solver = 1;
|
||||
end
|
||||
|
||||
if ~options_.k_order_solver
|
||||
if ~options_.k_order_solver || (options_.k_order_solver && options_.pruning) %if k_order_pert is not used or if we do not use Dynare++ with k_order_pert
|
||||
if iorder==1
|
||||
y_(:,1) = y_(:,1)-dr.ys;
|
||||
end
|
||||
|
|
|
@ -3924,29 +3924,29 @@ DynamicModel::writeLatexFile(const string &basename) const
|
|||
void
|
||||
DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model)
|
||||
{
|
||||
substituteLeadLagInternal(avEndoLead, deterministic_model);
|
||||
substituteLeadLagInternal(avEndoLead, deterministic_model, vector<string>());
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteEndoLagGreaterThanTwo(bool deterministic_model)
|
||||
{
|
||||
substituteLeadLagInternal(avEndoLag, deterministic_model);
|
||||
substituteLeadLagInternal(avEndoLag, deterministic_model, vector<string>());
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteExoLead(bool deterministic_model)
|
||||
{
|
||||
substituteLeadLagInternal(avExoLead, deterministic_model);
|
||||
substituteLeadLagInternal(avExoLead, deterministic_model, vector<string>());
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteExoLag(bool deterministic_model)
|
||||
{
|
||||
substituteLeadLagInternal(avExoLag, deterministic_model);
|
||||
substituteLeadLagInternal(avExoLag, deterministic_model, vector<string>());
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model)
|
||||
DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model, const vector<string> &subset)
|
||||
{
|
||||
ExprNode::subst_table_t subst_table;
|
||||
vector<BinaryOpNode *> neweqs;
|
||||
|
@ -3976,7 +3976,7 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model
|
|||
subst = value->substituteExoLag(subst_table, neweqs);
|
||||
break;
|
||||
case avDiffForward:
|
||||
subst = value->differentiateForwardVars(subst_table, neweqs);
|
||||
subst = value->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
break;
|
||||
default:
|
||||
cerr << "DynamicModel::substituteLeadLagInternal: impossible case" << endl;
|
||||
|
@ -4004,7 +4004,7 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model
|
|||
subst = equations[i]->substituteExoLag(subst_table, neweqs);
|
||||
break;
|
||||
case avDiffForward:
|
||||
subst = equations[i]->differentiateForwardVars(subst_table, neweqs);
|
||||
subst = equations[i]->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
break;
|
||||
default:
|
||||
cerr << "DynamicModel::substituteLeadLagInternal: impossible case" << endl;
|
||||
|
@ -4134,9 +4134,9 @@ DynamicModel::removeTrendVariableFromEquations()
|
|||
}
|
||||
|
||||
void
|
||||
DynamicModel::differentiateForwardVars()
|
||||
DynamicModel::differentiateForwardVars(const vector<string> &subset)
|
||||
{
|
||||
substituteLeadLagInternal(avDiffForward, true);
|
||||
substituteLeadLagInternal(avDiffForward, true, subset);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -139,8 +139,11 @@ private:
|
|||
void collectBlockVariables();
|
||||
|
||||
//! Factorized code for substitutions of leads/lags
|
||||
/*! \param[in] type determines which type of variables is concerned */
|
||||
void substituteLeadLagInternal(aux_var_t type, bool deterministic_model);
|
||||
/*! \param[in] type determines which type of variables is concerned
|
||||
\param[in] deterministic_model whether we are in a deterministic model (only for exogenous leads/lags)
|
||||
\param[in] subset variables to which to apply the transformation (only for diff of forward vars)
|
||||
*/
|
||||
void substituteLeadLagInternal(aux_var_t type, bool deterministic_model, const vector<string> &subset);
|
||||
|
||||
private:
|
||||
//! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true
|
||||
|
@ -281,7 +284,9 @@ public:
|
|||
void removeTrendVariableFromEquations();
|
||||
|
||||
//! Transforms the model by creating aux vars for the diff of forward vars
|
||||
void differentiateForwardVars();
|
||||
/*! If subset is empty, does the transformation for all fwrd vars; otherwise
|
||||
restrict it to the vars in subset */
|
||||
void differentiateForwardVars(const vector<string> &subset);
|
||||
|
||||
//! Fills eval context with values of model local variables and auxiliary variables
|
||||
void fillEvalContext(eval_context_t &eval_context) const;
|
||||
|
|
|
@ -568,7 +568,8 @@ model_options : BLOCK { driver.block(); }
|
|||
| BYTECODE { driver.byte_code(); }
|
||||
| USE_DLL { driver.use_dll(); }
|
||||
| NO_STATIC { driver.no_static();}
|
||||
| DIFFERENTIATE_FORWARD_VARS { driver.differentiate_forward_vars(); }
|
||||
| DIFFERENTIATE_FORWARD_VARS { driver.differentiate_forward_vars_all(); }
|
||||
| DIFFERENTIATE_FORWARD_VARS EQUAL '(' symbol_list ')' { driver.differentiate_forward_vars_some(); }
|
||||
| o_linear
|
||||
;
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ NumConstNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
|
|||
}
|
||||
|
||||
expr_t
|
||||
NumConstNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
NumConstNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
{
|
||||
return const_cast<NumConstNode *>(this);
|
||||
}
|
||||
|
@ -1225,14 +1225,16 @@ VariableNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
|
|||
}
|
||||
|
||||
expr_t
|
||||
VariableNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
VariableNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
{
|
||||
expr_t value;
|
||||
switch (type)
|
||||
{
|
||||
case eEndogenous:
|
||||
assert(lag <= 1);
|
||||
if (lag <= 0)
|
||||
if (lag <= 0
|
||||
|| (subset.size() > 0
|
||||
&& find(subset.begin(), subset.end(), datatree.symbol_table.getName(symb_id)) == subset.end()))
|
||||
return const_cast<VariableNode *>(this);
|
||||
else
|
||||
{
|
||||
|
@ -1255,7 +1257,7 @@ VariableNode::differentiateForwardVars(subst_table_t &subst_table, vector<Binary
|
|||
if (value->maxEndoLead() <= 0)
|
||||
return const_cast<VariableNode *>(this);
|
||||
else
|
||||
return value->differentiateForwardVars(subst_table, neweqs);
|
||||
return value->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
default:
|
||||
return const_cast<VariableNode *>(this);
|
||||
}
|
||||
|
@ -2339,9 +2341,9 @@ UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNo
|
|||
}
|
||||
|
||||
expr_t
|
||||
UnaryOpNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
UnaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
{
|
||||
expr_t argsubst = arg->differentiateForwardVars(subst_table, neweqs);
|
||||
expr_t argsubst = arg->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
return buildSimilarUnaryOpNode(argsubst, datatree);
|
||||
}
|
||||
|
||||
|
@ -3583,10 +3585,10 @@ BinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
|
|||
|
||||
|
||||
expr_t
|
||||
BinaryOpNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
BinaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
{
|
||||
expr_t arg1subst = arg1->differentiateForwardVars(subst_table, neweqs);
|
||||
expr_t arg2subst = arg2->differentiateForwardVars(subst_table, neweqs);
|
||||
expr_t arg1subst = arg1->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
expr_t arg2subst = arg2->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
|
||||
}
|
||||
|
||||
|
@ -4200,11 +4202,11 @@ TrinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOp
|
|||
|
||||
|
||||
expr_t
|
||||
TrinaryOpNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
TrinaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
{
|
||||
expr_t arg1subst = arg1->differentiateForwardVars(subst_table, neweqs);
|
||||
expr_t arg2subst = arg2->differentiateForwardVars(subst_table, neweqs);
|
||||
expr_t arg3subst = arg3->differentiateForwardVars(subst_table, neweqs);
|
||||
expr_t arg1subst = arg1->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
expr_t arg2subst = arg2->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
expr_t arg3subst = arg3->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
|
||||
}
|
||||
|
||||
|
@ -4765,11 +4767,11 @@ ExternalFunctionNode::substituteExpectation(subst_table_t &subst_table, vector<B
|
|||
}
|
||||
|
||||
expr_t
|
||||
ExternalFunctionNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
ExternalFunctionNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
|
||||
{
|
||||
vector<expr_t> arguments_subst;
|
||||
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
|
||||
arguments_subst.push_back((*it)->differentiateForwardVars(subst_table, neweqs));
|
||||
arguments_subst.push_back((*it)->differentiateForwardVars(subset, subst_table, neweqs));
|
||||
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
|
||||
}
|
||||
|
||||
|
|
|
@ -361,11 +361,13 @@ public:
|
|||
|
||||
//! Constructs a new expression where forward variables (supposed to be at most in t+1) have been replaced by themselves at t, plus a new aux var representing their (time) differentiate
|
||||
/*!
|
||||
\param[in] subset variables to which to limit the transformation; transform
|
||||
all fwrd vars if empty
|
||||
\param[in,out] subst_table Map used to store mapping between a given
|
||||
forward variable and the aux var that contains its differentiate
|
||||
\param[out] neweqs Equations to be added to the model to match the creation of auxiliary variables.
|
||||
*/
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
|
||||
|
||||
//! Return true if the nodeID is a numerical constant equal to value and false otherwise
|
||||
/*!
|
||||
|
@ -452,7 +454,7 @@ public:
|
|||
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual bool isNumConstNodeEqualTo(double value) const;
|
||||
virtual bool containsEndogenous(void) const;
|
||||
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
|
||||
|
@ -514,7 +516,7 @@ public:
|
|||
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual bool isNumConstNodeEqualTo(double value) const;
|
||||
virtual bool containsEndogenous(void) const;
|
||||
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
|
||||
|
@ -591,7 +593,7 @@ public:
|
|||
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual bool isNumConstNodeEqualTo(double value) const;
|
||||
virtual bool containsEndogenous(void) const;
|
||||
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
|
||||
|
@ -681,7 +683,7 @@ public:
|
|||
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual bool isNumConstNodeEqualTo(double value) const;
|
||||
virtual bool containsEndogenous(void) const;
|
||||
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
|
||||
|
@ -751,7 +753,7 @@ public:
|
|||
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual bool isNumConstNodeEqualTo(double value) const;
|
||||
virtual bool containsEndogenous(void) const;
|
||||
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
|
||||
|
@ -825,7 +827,7 @@ public:
|
|||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||
virtual expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const;
|
||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||
virtual bool isNumConstNodeEqualTo(double value) const;
|
||||
virtual bool containsEndogenous(void) const;
|
||||
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
|
||||
|
|
|
@ -250,6 +250,19 @@ ModFile::checkPass()
|
|||
cerr << "ERROR: marking equations as [static] or [dynamic] is not possible with ramsey_policy or discretionary_policy" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (stochastic_statement_present &&
|
||||
(dynamic_model.isUnaryOpUsed(oSign)
|
||||
|| dynamic_model.isUnaryOpUsed(oAbs)
|
||||
|| dynamic_model.isBinaryOpUsed(oMax)
|
||||
|| dynamic_model.isBinaryOpUsed(oMin)
|
||||
|| dynamic_model.isBinaryOpUsed(oGreater)
|
||||
|| dynamic_model.isBinaryOpUsed(oLess)
|
||||
|| dynamic_model.isBinaryOpUsed(oGreaterEqual)
|
||||
|| dynamic_model.isBinaryOpUsed(oLessEqual)
|
||||
|| dynamic_model.isBinaryOpUsed(oEqualEqual)
|
||||
|| dynamic_model.isBinaryOpUsed(oDifferent)))
|
||||
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -309,7 +322,7 @@ ModFile::transformPass()
|
|||
}
|
||||
|
||||
if (differentiate_forward_vars)
|
||||
dynamic_model.differentiateForwardVars();
|
||||
dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset);
|
||||
|
||||
if (mod_file_struct.dsge_var_estimated || !mod_file_struct.dsge_var_calibrated.empty())
|
||||
try
|
||||
|
|
|
@ -78,6 +78,12 @@ public:
|
|||
//! Is the 'differentiate_forward_vars' option used?
|
||||
bool differentiate_forward_vars;
|
||||
|
||||
/*! If the 'differentiate_forward_vars' option is used, contains the set of
|
||||
endogenous with respect to which to do the transformation;
|
||||
if empty, means that the transformation must be applied to all endos
|
||||
with a lead */
|
||||
vector<string> differentiate_forward_vars_subset;
|
||||
|
||||
//! Are nonstationary variables present ?
|
||||
bool nonstationary_variables;
|
||||
|
||||
|
|
|
@ -494,11 +494,26 @@ ParsingDriver::byte_code()
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::differentiate_forward_vars()
|
||||
ParsingDriver::differentiate_forward_vars_all()
|
||||
{
|
||||
mod_file->differentiate_forward_vars = true;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::differentiate_forward_vars_some()
|
||||
{
|
||||
mod_file->differentiate_forward_vars = true;
|
||||
mod_file->differentiate_forward_vars_subset = symbol_list.get_symbols();
|
||||
for (vector<string>::const_iterator it = mod_file->differentiate_forward_vars_subset.begin();
|
||||
it != mod_file->differentiate_forward_vars_subset.end(); ++it)
|
||||
{
|
||||
check_symbol_existence(*it);
|
||||
if (mod_file->symbol_table.getType(*it) != eEndogenous)
|
||||
error("Symbol " + *it + " is not an endogenous");
|
||||
}
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::cutoff(string *value)
|
||||
{
|
||||
|
|
|
@ -245,8 +245,10 @@ public:
|
|||
void byte_code();
|
||||
//! the static model is not computed
|
||||
void no_static();
|
||||
//! the differentiate_forward_vars option is enabled
|
||||
void differentiate_forward_vars();
|
||||
//! the differentiate_forward_vars option is enabled (for all vars)
|
||||
void differentiate_forward_vars_all();
|
||||
//! the differentiate_forward_vars option is enabled (for a subset of vars)
|
||||
void differentiate_forward_vars_some();
|
||||
//! cutoff option of model block
|
||||
void cutoff(string *value);
|
||||
//! mfs option of model block
|
||||
|
|
Loading…
Reference in New Issue