2008-09-03 18:05:35 +02:00
|
|
|
function oo_ = GetPosteriorParametersStatistics(estim_params_, M_, options_, bayestopt_, oo_)
|
2008-05-19 15:22:57 +02:00
|
|
|
% This function prints and saves posterior estimates after the mcmc
|
|
|
|
% (+updates of oo_ & TeX output).
|
|
|
|
%
|
|
|
|
% INPUTS
|
2008-09-03 18:05:35 +02:00
|
|
|
% estim_params_ [structure]
|
|
|
|
% M_ [structure]
|
|
|
|
% options_ [structure]
|
|
|
|
% bayestopt_ [structure]
|
|
|
|
% oo_ [structure]
|
2008-05-19 15:22:57 +02:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2008-09-03 18:05:35 +02:00
|
|
|
% oo_ [structure]
|
2008-05-19 15:22:57 +02:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% None.
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2013-03-19 21:12:49 +01:00
|
|
|
% Copyright (C) 2006-2013 Dynare Team
|
2008-08-01 14:40:33 +02:00
|
|
|
%
|
|
|
|
% 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/>.
|
2008-05-19 15:22:57 +02:00
|
|
|
|
2011-02-10 17:23:22 +01:00
|
|
|
%if ~options_.mh_replic && options_.load_mh_file
|
2008-09-03 18:05:35 +02:00
|
|
|
% load([M_.fname '_results.mat'],'oo_');
|
|
|
|
%end
|
2008-05-19 15:22:57 +02:00
|
|
|
|
2010-01-05 11:46:10 +01:00
|
|
|
TeX = options_.TeX;
|
|
|
|
nblck = options_.mh_nblck;
|
|
|
|
nvx = estim_params_.nvx;
|
|
|
|
nvn = estim_params_.nvn;
|
|
|
|
ncx = estim_params_.ncx;
|
|
|
|
ncn = estim_params_.ncn;
|
|
|
|
np = estim_params_.np ;
|
|
|
|
nx = nvx+nvn+ncx+ncn+np;
|
2008-05-19 15:22:57 +02:00
|
|
|
|
2013-11-20 18:03:12 +01:00
|
|
|
MetropolisFolder = CheckPath('metropolis',M_.dname);
|
|
|
|
OutputFolder = CheckPath('Output',M_.dname);
|
|
|
|
FileName = M_.fname;
|
|
|
|
|
|
|
|
load_last_mh_history_file(MetropolisFolder,FileName);
|
2008-05-19 15:22:57 +02:00
|
|
|
|
|
|
|
FirstMhFile = record.KeepedDraws.FirstMhFile;
|
2008-09-02 12:00:15 +02:00
|
|
|
FirstLine = record.KeepedDraws.FirstLine;
|
2008-09-05 18:48:39 +02:00
|
|
|
TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
|
2008-05-19 15:22:57 +02:00
|
|
|
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
|
|
|
|
FirstMhFile = record.KeepedDraws.FirstMhFile;
|
|
|
|
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
|
|
|
|
clear record;
|
|
|
|
|
2012-05-30 11:22:59 +02:00
|
|
|
pnames=[' ';'beta ';'gamma';'norm ';'invg ';'unif ';'invg2'];
|
2009-04-22 23:34:45 +02:00
|
|
|
header_width = row_header_width(M_,estim_params_,bayestopt_);
|
2013-09-16 17:11:25 +02:00
|
|
|
hpd_interval=[num2str(options_.mh_conf_sig*100), '% HPD interval'];
|
|
|
|
tit2 = sprintf('%-*s %12s %12s %23s %8s %12s\n',header_width,' ','prior mean','post. mean',hpd_interval,'prior','pstdev');
|
|
|
|
pformat = '%-*s %12.3f % 12.4f %11.4f %11.4f %7s %12.4f';
|
2008-05-19 15:22:57 +02:00
|
|
|
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline(2)
|
|
|
|
disp('ESTIMATION RESULTS')
|
|
|
|
skipline()
|
|
|
|
|
2008-09-03 18:05:35 +02:00
|
|
|
try
|
|
|
|
disp(sprintf('Log data density is %f.',oo_.MarginalDensity.ModifiedHarmonicMean))
|
|
|
|
catch
|
2009-04-22 23:34:45 +02:00
|
|
|
[marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_);
|
2008-09-03 18:05:35 +02:00
|
|
|
disp(sprintf('Log data density is %f.',oo_.MarginalDensity.ModifiedHarmonicMean))
|
|
|
|
end
|
2008-05-19 15:22:57 +02:00
|
|
|
if np
|
|
|
|
type = 'parameters';
|
|
|
|
if TeX
|
2013-11-29 10:25:25 +01:00
|
|
|
fid = TeXBegin(OutputFolder,M_.fname,1,type);
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2008-05-19 15:22:57 +02:00
|
|
|
disp(type)
|
|
|
|
disp(tit2)
|
|
|
|
ip = nvx+nvn+ncx+ncn+1;
|
|
|
|
for i=1:np
|
|
|
|
if options_.mh_replic
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, ...
|
|
|
|
density] = posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
name = bayestopt_.name{ip};
|
|
|
|
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
else
|
2008-09-03 18:05:35 +02:00
|
|
|
try
|
|
|
|
name = bayestopt_.name{ip};
|
|
|
|
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type);
|
|
|
|
catch
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, ...
|
|
|
|
density] = posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
name = bayestopt_.name{ip};
|
|
|
|
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
end
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2009-04-22 23:34:45 +02:00
|
|
|
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),...
|
2008-05-19 15:22:57 +02:00
|
|
|
post_mean, ...
|
|
|
|
hpd_interval, ...
|
|
|
|
pnames(bayestopt_.pshape(ip)+1,:), ...
|
2009-04-06 16:38:37 +02:00
|
|
|
bayestopt_.p2(ip)));
|
2008-05-19 15:22:57 +02:00
|
|
|
if TeX
|
2012-05-30 11:22:59 +02:00
|
|
|
k = estim_params_.param_vals(i,1);
|
|
|
|
name = deblank(M_.param_names_tex(k,:));
|
2009-04-06 16:38:37 +02:00
|
|
|
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
|
|
|
|
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
|
|
|
ip = ip+1;
|
|
|
|
end
|
|
|
|
if TeX
|
|
|
|
TeXEnd(fid,1,type);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if nvx
|
|
|
|
type = 'shocks_std';
|
|
|
|
if TeX
|
2013-11-20 18:03:12 +01:00
|
|
|
fid = TeXBegin(OutputFolder,FileName,2,'standard deviation of structural shocks');
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
|
|
|
ip = 1;
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2008-05-19 15:22:57 +02:00
|
|
|
disp('standard deviation of shocks')
|
|
|
|
disp(tit2)
|
|
|
|
for i=1:nvx
|
|
|
|
if options_.mh_replic
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
k = estim_params_.var_exo(i,1);
|
|
|
|
name = deblank(M_.exo_names(k,:));
|
|
|
|
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
M_.Sigma_e(k,k) = post_mean*post_mean;
|
|
|
|
else
|
2008-09-03 18:05:35 +02:00
|
|
|
try
|
|
|
|
k = estim_params_.var_exo(i,1);
|
|
|
|
name = deblank(M_.exo_names(k,:));
|
|
|
|
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type);
|
|
|
|
catch
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
k = estim_params_.var_exo(i,1);
|
|
|
|
name = deblank(M_.exo_names(k,:));
|
|
|
|
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
M_.Sigma_e(k,k) = post_mean*post_mean;
|
|
|
|
end
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2009-04-08 22:04:19 +02:00
|
|
|
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval,...
|
2009-04-06 16:38:37 +02:00
|
|
|
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
|
2012-05-30 11:22:59 +02:00
|
|
|
if TeX,
|
|
|
|
name = deblank(M_.exo_names_tex(k,:));
|
2009-04-06 16:38:37 +02:00
|
|
|
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
|
|
|
|
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
|
|
|
ip = ip+1;
|
|
|
|
end
|
|
|
|
if TeX
|
|
|
|
TeXEnd(fid,2,'standard deviation of structural shocks');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if nvn
|
|
|
|
type = 'measurement_errors_std';
|
|
|
|
if TeX
|
2013-11-20 18:03:12 +01:00
|
|
|
fid = TeXBegin(OutputFolder,FileName,3,'standard deviation of measurement errors');
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2008-05-19 15:22:57 +02:00
|
|
|
disp('standard deviation of measurement errors')
|
|
|
|
disp(tit2)
|
|
|
|
ip = nvx+1;
|
|
|
|
for i=1:nvn
|
|
|
|
if options_.mh_replic
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
2013-05-21 16:38:17 +02:00
|
|
|
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
|
2008-05-19 15:22:57 +02:00
|
|
|
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
else
|
2008-09-03 18:05:35 +02:00
|
|
|
try
|
2013-05-21 16:38:17 +02:00
|
|
|
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
|
2008-09-03 18:05:35 +02:00
|
|
|
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type);
|
|
|
|
catch
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
2013-05-21 16:38:17 +02:00
|
|
|
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
|
2008-09-03 18:05:35 +02:00
|
|
|
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
end
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2009-04-08 22:04:19 +02:00
|
|
|
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
|
2009-04-06 16:38:37 +02:00
|
|
|
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
|
2008-05-19 15:22:57 +02:00
|
|
|
if TeX
|
2012-05-30 11:22:59 +02:00
|
|
|
k = estim_params_.var_endo(i,1);
|
|
|
|
name = deblank(M_.endo_names_tex(k,:));
|
2009-04-06 16:38:37 +02:00
|
|
|
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
|
|
|
|
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
|
|
|
ip = ip+1;
|
|
|
|
end
|
|
|
|
if TeX
|
|
|
|
TeXEnd(fid,3,'standard deviation of measurement errors');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if ncx
|
|
|
|
type = 'shocks_corr';
|
|
|
|
if TeX
|
2013-11-20 18:03:12 +01:00
|
|
|
fid = TeXBegin(OutputFolder,FileName,4,'correlation of structural shocks');
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2008-05-19 15:22:57 +02:00
|
|
|
disp('correlation of shocks')
|
|
|
|
disp(tit2)
|
|
|
|
ip = nvx+nvn+1;
|
|
|
|
for i=1:ncx
|
|
|
|
if options_.mh_replic
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
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,:))];
|
|
|
|
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
|
|
|
|
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
|
|
|
|
else
|
2008-09-03 18:05:35 +02:00
|
|
|
try
|
|
|
|
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,:))];
|
|
|
|
[post_mean,hpd_interval,post_var] = Extractoo(oo_,NAME,type);
|
|
|
|
catch
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
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,:))];
|
|
|
|
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
|
|
|
|
M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
|
|
|
|
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
|
|
|
|
end
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2009-04-08 22:04:19 +02:00
|
|
|
disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
|
2009-04-06 16:38:37 +02:00
|
|
|
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
|
2008-05-19 15:22:57 +02:00
|
|
|
if TeX
|
2012-05-30 11:22:59 +02:00
|
|
|
name = ['(',deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:)),')'];
|
2009-04-06 16:38:37 +02:00
|
|
|
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
|
|
|
|
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
|
|
|
ip = ip+1;
|
|
|
|
end
|
|
|
|
if TeX
|
|
|
|
TeXEnd(fid,4,'correlation of structural shocks');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if ncn
|
|
|
|
type = 'measurement_errors_corr';
|
|
|
|
if TeX
|
2013-11-20 18:03:12 +01:00
|
|
|
fid = TeXBegin(OutputFolder,FileName,5,'correlation of measurement errors');
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2008-05-19 15:22:57 +02:00
|
|
|
disp('correlation of measurement errors')
|
|
|
|
disp(tit2)
|
|
|
|
ip = nvx+nvn+ncx+1;
|
|
|
|
for i=1:ncn
|
|
|
|
if options_.mh_replic
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
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,:))];
|
|
|
|
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,...
|
|
|
|
post_median,post_var,post_deciles,density);
|
|
|
|
else
|
2008-09-03 18:05:35 +02:00
|
|
|
try
|
|
|
|
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,:))];
|
|
|
|
[post_mean,hpd_interval,post_var] = Extractoo(oo_,NAME,type);
|
|
|
|
catch
|
|
|
|
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
|
|
|
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
|
|
|
|
posterior_moments(Draws,1,options_.mh_conf_sig);
|
|
|
|
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,:))];
|
|
|
|
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,...
|
|
|
|
post_median,post_var,post_deciles,density);
|
|
|
|
end
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
2009-04-08 22:04:19 +02:00
|
|
|
disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
|
2009-04-06 16:38:37 +02:00
|
|
|
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
|
2012-05-30 11:22:59 +02:00
|
|
|
if TeX,
|
|
|
|
name = ['(',deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:)),')'];
|
2009-04-06 16:38:37 +02:00
|
|
|
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
|
|
|
|
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
|
2008-05-19 15:22:57 +02:00
|
|
|
end
|
|
|
|
ip = ip+1;
|
|
|
|
end
|
|
|
|
if TeX
|
|
|
|
TeXEnd(fid,5,'correlation of measurement errors');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
%
|
|
|
|
%% subfunctions:
|
|
|
|
%
|
|
|
|
function fid = TeXBegin(directory,fname,fnum,title)
|
2009-12-16 18:17:34 +01:00
|
|
|
TeXfile = [directory '/' fname '_Posterior_Mean_' int2str(fnum) '.TeX'];
|
|
|
|
fidTeX = fopen(TeXfile,'w');
|
|
|
|
fprintf(fidTeX,'%% TeX-table generated by Dynare.\n');
|
|
|
|
fprintf(fidTeX,['%% RESULTS FROM METROPOLIS HASTINGS (' title ')\n']);
|
|
|
|
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
|
|
|
fprintf(fidTeX,' \n');
|
|
|
|
fprintf(fidTeX,' \n');
|
2012-05-30 11:22:59 +02:00
|
|
|
fprintf(fidTeX,'\\begin{center}\n');
|
|
|
|
fprintf(fidTeX,'\\begin{longtable}{l|lcccccc} \n');
|
|
|
|
fprintf(fidTeX,['\\caption{Results from Metropolis-Hastings (' title ')}\n ']);
|
|
|
|
fprintf(fidTeX,['\\label{Table:MHPosterior:' int2str(fnum) '}\\\\\n']);
|
|
|
|
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
|
|
|
fprintf(fidTeX,[' & Prior distribution & Prior mean & Prior ' ...
|
|
|
|
's.d. & Posterior mean & Posterior s.d. & HPD inf & HPD sup\\\\ \n']);
|
|
|
|
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
|
|
|
fprintf(fidTeX,['\\caption{(continued)}']);
|
|
|
|
fprintf(fidTeX,['\\label{Table:MHPosterior:' int2str(fnum) '}\\\\\n']);
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
|
|
|
fprintf(fidTeX,[' & Prior distribution & Prior mean & Prior ' ...
|
|
|
|
's.d. & Posterior mean & Posterior s.d. & HPD inf & HPD sup\\\\ \n']);
|
2012-05-30 11:22:59 +02:00
|
|
|
fprintf(fidTeX,'\\hline \\endhead \n');
|
|
|
|
|
|
|
|
fprintf(fidTeX,'\\hline \\multicolumn{8}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
|
|
|
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
|
|
|
|
|
|
|
|
2009-12-16 18:17:34 +01:00
|
|
|
fid = fidTeX;
|
|
|
|
|
2008-05-19 15:22:57 +02:00
|
|
|
|
|
|
|
function TeXCore(fid,name,shape,priormean,priorstd,postmean,poststd,hpd)
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf(fid,['$%s$ & %s & %7.3f & %6.4f & %7.3f& %6.4f & %7.4f & %7.4f \\\\ \n'],...
|
|
|
|
name,...
|
|
|
|
shape,...
|
|
|
|
priormean,...
|
|
|
|
priorstd,...
|
|
|
|
postmean,...
|
|
|
|
poststd,...
|
|
|
|
hpd(1),...
|
|
|
|
hpd(2));
|
|
|
|
|
2008-05-19 15:22:57 +02:00
|
|
|
|
|
|
|
function TeXEnd(fid,fnum,title)
|
2012-05-30 11:22:59 +02:00
|
|
|
fprintf(fid,'\\end{longtable}\n ');
|
|
|
|
fprintf(fid,'\\end{center}\n');
|
2009-12-16 18:17:34 +01:00
|
|
|
fprintf(fid,'%% End of TeX file.\n');
|
|
|
|
fclose(fid);
|
|
|
|
|
|
|
|
|
2008-05-19 15:22:57 +02:00
|
|
|
function oo = Filloo(oo,name,type,postmean,hpdinterval,postmedian,postvar,postdecile,density)
|
2009-12-16 18:17:34 +01:00
|
|
|
eval(['oo.posterior_mean.' type '.' name ' = postmean;']);
|
|
|
|
eval(['oo.posterior_hpdinf.' type '.' name ' = hpdinterval(1);']);
|
|
|
|
eval(['oo.posterior_hpdsup.' type '.' name ' = hpdinterval(2);']);
|
|
|
|
eval(['oo.posterior_median.' type '.' name ' = postmedian;']);
|
|
|
|
eval(['oo.posterior_variance.' type '.' name ' = postvar;']);
|
|
|
|
eval(['oo.posterior_deciles.' type '.' name ' = postdecile;']);
|
|
|
|
eval(['oo.posterior_density.' type '.' name ' = density;']);
|
|
|
|
|
2008-05-19 15:22:57 +02:00
|
|
|
function [post_mean,hpd_interval,post_var] = Extractoo(oo,name,type)
|
2009-12-16 18:17:34 +01:00
|
|
|
hpd_interval = zeros(2,1);
|
|
|
|
eval(['post_mean = oo.posterior_mean.' type '.' name ';']);
|
|
|
|
eval(['hpd_interval(1) = oo.posterior_hpdinf.' type '.' name ';']);
|
|
|
|
eval(['hpd_interval(2) = oo.posterior_hpdsup.' type '.' name ';']);
|
|
|
|
eval(['post_var = oo.posterior_variance.' type '.' name ';']);
|