Fixes around latex output: use of longtable for parameter estimates and various fixes for posterior analysis, also for parallel execution.

time-shift
Marco Ratto 2012-05-30 11:22:59 +02:00
parent 5af1effd8f
commit 4480f5b494
6 changed files with 168 additions and 175 deletions

View File

@ -57,7 +57,7 @@ FirstMhFile = record.KeepedDraws.FirstMhFile;
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws); NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
clear record; clear record;
pnames=[' ';'beta ';'gamm ';'norm ';'invg ';'unif ';'invg2']; pnames=[' ';'beta ';'gamma';'norm ';'invg ';'unif ';'invg2'];
header_width = row_header_width(M_,estim_params_,bayestopt_); header_width = row_header_width(M_,estim_params_,bayestopt_);
tit2 = sprintf('%-*s %10s %10s %16s %6s %10s\n',header_width+2,' ','prior mean','post. mean','conf. interval','prior','pstdev'); tit2 = sprintf('%-*s %10s %10s %16s %6s %10s\n',header_width+2,' ','prior mean','post. mean','conf. interval','prior','pstdev');
pformat = '%-*s %10.3f %10.4f %10.4f %8.4f %6s %10.4f'; pformat = '%-*s %10.3f %10.4f %10.4f %8.4f %6s %10.4f';
@ -103,6 +103,8 @@ if np
pnames(bayestopt_.pshape(ip)+1,:), ... pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip))); bayestopt_.p2(ip)));
if TeX if TeX
k = estim_params_.param_vals(i,1);
name = deblank(M_.param_names_tex(k,:));
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval); bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
@ -147,7 +149,8 @@ if nvx
end end
disp(sprintf(pformat,header_width,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))); pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX,
name = deblank(M_.exo_names_tex(k,:));
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval); bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
@ -188,6 +191,8 @@ if nvn
disp(sprintf(pformat,header_width,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))); pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX
k = estim_params_.var_endo(i,1);
name = deblank(M_.endo_names_tex(k,:));
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval); bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
@ -241,6 +246,7 @@ if ncx
disp(sprintf(pformat, header_width,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))); pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX
name = ['(',deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:)),')'];
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval); bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
@ -291,7 +297,8 @@ if ncn
end end
disp(sprintf(pformat, header_width,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))); pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX,
name = ['(',deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:)),')'];
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval); bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
@ -314,13 +321,25 @@ fprintf(fidTeX,['%% RESULTS FROM METROPOLIS HASTINGS (' title ')\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{table}\n'); fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\begin{longtable}{l|lcccccc} \n');
fprintf(fidTeX,'\\begin{tabular}{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,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,[' & Prior distribution & Prior mean & Prior ' ... fprintf(fidTeX,[' & Prior distribution & Prior mean & Prior ' ...
's.d. & Posterior mean & Posterior s.d. & HPD inf & HPD sup\\\\ \n']); 's.d. & Posterior mean & Posterior s.d. & HPD inf & HPD sup\\\\ \n']);
fprintf(fidTeX,'\\hline \\\\ \n'); fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,['\\caption{(continued)}']);
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 \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{8}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
fid = fidTeX; fid = fidTeX;
@ -337,11 +356,8 @@ fprintf(fid,['$%s$ & %s & %7.3f & %6.4f & %7.3f& %6.4f & %7.4f & %7.4f \\\\ \n']
function TeXEnd(fid,fnum,title) function TeXEnd(fid,fnum,title)
fprintf(fid,'\\hline\\hline \n'); fprintf(fid,'\\end{longtable}\n ');
fprintf(fid,'\\end{tabular}\n '); fprintf(fid,'\\end{center}\n');
fprintf(fid,['\\caption{Results from Metropolis-Hastings (' title ')}\n ']);
fprintf(fid,['\\label{Table:MHPosterior:' int2str(fnum) '}\n']);
fprintf(fid,'\\end{table}\n');
fprintf(fid,'%% End of TeX file.\n'); fprintf(fid,'%% End of TeX file.\n');
fclose(fid); fclose(fid);

View File

@ -175,7 +175,7 @@ for i = 1:pages
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:))); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
end end
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_udiag%s}\n',M_.fname,int2str(i)); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_udiag%s}\n',[DirectoryName '/' M_.fname],int2str(i));
fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n'); fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n');
fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n'); fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n');
fprintf(fidTeX,'the eighty percent interval, the second and third moments.}'); fprintf(fidTeX,'the eighty percent interval, the second and third moments.}');
@ -238,7 +238,7 @@ if reste
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:))); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
end end
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_udiag%s}\n',M_.fname,int2str(pages+1)); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_udiag%s}\n',[DirectoryName '/' M_.fname],int2str(pages+1));
if reste == 2 if reste == 2
fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n'); fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n');
fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n'); fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n');
@ -348,7 +348,7 @@ if TeX
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),' '); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),' ');
end end
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_mdiag}\n',M_.fname); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_mdiag}\n',[DirectoryName '/' M_.fname]);
fprintf(fidTeX,'\\caption{Multivariate convergence diagnostics for the Metropolis-Hastings.\n'); fprintf(fidTeX,'\\caption{Multivariate convergence diagnostics for the Metropolis-Hastings.\n');
fprintf(fidTeX,'The first, second and third rows are respectively the criteria based on\n'); fprintf(fidTeX,'The first, second and third rows are respectively the criteria based on\n');
fprintf(fidTeX,'the eighty percent interval, the second and third moments. The different \n'); fprintf(fidTeX,'the eighty percent interval, the second and third moments. The different \n');

View File

@ -159,7 +159,7 @@ for i=1:npar
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(j,:)),deblank(TeXNAMES(j,:))); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(j,:)),deblank(TeXNAMES(j,:)));
end end
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_PriorsAndPosteriors%s}\n',M_.fname,int2str(figunumber)); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s/%s_PriorsAndPosteriors%s}\n',OutputDirectoryName,M_.fname,int2str(figunumber));
fprintf(fidTeX,'\\caption{Priors and posteriors.}'); fprintf(fidTeX,'\\caption{Priors and posteriors.}');
fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n',int2str(figunumber)); fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n',int2str(figunumber));
fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,'\\end{figure}\n');

View File

@ -630,15 +630,20 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,'{\\tiny \n'); fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{table}\n'); fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (parameters)}\n '); fprintf(fidTeX,'\\caption{Results from posterior maximization (parameters)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:1}\n'); fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n'); fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n'); fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \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; ip = nvx+nvn+ncx+ncn+1;
for i=1:np for i=1:np
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',... fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
@ -649,24 +654,9 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
xparam1(ip),... xparam1(ip),...
stdh(ip)); stdh(ip));
ip = ip + 1; ip = ip + 1;
if ~mod(i,50) && i<np,
fprintf(fidTeX,'\\hline \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{(Table continues next page ...)} \\\\ \n')';
fprintf(fidTeX,'\\end{tabular}\n ');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'\\begin{table}\n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{( ... Table continued)} \\\\ \n')';
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \n');
end
end end
fprintf(fidTeX,'\\hline\\hline \n'); fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{tabular}\n '); fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'} \n');
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);
end end
@ -678,15 +668,20 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,'{\\tiny \n'); fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{table}\n'); fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of structural shocks)}\n '); fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of structural shocks)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:2}\n'); fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n'); fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n'); fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \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; ip = 1;
for i=1:nvx for i=1:nvx
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
@ -698,24 +693,9 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
xparam1(ip), ... xparam1(ip), ...
stdh(ip)); stdh(ip));
ip = ip+1; ip = ip+1;
if ~mod(i,50) && i<nvx,
fprintf(fidTeX,'\\hline \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{(Table continues next page ...)} \\\\ \n')';
fprintf(fidTeX,'\\end{tabular}\n ');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'\\begin{table}\n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{( ... Table continued)} \\\\ \n')';
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \n');
end
end end
fprintf(fidTeX,'\\hline\\hline \n'); fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{tabular}\n '); fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'} \n');
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);
end end
@ -727,14 +707,20 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{table}\n'); fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of measurement errors)}\n '); fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of measurement errors)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:3}\n'); fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n'); fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n') fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \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; ip = nvx+1;
for i=1:nvn for i=1:nvn
idx = strmatch(options_.varobs(estim_params_.var_endo(i,1),:),M_.endo_names); idx = strmatch(options_.varobs(estim_params_.var_endo(i,1),:),M_.endo_names);
@ -746,23 +732,9 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
xparam1(ip),... xparam1(ip),...
stdh(ip)); stdh(ip));
ip = ip+1; ip = ip+1;
if ~mod(i,50) && i<nvn,
fprintf(fidTeX,'\\hline \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{(Table continues next page ...)} \\\\ \n')';
fprintf(fidTeX,'\\end{tabular}\n ');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'\\begin{table}\n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{( ... Table continued)} \\\\ \n')';
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \n');
end
end end
fprintf(fidTeX,'\\hline\\hline \n'); fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{tabular}\n '); fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);
end end
@ -774,14 +746,20 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{table}\n'); fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n '); fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:4}\n'); fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n'); fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n') fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \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; ip = nvx+nvn+1;
for i=1:ncx for i=1:ncx
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
@ -794,23 +772,9 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
xparam1(ip), ... xparam1(ip), ...
stdh(ip)); stdh(ip));
ip = ip+1; ip = ip+1;
if ~mod(i,50) && i<ncx,
fprintf(fidTeX,'\\hline \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{(Table continues next page ...)} \\\\ \n')';
fprintf(fidTeX,'\\end{tabular}\n ');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'\\begin{table}\n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{( ... Table continued)} \\\\ \n')';
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \n');
end
end end
fprintf(fidTeX,'\\hline\\hline \n'); fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{tabular}\n '); fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);
end end
@ -822,14 +786,20 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{table}\n'); fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\begin{longtabe}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n '); fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:5}\n'); fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n'); fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n') fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \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; ip = nvx+nvn+ncx+1;
for i=1:ncn for i=1:ncn
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
@ -842,23 +812,9 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
xparam1(ip), ... xparam1(ip), ...
stdh(ip)); stdh(ip));
ip = ip+1; ip = ip+1;
if ~mod(i,50) && i<ncn,
fprintf(fidTeX,'\\hline \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{(Table continues next page ...)} \\\\ \n')';
fprintf(fidTeX,'\\end{tabular}\n ');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'\\begin{table}\n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n');
fprintf(fidTeX,'\\multicolumn{6}{c}{( ... Table continued)} \\\\ \n')';
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\\\ \n');
end
end end
fprintf(fidTeX,'\\hline\\hline \n'); fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{tabular}\n '); fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'\\end{table}\n');
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);
end end

View File

@ -41,12 +41,16 @@ else
end end
if options_.TeX if options_.TeX
% needs to be fixed % needs to be fixed
if isempty(tit_tex),
tit_tex=M_.endo_names_tex;
end
varlist_TeX = []; varlist_TeX = [];
for i=1:nvar for i=1:nvar
if i==1 if i==1
varlist_TeX = M_.endo_names_tex(SelecVariables(i),:); varlist_TeX = tit_tex(SelecVariables(i),:);
else else
varlist_TeX = char(varlist_TeX,M_.endo_names_tex(SelecVariables(i),:)); varlist_TeX = char(varlist_TeX,tit_tex(SelecVariables(i),:));
end end
end end
end end
@ -97,40 +101,6 @@ end
% %%% The file .TeX! are not saved in parallel. % %%% The file .TeX! are not saved in parallel.
subplotnum = 0;
if options_.TeX
fidTeX = fopen([M_.dname '/Output/' M_.fname '_' name3 '.TeX'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare.\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
for i=1:nvar
NAMES = [];
TEXNAMES = [];
if max(abs(Mean(:,i))) > 10^(-6)
subplotnum = subplotnum+1;
name = deblank(varlist(i,:));
NAMES = name;
texname = deblank(varlist_TeX(i,:));
TEXNAMES = ['$' texname '$'];
end
if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:size(TEXNAMES,1)
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{%s}\n'],deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,['\\includegraphics[scale=0.5]{%s_' name3 '_%s}\n'],M_.fname,deblank(tit3(i,:)));
fprintf(fidTeX,'\\label{Fig:%s:%s}\n',name3,deblank(tit3(i,:)));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
subplotnum = 0;
end
end
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
% Store the variable mandatory for local/remote parallel computing. % Store the variable mandatory for local/remote parallel computing.
@ -146,7 +116,7 @@ localVars.name3=name3;
localVars.tit3=tit3; localVars.tit3=tit3;
localVars.Mean=Mean; localVars.Mean=Mean;
% Like sequential execution! % Like sequential execution!
nvar0=nvar;
if ~exist('OCTAVE_VERSION') if ~exist('OCTAVE_VERSION')
% Commenting for testing! % Commenting for testing!
@ -165,7 +135,7 @@ if ~exist('OCTAVE_VERSION')
globalVars = struct('M_',M_, ... globalVars = struct('M_',M_, ...
'options_', options_, ... 'options_', options_, ...
'oo_', oo_); 'oo_', oo_);
[fout, nBlockPerCPU, totCPU] = masterParallel(options_.parallel, 1, nvar, [],'pm3_core', localVars,globalVars, options_.parallel_info); [fout, nvar0, totCPU] = masterParallel(options_.parallel, 1, nvar, [],'pm3_core', localVars,globalVars, options_.parallel_info);
end end
end end
else else
@ -175,6 +145,54 @@ else
fout = pm3_core(localVars,1,nvar,0); fout = pm3_core(localVars,1,nvar,0);
end end
subplotnum = 0;
if options_.TeX,
fidTeX = fopen([M_.dname '/Output/' M_.fname '_' name3 '.TeX'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare.\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
nvar0=cumsum(nvar0);
i=0;
for j=1:length(nvar0),
NAMES = [];
TEXNAMES = [];
nvar=nvar0(j);
while i<nvar,
i=i+1;
if max(abs(Mean(:,i))) > 10^(-6)
subplotnum = subplotnum+1;
name = deblank(varlist(i,:));
texname = deblank(varlist_TeX(i,:));
if subplotnum==1
NAMES = name;
TEXNAMES = ['$' texname '$'];
else
NAMES = char(NAMES,name);
TEXNAMES = char(TEXNAMES,['$' texname '$']);
end
end
if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:size(TEXNAMES,1)
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{%s}\n'],deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,['\\includegraphics[scale=0.5]{%s/Output/%s_' name3 '_%s}\n'],M_.dname,M_.fname,deblank(tit3(i,:)));
fprintf(fidTeX,'\\label{Fig:%s:%s}\n',name3,deblank(tit3(i,:)));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
subplotnum = 0;
NAMES = [];
TEXNAMES = [];
end
end
end
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
fprintf(['MH: ' tit1 ', done!\n']); fprintf(['MH: ' tit1 ', done!\n']);

View File

@ -221,13 +221,16 @@ if isnumeric(options_.parallel),
% Parallel execution! % Parallel execution!
else else
[nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B); [nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
ifil=zeros(7,totCPU);
for j=1:totCPU-1, for j=1:totCPU-1,
nfiles = ceil(nBlockPerCPU(j)/MAX_nsmoo); if run_smoother
ifil(1,j+1) =ifil(1,j)+nfiles; nfiles = ceil(nBlockPerCPU(j)/MAX_nsmoo);
nfiles = ceil(nBlockPerCPU(j)/MAX_ninno); ifil(1,j+1) =ifil(1,j)+nfiles;
ifil(2,j+1) =ifil(2,j)+nfiles; nfiles = ceil(nBlockPerCPU(j)/MAX_ninno);
nfiles = ceil(nBlockPerCPU(j)/MAX_nerro); ifil(2,j+1) =ifil(2,j)+nfiles;
ifil(3,j+1) =ifil(3,j)+nfiles; nfiles = ceil(nBlockPerCPU(j)/MAX_nerro);
ifil(3,j+1) =ifil(3,j)+nfiles;
end
if naK if naK
nfiles = ceil(nBlockPerCPU(j)/MAX_naK); nfiles = ceil(nBlockPerCPU(j)/MAX_naK);
ifil(4,j+1) =ifil(4,j)+nfiles; ifil(4,j+1) =ifil(4,j)+nfiles;
@ -274,16 +277,16 @@ if ~isnumeric(options_.parallel),
leaveSlaveOpen = options_.parallel_info.leaveSlaveOpen; leaveSlaveOpen = options_.parallel_info.leaveSlaveOpen;
if options_.parallel_info.leaveSlaveOpen == 0, if options_.parallel_info.leaveSlaveOpen == 0,
% Commenting for testing!!! % Commenting for testing!!!
% options_.parallel_info.leaveSlaveOpen = 1; % Force locally to leave open remote matlab sessions (repeated pm3 calls) options_.parallel_info.leaveSlaveOpen = 1; % Force locally to leave open remote matlab sessions (repeated pm3 calls)
end end
end end
if options_.smoother if options_.smoother
pm3(endo_nbr,gend,ifil(1),B,'Smoothed variables',... pm3(endo_nbr,gend,ifil(1),B,'Smoothed variables',...
'',M_.endo_names(1:M_.orig_endo_nbr, :),'tit_tex',M_.endo_names,... '',M_.endo_names(1:M_.orig_endo_nbr, :),M_.endo_names_tex,M_.endo_names,...
varlist,'SmoothedVariables',DirectoryName,'_smooth'); varlist,'SmoothedVariables',DirectoryName,'_smooth');
pm3(exo_nbr,gend,ifil(2),B,'Smoothed shocks',... pm3(exo_nbr,gend,ifil(2),B,'Smoothed shocks',...
'',M_.exo_names,'tit_tex',M_.exo_names,... '',M_.exo_names,M_.exo_names_tex,M_.exo_names,...
M_.exo_names,'SmoothedShocks',DirectoryName,'_inno'); M_.exo_names,'SmoothedShocks',DirectoryName,'_inno');
if nvn if nvn
% needs to be fixed % needs to be fixed