Commit aa843c73 authored by michel's avatar michel
Browse files

4.1: corrected estimation results tables with long parameter names

     added function row_header_width.m


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2570 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 02681122
......@@ -59,7 +59,7 @@ clear record;
pnames=[' ';'beta ';'gamm ';'norm ';'invg ';'unif ';'invg2'];
tit2 = sprintf('%10s %7s %10s %14s %4s %6s\n',' ','prior mean','post. mean','conf. interval','prior','pstdev');
pformat = '%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f';
pformat = '%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f';
disp(' ');disp(' ');disp('ESTIMATION RESULTS');disp(' ');
try
......@@ -68,6 +68,7 @@ catch
[marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_)
disp(sprintf('Log data density is %f.',oo_.MarginalDensity.ModifiedHarmonicMean))
end
header_width = row_header_width(M_,estim_params,bayestopt_);
if np
type = 'parameters';
if TeX
......@@ -97,6 +98,7 @@ if np
end
end
disp(sprintf(pformat,name,bayestopt_.p1(ip),...
header_width, ...
post_mean, ...
hpd_interval, ...
pnames(bayestopt_.pshape(ip)+1,:), ...
......@@ -144,7 +146,7 @@ if nvx
M_.Sigma_e(k,k) = post_mean*post_mean;
end
end
disp(sprintf(pformat,name,bayestopt_.p1(ip),post_mean,hpd_interval,...
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval,...
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
......@@ -184,7 +186,7 @@ if nvn
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
end
end
disp(sprintf(pformat,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
......@@ -237,7 +239,7 @@ if ncx
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
end
end
disp(sprintf(pformat, name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
......@@ -288,7 +290,7 @@ if ncn
post_median,post_var,post_deciles,density);
end
end
disp(sprintf(pformat, name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
......
......@@ -624,7 +624,10 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
for i = 1:nx
tstath(i) = abs(xparam1(i))/stdh(i);
end
tit1 = sprintf('%10s %7s %8s %7s %6s %4s %6s\n',' ','prior mean', ...
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;
......@@ -632,8 +635,8 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
disp(tit1)
for i=1:np
name = bayestopt_.name{ip};
disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
name, ...
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)));
......@@ -649,8 +652,8 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
for i=1:nvx
k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:));
disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
name,bayestopt_.p1(ip),xparam1(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)));
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
......@@ -665,8 +668,8 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
ip = nvx+1;
for i=1:nvn
name = deblank(options_.varobs(estim_params_.var_endo(i,1),:));
disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
name,bayestopt_.p1(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)));
......@@ -684,8 +687,8 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
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('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', name, ...
bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', name, ...
header_width,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);
......@@ -703,8 +706,8 @@ if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
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('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', name, ...
bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', name, ...
header_width,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);']);
......@@ -733,15 +736,16 @@ elseif ~any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
for i = 1:nx
tstath(i) = abs(xparam1(i))/stdh(i);
end
tit1 = sprintf('%10s %10s %7s %6s\n',' ','Estimate','s.d.','t-stat');
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('%12s %8.4f %7.4f %7.4f', ...
name,xparam1(ip),stdh(ip),tstath(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;
......@@ -754,7 +758,7 @@ elseif ~any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
for i=1:nvx
k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:));
disp(sprintf('%12s %8.4f %7.4f %7.4f',name,xparam1(ip),stdh(ip),tstath(ip)));
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);']);
......@@ -767,7 +771,7 @@ elseif ~any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
ip = nvx+1;
for i=1:nvn
name = deblank(options_.varobs(estim_params_.var_endo(i,1),:));
disp(sprintf('%12s %8.4f %7.4f %7.4f',name,xparam1(ip),stdh(ip),tstath(ip)))
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;
......@@ -782,7 +786,7 @@ elseif ~any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
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('%12s %8.4f %7.4f %7.4f', name,xparam1(ip),stdh(ip),tstath(ip)));
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);']);
......@@ -799,7 +803,7 @@ elseif ~any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
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('%12s %8.4f %7.4f %7.4f',name,xparam1(ip),stdh(ip),tstath(ip)));
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;
......@@ -1549,3 +1553,4 @@ if np > 0
pindx = estim_params_.param_vals(:,1);
save([M_.fname '_pindx.mat'] ,'pindx');
end
function w=row_header_width(M_,estim_params_,bayestopt_)
% This function computes the width of the row headers for
% the estimation results
%
% INPUTS
% estim_params_ [structure]
% M_ [structure]
% bayestopt_ [structure]
%
% OUTPUTS
% w integer
%
% SPECIAL REQUIREMENTS
% None.
% Copyright (C) 2006-2009 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/>.
np = estim_params_.np;
nvx = estim_params_.nvx;
nvn = estim_params_.nvn;
ncx = estim_params_.ncx;
ncn = estim_params_.ncn;
w = 0;
if np
for i=1:np
w = max(w,length(bayestopt_.name{i}));
end
end
if nvx
for i=1:nvx
k = estim_params_.var_exo(i,1)
w = max(w,length(deblank(M_.exo_names(k,:))));
end
end
if nvn
for i=1:nvn
k = estim_params_.var_endo(i,1)
w = max(w,length(deblank(M_.endo_names(k,:))));
end
end
if ncx
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
w = max(w,length(deblank(M_.exo_names(k1,:)))...
+length(deblank(M_.exo_names(k2,:))))
end
end
if ncn
for i=1:nvn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
w = max(w,length(deblank(M_.endo_names(k1,:)))...
+length(deblank(M_.endo_names(k2,:))))
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment