From 837916f45b53fafd232ab168f5604ad82c2e261d Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 16:40:20 +0100 Subject: [PATCH 01/10] Add LaTeX-capacities for trace_plot.m --- matlab/trace_plot.m | 52 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/matlab/trace_plot.m b/matlab/trace_plot.m index bc7322737..759afe94b 100644 --- a/matlab/trace_plot.m +++ b/matlab/trace_plot.m @@ -1,7 +1,7 @@ function trace_plot(options_,M_,estim_params_,type,blck,name1,name2) % This function builds trace plot for the Metropolis-Hastings draws. % -% INPUTS +% INPUTS % % options_ [structure] Dynare structure. % M_ [structure] Dynare structure (related to model definition). @@ -11,11 +11,11 @@ function trace_plot(options_,M_,estim_params_,type,blck,name1,name2) % or 'PosteriorDensity (for posterior density)' % blck [integer] Number of the mh chain. % name1 [string] Object name. -% name2 [string] Object name. -% -% OUTPUTS +% name2 [string] Object name. +% +% OUTPUTS % None -% +% % SPECIAL REQUIREMENTS % Copyright (C) 2003-2015 Dynare Team @@ -40,7 +40,7 @@ if strcmpi(type,'PosteriorDensity') column=0; name1=''; else - if nargin<7 + if nargin<7 column = name2index(options_, M_, estim_params_, type, name1); else column = name2index(options_, M_, estim_params_, type, name1, name2); @@ -92,7 +92,7 @@ else end if options_.mh_nblck>1 - FigureName = [ FigureName , ' (block number ' int2str(blck) ').']; + FigureName = [ FigureName , ' (block number ' int2str(blck) ').']; end hh=dyn_figure(options_,'Name',FigureName); @@ -107,7 +107,7 @@ first = N+1; last = TotalNumberOfMhDraws-N; for t=first:last - MovingAverage(t) = mean(PosteriorDraws(t-N:t+N)); + MovingAverage(t) = mean(PosteriorDraws(t-N:t+N)); end hold on @@ -129,5 +129,41 @@ if strcmpi(type,'PosteriorDensity') else plot_name=get_the_name(column,0,M_,estim_params_,options_); end + dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'TracePlot_' plot_name],options_) +if options_.TeX + fid=fopen([M_.fname,'/graphs/',M_.fname,'_TracePlot_' plot_name,'.TeX'],'w+'); + + if strcmpi(type,'DeepParameter') + tex_names=M_.param_names_tex; + base_names=M_.param_names; + elseif strcmpi(type,'StructuralShock') + tex_names=M_.exo_names_tex; + base_names=M_.exo_names; + elseif strcmpi(type,'MeasurementError') + tex_names=M_.endo_names_tex; + base_names=M_.endo_names; + end + + if strcmpi(type,'PosteriorDensity') + FigureName = ['Trace plot for ' TYPE name1]; + else + if nargin<7 + FigureName = ['Trace plot for ' TYPE '$' deblank(tex_names(strmatch(name1,base_names,'exact'),:)) '$']; + else + FigureName = ['Trace plot for ' TYPE '$' deblank(tex_names(strmatch(name1,base_names,'exact'),:)) '$ and $' deblank(tex_names(strmatch(name2,base_names,'exact'),:)) '$']; + end + end + if options_.mh_nblck>1 + FigureName = [ FigureName , ' (block number ' int2str(blck) ').']; + end + + fprintf(fid,'%-s\n','\begin{figure}[H]'); + fprintf(fid,'%-s\n','\centering'); + fprintf(fid,'%-s\n',[' \includegraphics[scale=0.5]{',[M_.fname, '/graphs/TracePlot_' plot_name],'}\\']); + fprintf(fid,'%-s\n',[' \caption{',FigureName,'}']); + fprintf(fid,'%-s\n','\end{figure}'); + fclose(fid); +end + From 482f2bdd2c75c9ef5e69a9ae339f7fcd42dcbc57 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 16:41:41 +0100 Subject: [PATCH 02/10] Add LaTeX output to Geweke convergence diagnostics Also allows for custom header part in dyn_latex_table.m --- matlab/McMCDiagnostics.m | 42 ++++++++++++++++++++++++++++------------ matlab/dyn_latex_table.m | 36 +++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/matlab/McMCDiagnostics.m b/matlab/McMCDiagnostics.m index 540b43d63..1333f7cf8 100644 --- a/matlab/McMCDiagnostics.m +++ b/matlab/McMCDiagnostics.m @@ -90,22 +90,26 @@ if nblck == 1 % Brooks and Gelman tests need more than one block last_obs_begin_sample = first_obs_begin_sample+round(options_.convergence.geweke.geweke_interval(1)*NumberOfDraws*(1-options_.mh_drop)); first_obs_end_sample = first_obs_begin_sample+round(options_.convergence.geweke.geweke_interval(2)*NumberOfDraws*(1-options_.mh_drop)); param_name=[]; - for jj=1:npar - param_name = strvcat(param_name,get_the_name(jj,options_.TeX,M_,estim_params_,options_)); + if options_.TeX + param_name_tex=[]; + end + for jj=1:npar + if options_.TeX + [param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_); + param_name_tex = strvcat(param_name_tex,strrep(param_name_tex_temp,'$','')); + param_name = strvcat(param_name,param_name_temp); + else + param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_); + param_name = strvcat(param_name,param_name_temp); + end end fprintf('\nGeweke (1992) Convergence Tests, based on means of draws %d to %d vs %d to %d.\n',first_obs_begin_sample,last_obs_begin_sample,first_obs_end_sample,NumberOfDraws); fprintf('p-values are for Chi2-test for equality of means.\n'); - Geweke_header={'Parameter', 'Post. Mean', 'Post. Std', 'p-val No Taper'}; - print_string=['%',num2str(size(param_name,2)+3),'s \t %12.3f \t %12.3f \t %12.3f']; - print_string_header=['%',num2str(size(param_name,2)+3),'s \t %12s \t %12s \t %12s']; + Geweke_header=char('Parameter', 'Post. Mean', 'Post. Std', 'p-val No Taper'); for ii=1:length(options_.convergence.geweke.taper_steps) - Geweke_header=[Geweke_header, ['p-val ' num2str(options_.convergence.geweke.taper_steps(ii)),'% Taper']]; - print_string=[print_string,'\t %12.3f']; - print_string_header=[print_string_header,'\t %12s']; + Geweke_header=char(Geweke_header,['p-val ' num2str(options_.convergence.geweke.taper_steps(ii)),'% Taper']); end - print_string=[print_string,'\n']; - print_string_header=[print_string_header,'\n']; - fprintf(print_string_header,Geweke_header{1,:}); + datamat=NaN(npar,3+length(options_.convergence.geweke.taper_steps)); for jj=1:npar startline=0; for n = 1:NumberOfMcFilesPerBlock @@ -124,7 +128,21 @@ if nblck == 1 % Brooks and Gelman tests need more than one block results_struct = geweke_chi2_test(results_vec1,results_vec2,results_struct,options_); eval(['oo_.convergence.geweke.',param_name(jj,:),'=results_struct;']) - fprintf(print_string,param_name(jj,:),results_struct.posteriormean,results_struct.posteriorstd,results_struct.prob_chi2_test) + datamat(jj,:)=[results_struct.posteriormean,results_struct.posteriorstd,results_struct.prob_chi2_test]; + end + lh = size(param_name,2)+2; + dyntable('',Geweke_header,param_name,datamat,lh,12,3); + if options_.TeX + Geweke_tex_header=char('Parameter', 'Mean', 'Std', 'No\ Taper'); + additional_header={[' & \multicolumn{2}{c}{Posterior} & \multicolumn{',num2str(1+length(options_.convergence.geweke.taper_steps)),'}{c}{p-values} \\'], + ['\cmidrule(r{.75em}){2-3} \cmidrule(r{.75em}){4-',num2str(4+length(options_.convergence.geweke.taper_steps)),'}']}; + for ii=1:length(options_.convergence.geweke.taper_steps) + Geweke_tex_header=char(Geweke_tex_header,[num2str(options_.convergence.geweke.taper_steps(ii)),'\%%\ Taper']); + end + headers = char(Geweke_tex_header); + lh = size(param_name_tex,2)+2; + my_title=sprintf('Geweke (1992) Convergence Tests, based on means of draws %d to %d vs %d to %d. p-values are for $\\\\chi^2$-test for equality of means.',first_obs_begin_sample,last_obs_begin_sample,first_obs_end_sample,NumberOfDraws); + dyn_latex_table(M_,my_title,'geweke',headers,param_name_tex,datamat,lh,12,4,additional_header); end skipline(2); return; diff --git a/matlab/dyn_latex_table.m b/matlab/dyn_latex_table.m index 0251179e9..3bb4c92ce 100644 --- a/matlab/dyn_latex_table.m +++ b/matlab/dyn_latex_table.m @@ -1,11 +1,11 @@ -function dyn_latex_table(M_,title,LaTeXtitle,headers,labels,values,label_width,val_width,val_precis) +function dyn_latex_table(M_,title,LaTeXtitle,headers,labels,values,label_width,val_width,val_precis,optional_header) OutputDirectoryName = CheckPath('Output',M_.dname); %% get width of label column -if ~isempty(label_width) +if ~isempty(label_width) label_width = max(size(deblank(char(headers(1,:),labels)),2)+2, ... - label_width); + label_width); else %use default length label_width = max(size(deblank(char(headers(1,:),labels)),2))+2; end @@ -21,7 +21,7 @@ if any(values) < 0 %add one character for minus sign values_length = values_length+1; end -%% get width of header strings +%% get width of header strings headers_length = max(size(deblank(headers(2:end,:)),2)); if ~isempty(val_width) val_width = max(max(headers_length,values_length)+4,val_width); @@ -34,7 +34,7 @@ header_string_format = sprintf('$%%%ds$',val_width); %Create and print header string if length(headers) > 0 header_string = sprintf(label_format_leftbound ,deblank(headers(1,:))); - header_code_string='l|'; + header_code_string='l'; for i=2:size(headers,1) header_string = [header_string '\t & \t ' sprintf(header_string_format,strrep(deblank(headers(i,:)),'\','\\'))]; header_code_string= [header_code_string 'c']; @@ -49,25 +49,35 @@ fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n'); fprintf(fidTeX,'\\begin{center}\n'); fprintf(fidTeX,['\\begin{longtable}{%s} \n'],header_code_string); - fprintf(fidTeX,['\\caption{',title,'}\\\\\n ']); + fprintf(fidTeX,['\\label{Table:',LaTeXtitle,'}\\\\\n']); -fprintf(fidTeX,'\\hline\\hline \\\\ \n'); +fprintf(fidTeX,'\\toprule \n'); +if nargin==10 + for ii=1:size(optional_header,1) + fprintf(fidTeX,'%s\n',optional_header{ii}); + end +end fprintf(fidTeX,header_string); -fprintf(fidTeX,'\\hline \\endfirsthead \n'); +fprintf(fidTeX,'\\midrule \\endfirsthead \n'); fprintf(fidTeX,'\\caption{(continued)}\\\\\n '); -fprintf(fidTeX,'\\hline\\hline \\\\ \n'); +fprintf(fidTeX,'\\toprule \\\\ \n'); +if nargin==10 + for ii=1:size(optional_header,1) + fprintf(fidTeX,'%s\n',optional_header{ii}); + end +end fprintf(fidTeX,header_string); -fprintf(fidTeX,'\\hline \\endhead \n'); -fprintf(fidTeX,['\\hline \\multicolumn{',num2str(size(headers,1)),'}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n']); -fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n'); +fprintf(fidTeX,'\\midrule \\endhead \n'); +fprintf(fidTeX,['\\bottomrule \\multicolumn{',num2str(size(headers,1)),'}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n']); +fprintf(fidTeX,'\\bottomrule \\endlastfoot \n'); for i=1:size(values,1) fprintf(fidTeX,label_format_leftbound,deblank(labels(i,:))); fprintf(fidTeX,['\t & \t' value_format],values(i,:)); fprintf(fidTeX,' \\\\ \n'); end -fprintf(fidTeX,'\\end{longtable}\n '); +fprintf(fidTeX,'\\end{longtable}\n '); fprintf(fidTeX,'\\end{center}\n'); fprintf(fidTeX,'%% End of TeX file.\n'); fclose(fidTeX); \ No newline at end of file From df4bc5c5c80868053c005120ad9a38915728e63f Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 16:42:20 +0100 Subject: [PATCH 03/10] Use TeX-name for caption in shock decomposition graphs --- matlab/graph_decomp.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/graph_decomp.m b/matlab/graph_decomp.m index abf1bc9fe..f1ef56e47 100644 --- a/matlab/graph_decomp.m +++ b/matlab/graph_decomp.m @@ -105,7 +105,7 @@ for j=1:nvar fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,['\\includegraphics[scale=0.5]{%s_shock_decomposition_%s}\n'],DynareModel.fname,deblank(endo_names(i_var(j),:))); fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',deblank(endo_names(i_var(j),:))); - fprintf(fidTeX,'\\caption{Historical shock decomposition: %s}\n',deblank(endo_names(i_var(j),:))); + fprintf(fidTeX,'\\caption{Historical shock decomposition: $ %s $}\n',deblank(DynareModel.endo_names_tex(i_var(j),:))); fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,' \n'); end From aafa3e15b98b8257847e0ad332f06eca2af5bcb5 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 16:42:52 +0100 Subject: [PATCH 04/10] Modularize display_estimation_results_table.m --- matlab/display_estimation_results_table.m | 304 ++++++---------------- 1 file changed, 74 insertions(+), 230 deletions(-) diff --git a/matlab/display_estimation_results_table.m b/matlab/display_estimation_results_table.m index d813d3f5a..93fa62102 100644 --- a/matlab/display_estimation_results_table.m +++ b/matlab/display_estimation_results_table.m @@ -179,24 +179,7 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior 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,'\\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'); + TeXBegin_Bayesian(fidTeX,1,'parameters') ip = nvx+nvn+ncx+ncn+1; for i=1:np fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',... @@ -208,33 +191,12 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior 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); + TeXEnd(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'); + TeXBegin_Bayesian(fidTeX,2,'standard deviation of structural shocks') ip = 1; for i=1:nvx k = estim_params_.var_exo(i,1); @@ -247,33 +209,12 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior 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); + TeXEnd(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'); + TeXBegin_Bayesian(fidTeX,3,'standard deviation of measurement errors') ip = nvx+1; for i=1:nvn idx = strmatch(options_.varobs{estim_params_.nvn_observable_correspondence(i,1)},M_.endo_names); @@ -286,33 +227,12 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior 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); + TeXEnd(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'); + TeXBegin_Bayesian(fidTeX,4,'correlation of structural shocks') ip = nvx+nvn+1; for i=1:ncx k1 = estim_params_.corrx(i,1); @@ -326,33 +246,12 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior 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); + TeXEnd(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'); + TeXBegin_Bayesian(fidTeX,5,'correlation of measurement errors') ip = nvx+nvn+ncx+1; for i=1:ncn k1 = estim_params_.corrn(i,1); @@ -366,34 +265,13 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior 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); + TeXEnd(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'); + TeXBegin_ML(fidTeX,1,'parameters',table_title,LaTeXtitle) ip = nvx+nvn+ncx+ncn+1; for i=1:np fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n',... @@ -403,33 +281,12 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output 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); + TeXEnd(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'); + TeXBegin_ML(fidTeX,2,'standard deviation of structural shocks',table_title,LaTeXtitle) ip = 1; for i=1:nvx k = estim_params_.var_exo(i,1); @@ -440,33 +297,12 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output 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); + TeXEnd(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'); + TeXBegin_ML(fidTeX,3,'standard deviation of measurement errors',table_title,LaTeXtitle) ip = nvx+1; for i=1:nvn idx = strmatch(options_.varobs{estim_params_.nvn_observable_correspondence(i,1)},M_.endo_names); @@ -477,33 +313,12 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output 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); + TeXEnd(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'); + TeXBegin_ML(fidTeX,4,'correlation of structural shocks',table_title,LaTeXtitle) ip = nvx+nvn+1; for i=1:ncx k1 = estim_params_.corrx(i,1); @@ -515,33 +330,12 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output 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); + TeXEnd(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'); + TeXBegin_ML(fidTeX,5,'correlation of measurement errors',table_title,LaTeXtitle) ip = nvx+nvn+ncx+1; for i=1:ncn k1 = estim_params_.corrn(i,1); @@ -553,10 +347,60 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output 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 - + TeXEnd(fidTeX) end + + + +%% subfunctions: +% +function TeXBegin_Bayesian(fid,fnum,title) + fprintf(fid,'%% TeX-table generated by dynare_estimation (Dynare).\n'); + fprintf(fid,['%% RESULTS FROM POSTERIOR MAXIMIZATION (' title ')\n']); + fprintf(fid,['%% ' datestr(now,0)]); + fprintf(fid,' \n'); + fprintf(fid,' \n'); + fprintf(fid,'\\begin{center}\n'); + fprintf(fid,'\\begin{longtable}{llcccc} \n'); + fprintf(fid,['\\caption{Results from posterior maximization (' title ')}\\\\\n ']); + fprintf(fid,['\\label{Table:Posterior:' int2str(fnum) '}\\\\\n']); + fprintf(fid,'\\toprule \n'); + fprintf(fid,' & \\multicolumn{3}{c}{Prior} & \\multicolumn{2}{c}{Posterior} \\\\\n'); + fprintf(fid,' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-6}\n'); + fprintf(fid,' & Dist. & Mean & Stdev & Mode & Stdev \\\\ \n'); + fprintf(fid,'\\midrule \\endfirsthead \n'); + fprintf(fid,'\\caption{(continued)}\\\\\n '); + fprintf(fid,'\\bottomrule \n'); + fprintf(fid,' & \\multicolumn{3}{c}{Prior} & \\multicolumn{2}{c}{Posterior} \\\\\n'); + fprintf(fid,' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-6}\n'); + fprintf(fid,' & Dist. & Mean & Stdev & Mode & Stdev \\\\ \n'); + fprintf(fid,'\\midrule \\endhead \n'); + fprintf(fid,'\\bottomrule \\multicolumn{6}{r}{(Continued on next page)}\\endfoot \n'); + fprintf(fid,'\\bottomrule\\endlastfoot \n'); + + function TeXBegin_ML(fid,fnum,title,table_title,LaTeXtitle) + fprintf(fid,'%% TeX-table generated by dynare_estimation (Dynare).\n'); + fprintf(fid,['%% RESULTS FROM ' table_title ' MAXIMIZATION (' title ')\n']); + fprintf(fid,['%% ' datestr(now,0)]); + fprintf(fid,' \n'); + fprintf(fid,' \n'); + fprintf(fid,'\\begin{center}\n'); + fprintf(fid,'\\begin{longtable}{llcc} \n'); + fprintf(fid,['\\caption{Results from ' table_title ' maximization (' title ')}\\\\\n ']); + fprintf(fid,['\\label{Table:' LaTeXtitle ':' int2str(fnum) '}\\\\\n']); + fprintf(fid,'\\toprule \n'); + fprintf(fid,' & Mode & s.d. & t-stat\\\\ \n'); + fprintf(fid,'\\midrule \\endfirsthead \n'); + fprintf(fid,'\\caption{(continued)}\\\\\n '); + fprintf(fid,'\\toprule \n'); + fprintf(fid,' & Mode & s.d. & t-stat\\\\ \n'); + fprintf(fid,'\\midrule \\endhead \n'); + fprintf(fid,'\\bottomrule \\multicolumn{4}{r}{(Continued on next page)} \\endfoot \n'); + fprintf(fid,'\\bottomrule \\endlastfoot \n'); + +function TeXEnd(fid) +fprintf(fid,'\\end{longtable}\n '); +fprintf(fid,'\\end{center}\n'); +fprintf(fid,'%% End of TeX file.\n'); +fclose(fid); \ No newline at end of file From 246ea146d182c2d24182a765611486a53a61a53c Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 16:43:25 +0100 Subject: [PATCH 05/10] Use booktabs package for neater table output --- matlab/GetPosteriorParametersStatistics.m | 27 ++++++++++++----------- matlab/write_latex_parameter_table.m | 10 ++++----- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/matlab/GetPosteriorParametersStatistics.m b/matlab/GetPosteriorParametersStatistics.m index 7ecbd7b12..a8ee9a58b 100644 --- a/matlab/GetPosteriorParametersStatistics.m +++ b/matlab/GetPosteriorParametersStatistics.m @@ -336,22 +336,23 @@ fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n'); fprintf(fidTeX,'\\begin{center}\n'); -fprintf(fidTeX,'\\begin{longtable}{l|lcccccc} \n'); +fprintf(fidTeX,'\\begin{longtable}{llcccccc} \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']); -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,'\\toprule \n'); +fprintf(fidTeX,' & \\multicolumn{3}{c}{Prior} & \\multicolumn{4}{c}{Posterior} \\\\\n'); +fprintf(fidTeX,' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-8}\n'); +fprintf(fidTeX,' & Dist. & Mean & Stdev. & Mean & Stdev. & HPD inf & HPD sup\\\\\n'); +fprintf(fidTeX,'\\midrule \\endfirsthead \n'); +fprintf(fidTeX,['\\caption{(continued)}\\\\']); +fprintf(fidTeX,'\\toprule \n'); +fprintf(fidTeX,' & \\multicolumn{3}{c}{Prior} & \\multicolumn{4}{c}{Posterior} \\\\\n'); +fprintf(fidTeX,' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-8}\n'); +fprintf(fidTeX,' & Dist. & Mean & Stdev. & Mean & Stdev. & HPD inf & HPD sup\\\\\n'); +fprintf(fidTeX,'\\midrule \\endhead \n'); -fprintf(fidTeX,'\\hline \\multicolumn{8}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n'); -fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n'); +fprintf(fidTeX,'\\bottomrule \\multicolumn{8}{r}{(Continued on next page)} \\endfoot \n'); +fprintf(fidTeX,'\\bottomrule \\endlastfoot \n'); fid = fidTeX; diff --git a/matlab/write_latex_parameter_table.m b/matlab/write_latex_parameter_table.m index 646adbe49..c2d739801 100644 --- a/matlab/write_latex_parameter_table.m +++ b/matlab/write_latex_parameter_table.m @@ -45,7 +45,7 @@ else end fprintf(fid, ['\\caption{Parameter Values}\\\\%%\n']); -fprintf(fid, '\\hline%%\n'); +fprintf(fid, '\\toprule%%\n'); fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Parameter}} &\n'); fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Value}} '); if Long_names_present==1; @@ -53,7 +53,7 @@ if Long_names_present==1; else fprintf(fid, ' \\\\%%\n'); end -fprintf(fid, '\\hline\\hline%%\n'); +fprintf(fid, '\\midrule%%\n'); fprintf(fid, '\\endfirsthead\n'); if Long_names_present==1; @@ -61,7 +61,7 @@ if Long_names_present==1; else fprintf(fid, '\\multicolumn{2}{c}{{\\tablename} \\thetable{} -- Continued}\\\\%%\n'); end -fprintf(fid, '\\hline%%\n'); +fprintf(fid, '\\midrule%%\n'); fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Parameter}} &\n'); fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Value}} '); if Long_names_present==1; @@ -69,7 +69,7 @@ if Long_names_present==1; else fprintf(fid, '\\\\%%\n'); end -fprintf(fid, '\\hline\\hline%%\n'); +fprintf(fid, '\\midrule%%\n'); fprintf(fid, '\\endhead\n'); tex = M_.param_names_tex; @@ -90,7 +90,7 @@ else M_.params(j,:)); end end -fprintf(fid, '\\hline%%\n'); +fprintf(fid, '\\bottomrule%%\n'); fprintf(fid, '\\end{longtable}\n'); fprintf(fid, '\\end{center}\n'); From 9cea813249bd551976c98b1ab1ad7553e3d3dccf Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 16:57:25 +0100 Subject: [PATCH 06/10] Add missing packages to collect_LaTeX_Files.m and manual --- doc/dynare.texi | 5 +++-- matlab/collect_LaTeX_Files.m | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 1390e8407..5db450d88 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -9573,8 +9573,9 @@ following @LaTeX{} packages: @code{longtable} Writes a @LaTeX{} file named @code{<>_TeX_binder.tex} that collects all @TeX{} output generated by Dynare into a file. This file can be compiled using pdflatex and automatically tries to load all required packages. -Requires the following @LaTeX{} packages: @code{longtable}, @code{psfrag}, -@code{graphicx}, @code{epstopdf}, @code{longtable}, and @code{float} +Requires the following @LaTeX{} packages: @code{breqn}, @code{psfrag}, +@code{graphicx}, @code{epstopdf}, @code{longtable}, @code{booktabs}, @code{caption}, +@code{float}, and @code{morefloats} @end deffn diff --git a/matlab/collect_LaTeX_Files.m b/matlab/collect_LaTeX_Files.m index d6cb76d56..142df191c 100644 --- a/matlab/collect_LaTeX_Files.m +++ b/matlab/collect_LaTeX_Files.m @@ -30,13 +30,14 @@ function collect_LaTeX_Files(M_) f_name_binder=[M_.fname,'_TeX_binder.TeX']; fid=fopen(f_name_binder,'w+'); fprintf(fid,'%s \n','\documentclass[12pt]{article}'); +fprintf(fid,'%s \n','\usepackage[margin=2cm]{geometry}'); fprintf(fid,'%s \n','\usepackage{psfrag}'); fprintf(fid,'%s \n','\usepackage{graphicx}'); fprintf(fid,'%s \n','\usepackage{epstopdf}'); -fprintf(fid,'%s \n','\usepackage{longtable}'); +fprintf(fid,'%s \n','\usepackage{longtable,booktabs}'); fprintf(fid,'%s \n','\usepackage{amsfonts}'); fprintf(fid,'%s \n','\usepackage{breqn}'); -fprintf(fid,'%s \n','\usepackage{float}'); +fprintf(fid,'%s \n','\usepackage{float,morefloats,caption}'); fprintf(fid,'%s \n','\begin{document}'); %% Root directory From 1c630a8172d5d21444b2d26bac3332ca6b9167c4 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 13 Dec 2015 17:45:10 +0100 Subject: [PATCH 07/10] Add trace_plot to LaTeX unit test --- tests/TeX/fs2000_corr_ME.mod | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/TeX/fs2000_corr_ME.mod b/tests/TeX/fs2000_corr_ME.mod index dc7a6a277..824867d31 100644 --- a/tests/TeX/fs2000_corr_ME.mod +++ b/tests/TeX/fs2000_corr_ME.mod @@ -160,7 +160,11 @@ stderr gp_obs, inv_gamma_pdf, 0.001, inf; //corr gp_obs, gy_obs,normal_pdf, 0, 0.2; end; -estimation(mode_compute=9,order=1,datafile='../fs2000/fsdat_simul',mode_check,smoother,filter_decomposition,mh_replic=2002, mh_nblocks=2, mh_jscale=0.8,forecast = 8,bayesian_irf,filtered_vars,filter_step_ahead=[1,3],irf=20,moments_varendo,contemporaneous_correlation) m P c e W R k d y; +estimation(mode_compute=9,order=1,datafile='../fs2000/fsdat_simul',mode_check,smoother,filter_decomposition,mh_replic=4000, mh_nblocks=1, mh_jscale=0.8,forecast = 8,bayesian_irf,filtered_vars,filter_step_ahead=[1,3],irf=20,moments_varendo,contemporaneous_correlation) m P c e W R k d y; + +trace_plot(options_,M_,estim_params_,'PosteriorDensity',1); +trace_plot(options_,M_,estim_params_,'StructuralShock',1,'eps_a') + shock_decomposition y W R; collect_LaTeX_Files(M_); From 4f9b141c76f18f390856966ed26b00f9278fd059 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 14 Dec 2015 11:26:33 +0100 Subject: [PATCH 08/10] Add eps-loaders to identification codes --- matlab/collect_LaTeX_Files.m | 11 ++- matlab/dynare_identification.m | 65 ++++++++------ matlab/plot_identification.m | 117 ++++++++++++++++++++++++- tests/identification/as2007/as2007.mod | 7 +- 4 files changed, 168 insertions(+), 32 deletions(-) diff --git a/matlab/collect_LaTeX_Files.m b/matlab/collect_LaTeX_Files.m index 142df191c..cbf9e336d 100644 --- a/matlab/collect_LaTeX_Files.m +++ b/matlab/collect_LaTeX_Files.m @@ -61,7 +61,7 @@ for ii=1:length(TeX_Files) end end -%5 graphs directory +%% graphs directory TeX_Files=dir([M_.dname filesep 'graphs' filesep M_.fname '*.TeX']); for ii=1:length(TeX_Files) [pathstr,f_name,ext] = fileparts(TeX_Files(ii).name); @@ -70,6 +70,15 @@ for ii=1:length(TeX_Files) end end +%% Identification directory +TeX_Files=dir([M_.dname filesep 'identification' filesep M_.fname '*.TeX']); +for ii=1:length(TeX_Files) + [pathstr,f_name,ext] = fileparts(TeX_Files(ii).name); + if ~strcmp(TeX_Files(ii).name,f_name_binder) + fprintf(fid,'%s \n',['\include{', M_.dname '/identification' '/',f_name,'}']); + end +end + %% Write footer fprintf(fid,'%s \n','\end{document}'); diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index 2da320f4c..b765ddf17 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -234,37 +234,44 @@ if iload <=0, params = set_prior(estim_params_,M_,options_)'; if all(bayestopt_.pshape == 0) parameters = 'ML_Starting_value'; + parameters_TeX = 'ML starting value'; disp('Testing ML Starting value') else - switch parameters - case 'posterior_mode' - disp('Testing posterior mode') - params(1,:) = get_posterior_parameters('mode'); - case 'posterior_mean' - disp('Testing posterior mean') - params(1,:) = get_posterior_parameters('mean'); - case 'posterior_median' - disp('Testing posterior median') - params(1,:) = get_posterior_parameters('median'); - case 'prior_mode' - disp('Testing prior mode') - params(1,:) = bayestopt_.p5(:); - case 'prior_mean' - disp('Testing prior mean') - params(1,:) = bayestopt_.p1; - otherwise - disp('The option parameter_set has to be equal to:') - disp(' ''posterior_mode'', ') - disp(' ''posterior_mean'', ') - disp(' ''posterior_median'', ') - disp(' ''prior_mode'' or') - disp(' ''prior_mean''.') - error; - end + switch parameters + case 'posterior_mode' + parameters_TeX = 'Posterior mode'; + disp('Testing posterior mode') + params(1,:) = get_posterior_parameters('mode'); + case 'posterior_mean' + parameters_TeX = 'Posterior mean'; + disp('Testing posterior mean') + params(1,:) = get_posterior_parameters('mean'); + case 'posterior_median' + parameters_TeX = 'Posterior median'; + disp('Testing posterior median') + params(1,:) = get_posterior_parameters('median'); + case 'prior_mode' + parameters_TeX = 'Prior mode'; + disp('Testing prior mode') + params(1,:) = bayestopt_.p5(:); + case 'prior_mean' + parameters_TeX = 'Prior mean'; + disp('Testing prior mean') + params(1,:) = bayestopt_.p1; + otherwise + disp('The option parameter_set has to be equal to:') + disp(' ''posterior_mode'', ') + disp(' ''posterior_mean'', ') + disp(' ''posterior_median'', ') + disp(' ''prior_mode'' or') + disp(' ''prior_mean''.') + error; + end end else params = [sqrt(diag(M_.Sigma_e))', M_.params']; parameters = 'Current_params'; + parameters_TeX = 'Current parameter values'; disp('Testing current parameter values') end [idehess_point, idemoments_point, idemodel_point, idelre_point, derivatives_info_point, info] = ... @@ -339,7 +346,7 @@ if iload <=0, save([IdentifDirectoryName '/' M_.fname '_' parameters '_identif.mat'], 'idehess_point', 'idemoments_point','idemodel_point', 'idelre_point','store_options_ident') disp_identification(params, idemodel_point, idemoments_point, name, advanced); if ~options_.nograph, - plot_identification(params,idemoments_point,idehess_point,idemodel_point,idelre_point,advanced,parameters,name,IdentifDirectoryName); + plot_identification(params,idemoments_point,idehess_point,idemodel_point,idelre_point,advanced,parameters,name,IdentifDirectoryName,parameters_TeX); end if SampleSize > 1, @@ -541,7 +548,7 @@ if SampleSize > 1, disp_identification(pdraws(jmax,:), idemodel_max, idemoments_max, name,1); close all, if ~options_.nograph, - plot_identification(pdraws(jmax,:),idemoments_max,idehess_max,idemodel_max,idelre_max,1,tittxt,name,IdentifDirectoryName); + plot_identification(pdraws(jmax,:),idemoments_max,idehess_max,idemodel_max,idelre_max,1,tittxt,name,IdentifDirectoryName,tittxt); end [dum,jmin]=min(idemoments.cond); fprintf('\n') @@ -556,7 +563,7 @@ if SampleSize > 1, disp_identification(pdraws(jmin,:), idemodel_min, idemoments_min, name,1); close all, if ~options_.nograph, - plot_identification(pdraws(jmin,:),idemoments_min,idehess_min,idemodel_min,idelre_min,1,tittxt,name,IdentifDirectoryName); + plot_identification(pdraws(jmin,:),idemoments_min,idehess_min,idemodel_min,idelre_min,1,tittxt,name,IdentifDirectoryName,tittxt); end else for j=1:length(jcrit), @@ -570,7 +577,7 @@ if SampleSize > 1, disp_identification(pdraws(jcrit(j),:), idemodel_(j), idemoments_(j), name,1); close all, if ~options_.nograph, - plot_identification(pdraws(jcrit(j),:),idemoments_(j),idehess_(j),idemodel_(j),idelre_(j),1,tittxt,name,IdentifDirectoryName); + plot_identification(pdraws(jcrit(j),:),idemoments_(j),idehess_(j),idemodel_(j),idelre_(j),1,tittxt,name,IdentifDirectoryName,tittxt); end end if ~iload, diff --git a/matlab/plot_identification.m b/matlab/plot_identification.m index 16e4a83d1..e3a20013a 100644 --- a/matlab/plot_identification.m +++ b/matlab/plot_identification.m @@ -1,4 +1,4 @@ -function plot_identification(params,idemoments,idehess,idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName) +function plot_identification(params,idemoments,idehess,idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName,tit_TeX) % function plot_identification(params,idemoments,idehess,idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName) % % INPUTS @@ -11,6 +11,7 @@ function plot_identification(params,idemoments,idehess,idemodel, idelre, advance % o tittxt [char] name of the results to plot % o name [char] list of names % o IdentifDirectoryName [char] directory name +% o tittxt [char] TeX-name of the results to plot % % OUTPUTS % None @@ -101,6 +102,19 @@ if SampleSize == 1, else title('Sensitivity component with moments Information matrix (log-scale)') end + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1,'.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_ident_strength_%s}\n',[IdentifDirectoryName '/' M_.fname],tittxt1); + fprintf(fidTeX,'\\caption{%s - Identification using info from observables.}',tit_TeX); + fprintf(fidTeX,'\\label{Fig:ident:%s}\n',deblank(tittxt)); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_); if advanced, @@ -131,6 +145,19 @@ if SampleSize == 1, legend('Moments','Model','LRE model','Location','Best') title('Sensitivity bars using derivatives (log-scale)') dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1,'.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_sensitivity_%s}\n',[IdentifDirectoryName '/' M_.fname],tittxt1); + fprintf(fidTeX,'\\caption{%s - Sensitivity plot.}',tit_TeX); + fprintf(fidTeX,'\\label{Fig:sensitivity:%s}\n',deblank(tittxt)); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end % identificaton patterns for j=1:size(idemoments.cosnJ,2), @@ -171,6 +198,19 @@ if SampleSize == 1, set(gca,'ygrid','on') xlabel([tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)'],'interpreter','none') dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j),'.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_ident_collinearity_%s_%u}\n',[IdentifDirectoryName '/' M_.fname],tittxt1,j); + fprintf(fidTeX,'\\caption{%s - Collinearity patterns with %u parameter(s).}',tit_TeX,j); + fprintf(fidTeX,'\\label{Fig:collinearity:%s:%u_pars}\n',deblank(tittxt),j); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end skipline() [U,S,V]=svd(idehess.AHess,0); @@ -178,18 +218,24 @@ if SampleSize == 1, if idehess.flag_score, if nparam<5, f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix)']); + tex_tit_1=[tittxt,' - Identification patterns (Information matrix)']; else f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix): SMALLEST SV']); + tex_tit_1=[tittxt,' - Identification patterns (Information matrix): SMALLEST SV']; f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']); + tex_tit_2=[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']; end else % S = idemoments.S; % V = idemoments.V; if nparam<5, f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix)']); + tex_tit_1=[tittxt,' - Identification patterns (moments Information matrix)']; else f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix): SMALLEST SV']); + tex_tit_1=[tittxt,' - Identification patterns (moments Information matrix): SMALLEST SV']; f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV']); + tex_tit_2=[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV']; end end for j=1:min(nparam,8), @@ -217,8 +263,34 @@ if SampleSize == 1, title(['Singular value ',num2str(Stit)]) end dyn_saveas(f1,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1' ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1','.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_ident_pattern_%s_1}\n',[IdentifDirectoryName '/' M_.fname],tittxt1); + fprintf(fidTeX,'\\caption{%s.}',tex_tit_1); + fprintf(fidTeX,'\\label{Fig:ident_pattern:%s:1}\n',tittxt1); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end if nparam>4, dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2' ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_ident_pattern_%s_2}\n',[IdentifDirectoryName '/' M_.fname],tittxt1); + fprintf(fidTeX,'\\caption{%s.}',tex_tit_2); + fprintf(fidTeX,'\\label{Fig:ident_pattern:%s:2}\n',tittxt1); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end end @@ -250,6 +322,20 @@ else end title('MC mean of sensitivity measures') dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_MC_sensitivity' ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_sensitivity.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_MC_sensitivity}\n',[IdentifDirectoryName '/' M_.fname]); + fprintf(fidTeX,'\\caption{MC mean of sensitivity measures}'); + fprintf(fidTeX,'\\label{Fig:_MC_sensitivity}\n'); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end + if advanced, if ~options_.nodisplay, skipline() @@ -304,9 +390,12 @@ else if nparam<5, f1 = dyn_figure(options_,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']); + tex_tit_1=[tittxt,' - MC Identification patterns (moments): HIGHEST SV']; else f1 = dyn_figure(options_,'Name',[tittxt,' - MC Identification patterns (moments): SMALLEST SV']); + tex_tit_1=[tittxt,' - MC Identification patterns (moments): SMALLEST SV']; f2 = dyn_figure(options_,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']); + tex_tit_2=[tittxt,' - MC Identification patterns (moments): HIGHEST SV']; end nplots=min(nparam,8); if nplots>4, @@ -343,8 +432,34 @@ else title(['MEAN Singular value ',num2str(Stit)]) end dyn_saveas(f1,[IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1' ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_MC_ident_pattern_1}\n',[IdentifDirectoryName '/' M_.fname]); + fprintf(fidTeX,'\\caption{%s.}',tex_tit_1); + fprintf(fidTeX,'\\label{Fig:MC_ident_pattern:1}\n'); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end if nparam>4, dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2' ],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_MC_ident_pattern_2}\n',[IdentifDirectoryName '/' M_.fname]); + fprintf(fidTeX,'\\caption{%s.}',tex_tit_2); + fprintf(fidTeX,'\\label{Fig:MC_ident_pattern:2}\n'); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end end end diff --git a/tests/identification/as2007/as2007.mod b/tests/identification/as2007/as2007.mod index f2b813e12..7e6f0313c 100644 --- a/tests/identification/as2007/as2007.mod +++ b/tests/identification/as2007/as2007.mod @@ -59,7 +59,12 @@ stderr 1; var e_z; stderr 1; end; - +options_.TeX=1; identification; identification(advanced=1,max_dim_cova_group=3,prior_mc=250); + +collect_LaTeX_Files(M_); +if system(['pdflatex -halt-on-error ' M_.fname '_TeX_binder.TeX']) + error('TeX-File did not compile.') +end \ No newline at end of file From 877b2cbb808439d3e42c820056d7758e29f85914 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 14 Dec 2015 11:27:00 +0100 Subject: [PATCH 09/10] Use longtable for collinearity pattern table --- matlab/ident_bruteforce.m | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/matlab/ident_bruteforce.m b/matlab/ident_bruteforce.m index 57a54984c..a2234f531 100644 --- a/matlab/ident_bruteforce.m +++ b/matlab/ident_bruteforce.m @@ -73,14 +73,22 @@ for ll = 1:n, fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n'); + fprintf(fidTeX,'{\\tiny \n'); - fprintf(fidTeX,'\\begin{table}\n'); - fprintf(fidTeX,'\\centering\n'); - fprintf(fidTeX,'\\begin{tabular}{l|lc} \n'); - fprintf(fidTeX,'\\hline\\hline \\\\ \n'); + fprintf(fidTeX,'\\begin{longtable}{llc} \n'); + fprintf(fidTeX,['\\caption{Collinearity patterns with ',int2str(ll),' parameter(s)}\n ']); + fprintf(fidTeX,['\\label{Table:CollinearityPatterns:',int2str(ll),'}\\\\\n']); + fprintf(fidTeX,'\\toprule \n'); fprintf(fidTeX,' Parameter & Explanatory & cosn \\\\ \n'); fprintf(fidTeX,' & parameter(s) & \\\\ \n'); - fprintf(fidTeX,'\\hline \\\\ \n'); + fprintf(fidTeX,'\\midrule \\endfirsthead \n'); + fprintf(fidTeX,'\\caption{(continued)}\\\\\n '); + fprintf(fidTeX,'\\bottomrule \n'); + fprintf(fidTeX,' Parameter & Explanatory & cosn \\\\ \n'); + fprintf(fidTeX,' & parameter(s) & \\\\ \n'); + fprintf(fidTeX,'\\midrule \\endhead \n'); + fprintf(fidTeX,'\\bottomrule \\multicolumn{3}{r}{(Continued on next page)}\\endfoot \n'); + fprintf(fidTeX,'\\bottomrule\\endlastfoot \n'); for i=1:k, plist=''; for ii=1:ll, @@ -93,11 +101,8 @@ for ll = 1:n, plist,... cosnJ(i,ll)); end - fprintf(fidTeX,'\\hline\\hline \n'); - fprintf(fidTeX,'\\end{tabular}\n '); - fprintf(fidTeX,['\\caption{Collinearity patterns with ',int2str(ll),' parameter(s)}\n ']); - fprintf(fidTeX,['\\label{Table:CollinearityPatterns:',int2str(ll),'}\n']); - fprintf(fidTeX,'\\end{table}\n'); + fprintf(fidTeX,'\\bottomrule \n'); + fprintf(fidTeX,'\\end{longtable}\n'); fprintf(fidTeX,'} \n'); fprintf(fidTeX,'%% End of TeX file.\n'); fclose(fidTeX); From e5894c41572ad67a4016412019858b31abec7030 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 14 Dec 2015 14:09:37 +0100 Subject: [PATCH 10/10] Add eps-loaders to GSA output --- matlab/collect_LaTeX_Files.m | 9 +++++++++ matlab/gsa/filt_mc_.m | 34 ++++++++++++++++++++++++++++++++-- matlab/gsa/map_calibration.m | 17 ++++++++++++++++- matlab/gsa/map_ident_.m | 26 ++++++++++++++++++++++++-- matlab/gsa/redform_map.m | 33 ++++++++++++++++++++++++++++++--- matlab/gsa/redform_screen.m | 26 ++++++++++++++++++++++++-- matlab/gsa/scatter_mcf.m | 13 +++++++++++++ matlab/gsa/stab_map_1.m | 26 ++++++++++++++++++++++++++ matlab/gsa/stab_map_2.m | 26 ++++++++++++++++++++++++++ tests/gsa/ls2003.mod | 6 +++++- 10 files changed, 205 insertions(+), 11 deletions(-) diff --git a/matlab/collect_LaTeX_Files.m b/matlab/collect_LaTeX_Files.m index cbf9e336d..961a41947 100644 --- a/matlab/collect_LaTeX_Files.m +++ b/matlab/collect_LaTeX_Files.m @@ -79,6 +79,15 @@ for ii=1:length(TeX_Files) end end +%% GSA directory +TeX_Files=dir([M_.dname filesep 'gsa' filesep M_.fname '*.TeX']); +for ii=1:length(TeX_Files) + [pathstr,f_name,ext] = fileparts(TeX_Files(ii).name); + if ~strcmp(TeX_Files(ii).name,f_name_binder) + fprintf(fid,'%s \n',['\include{', M_.dname '/gsa' '/',f_name,'}']); + end +end + %% Write footer fprintf(fid,'%s \n','\end{document}'); diff --git a/matlab/gsa/filt_mc_.m b/matlab/gsa/filt_mc_.m index 60fb43976..8809f4baf 100644 --- a/matlab/gsa/filt_mc_.m +++ b/matlab/gsa/filt_mc_.m @@ -366,11 +366,14 @@ else end if options_.opt_gsa.ppost dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],options_); + create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnprior') else if options_.opt_gsa.pprior dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnprior',int2str(ifig) ],options_); + create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnprior') else dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnprior',int2str(ifig) ],options_); + create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnprior') end end end @@ -408,12 +411,15 @@ else end if options_.opt_gsa.ppost dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnlik',int2str(ifig) ],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnprio') else if options_.opt_gsa.pprior dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnlik') else dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],options_); - end + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnlik') + end end end end @@ -450,11 +456,14 @@ else end if options_.opt_gsa.ppost dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnpost') else if options_.opt_gsa.pprior dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnpost') else dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnpost') end end end @@ -662,11 +671,14 @@ else %set(findobj(get(h0,'children'),'type','text'),'interpreter','none') if options_.opt_gsa.ppost dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_); + create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],ix,[temp_name,' observed variable ',deblank(vvarvecm(iy,:))],['rmse_post_' deblank(vvarvecm(iy,:))]) else if options_.opt_gsa.pprior dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],ix,[temp_name,' observed variable ',deblank(vvarvecm(iy,:))],['rmse_prior_' deblank(vvarvecm(iy,:))]) else dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],ix,[temp_name,' observed variable ',deblank(vvarvecm(iy,:))],['rmse_mc_' deblank(vvarvecm(iy,:))]) end end end @@ -720,11 +732,14 @@ else %set(findobj(get(h0,'children'),'type','text'),'interpreter','none') if options_.opt_gsa.ppost dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_); + create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_post_params') else if options_.opt_gsa.pprior dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_prior_params') else dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],options_); + create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_mc_params') end end end @@ -789,4 +804,19 @@ else % % close all % end -end \ No newline at end of file +end + +function []=create_TeX_loader(options_,figpath,label_number,caption,label_name) +if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([figpath '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by filt_mc_.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',strrep(figpath,'\','/')); + fprintf(fidTeX,'\\caption{%s.}',caption); + fprintf(fidTeX,'\\label{Fig:%s:%u}\n',label_name,label_number); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); +end diff --git a/matlab/gsa/map_calibration.m b/matlab/gsa/map_calibration.m index 6dae9fe51..19052edb2 100644 --- a/matlab/gsa/map_calibration.m +++ b/matlab/gsa/map_calibration.m @@ -303,8 +303,8 @@ if ~isempty(indx_irf), end if ~DynareOptions.nograph, dyn_saveas(h1,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],DynareOptions); + create_TeX_loader(options_,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],[type ' evaluation of irf restrictions'],'irf_restrictions',type) end - skipline() end @@ -495,9 +495,24 @@ if ~isempty(indx_moment) end if ~DynareOptions.nograph, dyn_saveas(h2,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],DynareOptions); + create_TeX_loader(options_,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],[type ' evaluation of moment restrictions'],'moment_restrictions',type) end skipline() end return +function []=create_TeX_loader(options_,figpath,caption,label_name,label_type) +if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([figpath '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by map_calibration.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',strrep(figpath,'\','/')); + fprintf(fidTeX,'\\caption{%s.}',caption); + fprintf(fidTeX,'\\label{Fig:%s:%s}\n',label_name,label_type); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); +end diff --git a/matlab/gsa/map_ident_.m b/matlab/gsa/map_ident_.m index 61db1cafd..2ce547480 100644 --- a/matlab/gsa/map_ident_.m +++ b/matlab/gsa/map_ident_.m @@ -100,6 +100,7 @@ if opt_gsa.load_ident_files==0, title(M_.exo_names(j,:),'interpreter','none') if mod(j,6)==0 | j==M_.exo_nbr, dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_); + create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],ifig,['Variance decomposition shocks'],'vdec_exo') end end end @@ -223,6 +224,7 @@ if opt_gsa.morris==1, xlabel(' ') title('Elementary effects variance decomposition') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_vdec'],options_); + create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_vdec'],1,'Screening identification: variance decomposition','morris_vdec') else save([OutputDirectoryName,'/',fname_,'_morris_IDE'],'vdec') @@ -328,6 +330,8 @@ if opt_gsa.morris==1, xlabel(' ') title('Elementary effects in the moments') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_moments'],options_); + create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_moments'],1,'Screening identification: theoretical moments','morris_moments') + % close(gcf), %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -724,6 +728,7 @@ if opt_gsa.morris==1, xlabel(' ') title('Elementary effects in the model') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_par'],options_); + create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_par'],1,'Screening identification: model','morris_par') % hh=dyn_figure(options_); %bar(SAmunorm(:,irel)) % % boxplot(SAmunorm','whis',10,'symbol','r.') @@ -1508,7 +1513,7 @@ else, % main effects analysis % SAmeanexo=mean(SAmomN(:,1:nshock)); % figure, bar(latent'*SAcc), - hh=dyn_figure(options_); + hh=dyn_figure(options_,'Name',['Identifiability indices in the ',fsuffix,' moments.']); bar(sum(SAcc)), set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) set(gca,'xlim',[0.5 npT+0.5]) @@ -1522,7 +1527,8 @@ else, % main effects analysis xlabel(' ') title(['Identifiability indices in the ',fsuffix,' moments.'],'interpreter','none') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],options_); - + create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],1,['Identifiability indices in the ',fsuffix,' moments.'],['ident_ALL',fsuffix]') + % figure, bar(SAmeanexo), % set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:nshock]) % set(gca,'xlim',[0.5 nshock+0.5]) @@ -1541,3 +1547,19 @@ else, % main effects analysis end return + + +function []=create_TeX_loader(options_,figpath,ifig_number,caption,label_name) +if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([figpath '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by map_ident_.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',strrep(figpath,'\','/')); + fprintf(fidTeX,'\\caption{%s.}',caption); + fprintf(fidTeX,'\\label{Fig:%s:%u}\n',label_name,ifig_number); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); +end diff --git a/matlab/gsa/redform_map.m b/matlab/gsa/redform_map.m index 448b1a634..da5c89053 100644 --- a/matlab/gsa/redform_map.m +++ b/matlab/gsa/redform_map.m @@ -189,6 +189,7 @@ for j=1:size(anamendo,1) hold off, title([namendo,' vs ', namexo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none') dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],options_); + create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs ', namexo],[type '_' namendo,'_vs_', namexo]) end si(:,js) = NaN(np,1); delete([xdir, '/*threshold*.*']) @@ -255,8 +256,9 @@ for j=1:size(anamendo,1) text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none') end title([logflag,' ',namendo,' vs ',namexo],'interpreter','none') - if iplo==9, + if iplo==9 dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',namendo,' vs ',namexo],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)]) end end @@ -265,6 +267,7 @@ for j=1:size(anamendo,1) end if iplo<9 && iplo>0 && ifig && ~options_.nograph, dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',namendo,' vs ',namexo],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)]) end ifig=0; iplo=0; @@ -322,6 +325,7 @@ for j=1:size(anamendo,1) hold off, title([namendo,' vs lagged ', namlagendo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none') dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],options_); + create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs lagged ', namlagendo],[type '_' namendo,'_vs_', namlagendo]) end delete([xdir, '/*threshold*.*']) @@ -391,6 +395,7 @@ for j=1:size(anamendo,1) title([logflag,' ',namendo,' vs ',namlagendo,'(-1)'],'interpreter','none') if iplo==9, dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',namendo,' vs ',namlagendo,'(-1)'],[redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)]) end end @@ -399,6 +404,7 @@ for j=1:size(anamendo,1) end if iplo<9 && iplo>0 && ifig && ~options_.nograph, dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',namendo,' vs ',namlagendo,'(-1)'],[redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)]) end end @@ -417,7 +423,8 @@ if isempty(threshold) && ~options_.nograph, end title('Reduced form GSA') dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa'],options_); - + create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa'],'Reduced Form GSA','redform_gsa') + else hfig=dyn_figure(options_,'name','Reduced Form GSA'); %bar(silog) % boxplot(silog','whis',10,'symbol','r.') @@ -432,6 +439,7 @@ if isempty(threshold) && ~options_.nograph, end title('Reduced form GSA - Log-transformed elements') dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa_log'],options_); + create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa_log'],'Reduced form GSA - Log-transformed elements','redform_gsa_log') end end @@ -602,7 +610,8 @@ end title(['Out-of-sample prediction - R2=' num2str(r2,2)],'interpreter','none') end dyn_saveas(hfig,fname,options_); - + create_TeX_loader(options_,fname,['Out-of-sample prediction - R2=' num2str(r2,2)],'redform_gsa_log') + if options_.nodisplay close(hmap); end @@ -617,6 +626,8 @@ else plot(y0,[yf y0],'.'), title([namy,' vs ', namx,' pred'],'interpreter','none') dyn_saveas(hfig,[fname '_pred'],options_); + create_TeX_loader(options_,[fname '_pred'],options_map.title,[namy,' vs ', namx,' pred']) + end end % si = gsa_.multivariate.si; @@ -735,5 +746,21 @@ if ~isoctave end dyn_saveas(hfig,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],options_); +create_TeX_loader(options_,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],options_mcf.amcf_title,[options_mcf.fname_,'_',options_mcf.amcf_name]) return + +function []=create_TeX_loader(options_,figpath,caption,label_name) +if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([figpath '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by redform_map.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',strrep(figpath,'\','/')); + fprintf(fidTeX,'\\caption{%s.}',caption); + fprintf(fidTeX,'\\label{Fig:%s}\n',label_name); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); +end diff --git a/matlab/gsa/redform_screen.m b/matlab/gsa/redform_screen.m index cdbd2d596..56b5a7d80 100644 --- a/matlab/gsa/redform_screen.m +++ b/matlab/gsa/redform_screen.m @@ -90,7 +90,8 @@ for j=1:size(anamendo,1), end title([namendo,' vs. ',namexo],'interpreter','none') if iplo==9, - dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_); + dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock']) end end @@ -98,6 +99,7 @@ for j=1:size(anamendo,1), end if iplo<9 && iplo>0 && ifig, dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shocks_',num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock']) end iplo=0; @@ -132,16 +134,18 @@ for j=1:size(anamendo,1), title([namendo,' vs. ',namlagendo,'(-1)'],'interpreter','none') if iplo==9, dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags']) end end end end if iplo<9 && iplo>0 && ifig, dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_); + create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags']) end end -hh=dyn_figure(options_); +hh=dyn_figure(options_,'Name','Reduced form screening'); %bar(SA) % boxplot(SA','whis',10,'symbol','r.') myboxplot(SA',[],'.',[],10) @@ -156,3 +160,21 @@ xlabel(' ') ylabel('Elementary Effects') title('Reduced form screening') dyn_saveas(hh,[dirname,'/',M_.fname,'_redform_screen'],options_); +create_TeX_loader(options_,[dirname,'/',M_.fname,'_redform_screen'],1,'Reduced form screening','redform_screen') + + +function []=create_TeX_loader(options_,figpath,label_number,caption,label_name) +if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([figpath '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by redform_screen.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',strrep(figpath,'\','/')); + fprintf(fidTeX,'\\caption{%s.}',caption); + fprintf(fidTeX,'\\label{Fig:%s:%u}\n',label_name,label_number); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); +end + diff --git a/matlab/gsa/scatter_mcf.m b/matlab/gsa/scatter_mcf.m index 8f8bdd82c..736e3dc5a 100644 --- a/matlab/gsa/scatter_mcf.m +++ b/matlab/gsa/scatter_mcf.m @@ -164,4 +164,17 @@ end if ~nograph, dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions); + if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format))) + fidTeX = fopen([dirname,'/',fig_nam_ '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',[dirname,'/',fig_nam_]); + fprintf(fidTeX,'\\caption{%s.}',figtitle); + fprintf(fidTeX,'\\label{Fig:%s}\n',fig_nam_); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end \ No newline at end of file diff --git a/matlab/gsa/stab_map_1.m b/matlab/gsa/stab_map_1.m index 681db4724..072f0c544 100644 --- a/matlab/gsa/stab_map_1.m +++ b/matlab/gsa/stab_map_1.m @@ -102,8 +102,34 @@ if iplot && ~options_.nograph end if nparplot>12, dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA_',int2str(i) '.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)]); + fprintf(fidTeX,'\\caption{%s.}',atitle); + fprintf(fidTeX,'\\label{Fig:%s:%u}\n',atitle,i); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end else dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA'],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',[dirname,filesep,fname_,'_',aname,'_SA']); + fprintf(fidTeX,'\\caption{%s.}',atitle); + fprintf(fidTeX,'\\label{Fig:%s}\n',atitle); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end end end diff --git a/matlab/gsa/stab_map_2.m b/matlab/gsa/stab_map_2.m index 7848de1c6..2bafb48a7 100644 --- a/matlab/gsa/stab_map_2.m +++ b/matlab/gsa/stab_map_2.m @@ -114,6 +114,19 @@ for j=1:npar, title(['cc = ',num2str(c0(i2(jx),j))]) if (mod(j2,12)==0) && j2>0, dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',[dirname,filesep,fig_nam_,int2str(ifig)]); + fprintf(fidTeX,'\\caption{%s.}',[figtitle,' sample bivariate projection ', num2str(ifig)]); + fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_,ifig); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end end end @@ -122,6 +135,19 @@ for j=1:npar, end if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0), dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_); + if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) + fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.TeX'],'w'); + fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n'); + fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']); + fprintf(fidTeX,'\\begin{figure}[H]\n'); + fprintf(fidTeX,'\\centering \n'); + fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s}\n',[dirname,filesep,fig_nam_,int2str(ifig)]); + fprintf(fidTeX,'\\caption{%s.}',[figtitle,' sample bivariate projection ', num2str(ifig)]); + fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_,ifig); + fprintf(fidTeX,'\\end{figure}\n\n'); + fprintf(fidTeX,'%% End Of TeX file. \n'); + fclose(fidTeX); + end end end diff --git a/tests/gsa/ls2003.mod b/tests/gsa/ls2003.mod index 6cf6410b0..4a8e169e6 100644 --- a/tests/gsa/ls2003.mod +++ b/tests/gsa/ls2003.mod @@ -61,7 +61,7 @@ stderr e_ys,inv_gamma_pdf,1.2533,0.6551; stderr e_pies,inv_gamma_pdf,1.88,0.9827; end; - +options_.TeX=1; disp(' '); disp('NOW I DO STABILITY MAPPING and prepare sample for Reduced form Mapping'); disp(' '); @@ -217,3 +217,7 @@ dynare_sensitivity(nodisplay, stab=0, // no need for stability analysis since th datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1, rmse=1,ppost=1); +collect_LaTeX_Files(M_); +if system(['pdflatex -halt-on-error ' M_.fname '_TeX_binder.TeX']) + error('TeX-File did not compile.') +end \ No newline at end of file