Add LaTeX-output option to table from stoch_simul.m
parent
38d293b864
commit
40877685f2
|
@ -59,6 +59,7 @@ oo_.mean = transpose(m);
|
||||||
oo_.var = y'*y/size(y,1);
|
oo_.var = y'*y/size(y,1);
|
||||||
|
|
||||||
labels = deblank(M_.endo_names(ivar,:));
|
labels = deblank(M_.endo_names(ivar,:));
|
||||||
|
labels_TeX = deblank(M_.endo_names_tex(ivar,:));
|
||||||
|
|
||||||
if options_.nomoments == 0
|
if options_.nomoments == 0
|
||||||
z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
|
z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
|
||||||
|
@ -69,6 +70,9 @@ if options_.nomoments == 0
|
||||||
headers=char('VARIABLE','MEAN','STD. DEV.','VARIANCE','SKEWNESS', ...
|
headers=char('VARIABLE','MEAN','STD. DEV.','VARIANCE','SKEWNESS', ...
|
||||||
'KURTOSIS');
|
'KURTOSIS');
|
||||||
dyntable(title,headers,labels,z,size(labels,2)+2,16,6);
|
dyntable(title,headers,labels,z,size(labels,2)+2,16,6);
|
||||||
|
if options_.TeX
|
||||||
|
dyn_latex_table(M_,title,'sim_moments',headers,labels_TeX,z,size(labels,2)+2,16,6);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.nocorr == 0
|
if options_.nocorr == 0
|
||||||
|
@ -83,6 +87,11 @@ if options_.nocorr == 0
|
||||||
|
|
||||||
headers = char('VARIABLE',M_.endo_names(ivar,:));
|
headers = char('VARIABLE',M_.endo_names(ivar,:));
|
||||||
dyntable(title,headers,labels,corr,size(labels,2)+2,8,4);
|
dyntable(title,headers,labels,corr,size(labels,2)+2,8,4);
|
||||||
|
if options_.TeX
|
||||||
|
headers = char('VARIABLE',M_.endo_names_tex(ivar,:));
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'sim_corr_matrix',headers,labels_TeX,corr,size(labels,2)+2,8,4);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,7 +111,13 @@ if ar > 0
|
||||||
title=add_filter_subtitle(title,options_);
|
title=add_filter_subtitle(title,options_);
|
||||||
headers = char('VARIABLE',int2str([1:ar]'));
|
headers = char('VARIABLE',int2str([1:ar]'));
|
||||||
dyntable(title,headers,labels,autocorr,size(labels,2)+2,8,4);
|
dyntable(title,headers,labels,autocorr,size(labels,2)+2,8,4);
|
||||||
|
if options_.TeX
|
||||||
|
headers = char('VARIABLE',int2str([1:ar]'));
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'sim_autocorr_matrix',headers,labels_TeX,autocorr,size(labels_TeX,2)+2,8,4);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +157,15 @@ if ~options_.nodecomposition
|
||||||
headers(M_.exo_names_orig_ord,:) = headers;
|
headers(M_.exo_names_orig_ord,:) = headers;
|
||||||
headers = char(' ',headers);
|
headers = char(' ',headers);
|
||||||
lh = size(deblank(M_.endo_names(ivar,:)),2)+2;
|
lh = size(deblank(M_.endo_names(ivar,:)),2)+2;
|
||||||
dyntable(title,char(headers,'Total linear contrib.'),deblank(M_.endo_names(ivar,:)),[oo_.variance_decomposition sum(oo_.variance_decomposition,2)],lh,8,2);
|
dyntable(title,char(headers,'Tot. lin. contr.'),deblank(M_.endo_names(ivar,:)),[oo_.variance_decomposition sum(oo_.variance_decomposition,2)],lh,8,2);
|
||||||
|
if options_.TeX
|
||||||
|
headers=M_.exo_names_tex;
|
||||||
|
headers = char(' ',headers);
|
||||||
|
labels = deblank(M_.endo_names_tex(ivar,:));
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'sim_var_decomp',char(headers,'Tot. lin. contr.'),labels_TeX,[oo_.variance_decomposition sum(oo_.variance_decomposition,2)],lh,8,2);
|
||||||
|
end
|
||||||
|
|
||||||
if options_.order == 1
|
if options_.order == 1
|
||||||
fprintf('Note: numbers do not add up to 100 due to non-zero correlation of simulated shocks in small samples\n\n')
|
fprintf('Note: numbers do not add up to 100 due to non-zero correlation of simulated shocks in small samples\n\n')
|
||||||
else
|
else
|
||||||
|
|
|
@ -65,6 +65,11 @@ if size(stationary_vars, 1) > 0
|
||||||
labels = deblank(M_.endo_names(ivar,:));
|
labels = deblank(M_.endo_names(ivar,:));
|
||||||
lh = size(labels,2)+2;
|
lh = size(labels,2)+2;
|
||||||
dyntable(title,headers,labels,z,lh,11,4);
|
dyntable(title,headers,labels,z,lh,11,4);
|
||||||
|
if options_.TeX
|
||||||
|
labels = deblank(M_.endo_names_tex(ivar,:));
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'th_moments',headers,labels,z,lh,11,4);
|
||||||
|
end
|
||||||
|
|
||||||
if M_.exo_nbr > 1 && ~nodecomposition
|
if M_.exo_nbr > 1 && ~nodecomposition
|
||||||
skipline()
|
skipline()
|
||||||
|
@ -81,6 +86,13 @@ if size(stationary_vars, 1) > 0
|
||||||
dyntable(title,headers,deblank(M_.endo_names(ivar(stationary_vars), ...
|
dyntable(title,headers,deblank(M_.endo_names(ivar(stationary_vars), ...
|
||||||
:)),100* ...
|
:)),100* ...
|
||||||
oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
|
oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
|
||||||
|
if options_.TeX
|
||||||
|
headers=M_.exo_names_tex;
|
||||||
|
headers = char(' ',headers);
|
||||||
|
labels = deblank(M_.endo_names_tex(ivar(stationary_vars),:));
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'th_var_decomp_uncond',headers,labels,100*oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -125,6 +137,12 @@ if options_.nocorr == 0 && size(stationary_vars, 1) > 0
|
||||||
headers = char('Variables',labels);
|
headers = char('Variables',labels);
|
||||||
lh = size(labels,2)+2;
|
lh = size(labels,2)+2;
|
||||||
dyntable(title,headers,labels,corr,lh,8,4);
|
dyntable(title,headers,labels,corr,lh,8,4);
|
||||||
|
if options_.TeX
|
||||||
|
labels = deblank(M_.endo_names_tex(ivar(i1),:));
|
||||||
|
headers=char('Variables',labels);
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'th_corr_matrix',headers,labels,corr,lh,8,4);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if options_.ar > 0 && size(stationary_vars, 1) > 0
|
if options_.ar > 0 && size(stationary_vars, 1) > 0
|
||||||
|
@ -145,5 +163,11 @@ if options_.ar > 0 && size(stationary_vars, 1) > 0
|
||||||
headers = char('Order ',int2str([1:options_.ar]'));
|
headers = char('Order ',int2str([1:options_.ar]'));
|
||||||
lh = size(labels,2)+2;
|
lh = size(labels,2)+2;
|
||||||
dyntable(title,headers,labels,z,lh,8,4);
|
dyntable(title,headers,labels,z,lh,8,4);
|
||||||
|
if options_.TeX
|
||||||
|
labels = deblank(M_.endo_names_tex(ivar(i1),:));
|
||||||
|
headers=char('Order ',int2str([1:options_.ar]'));
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,title,'th_autocorr_matrix',headers,labels,z,lh,8,4);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,11 +31,13 @@ function display_conditional_variance_decomposition(conditional_decomposition_ar
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if options_.order == 2
|
if options_.order == 2
|
||||||
skipline()
|
skipline()
|
||||||
disp('APPROXIMATED CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
|
title='APPROXIMATED CONDITIONAL VARIANCE DECOMPOSITION (in percent)';
|
||||||
|
disp(title)
|
||||||
else
|
else
|
||||||
skipline()
|
skipline()
|
||||||
disp('CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
|
title='CONDITIONAL VARIANCE DECOMPOSITION (in percent)';
|
||||||
|
disp(title)
|
||||||
end
|
end
|
||||||
|
|
||||||
vardec_i = zeros(length(SubsetOfVariables),M_.exo_nbr);
|
vardec_i = zeros(length(SubsetOfVariables),M_.exo_nbr);
|
||||||
|
@ -54,4 +56,10 @@ for i=1:length(Steps)
|
||||||
dyntable('',headers,...
|
dyntable('',headers,...
|
||||||
deblank(M_.endo_names(SubsetOfVariables,:)),...
|
deblank(M_.endo_names(SubsetOfVariables,:)),...
|
||||||
vardec_i,lh,8,2);
|
vardec_i,lh,8,2);
|
||||||
|
if options_.TeX
|
||||||
|
labels_TeX = deblank(M_.endo_names_tex(SubsetOfVariables,:));
|
||||||
|
headers_TeX=char('',deblank(M_.exo_names_tex));
|
||||||
|
lh = size(labels_TeX,2)+2;
|
||||||
|
dyn_latex_table(M_,[title,'; Period ' int2str(Steps(i))],['th_var_decomp_cond_h',int2str(Steps(i))],headers_TeX,labels_TeX,vardec_i,lh,8,2);
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,73 @@
|
||||||
|
function dyn_latex_table(M_,title,LaTeXtitle,headers,labels,values,label_width,val_width,val_precis)
|
||||||
|
|
||||||
|
OutputDirectoryName = CheckPath('Output',M_.dname);
|
||||||
|
|
||||||
|
%% get width of label column
|
||||||
|
if ~isempty(label_width)
|
||||||
|
label_width = max(size(deblank(char(headers(1,:),labels)),2)+2, ...
|
||||||
|
label_width);
|
||||||
|
else %use default length
|
||||||
|
label_width = max(size(deblank(char(headers(1,:),labels)),2))+2;
|
||||||
|
end
|
||||||
|
label_format_leftbound = sprintf('$%%-%ds$',label_width);
|
||||||
|
|
||||||
|
%% get width of label column
|
||||||
|
if all(~isfinite(values))
|
||||||
|
values_length = 4;
|
||||||
|
else
|
||||||
|
values_length = max(ceil(max(max(log10(abs(values(isfinite(values))))))),1)+val_precis+1;
|
||||||
|
end
|
||||||
|
if any(values) < 0 %add one character for minus sign
|
||||||
|
values_length = values_length+1;
|
||||||
|
end
|
||||||
|
|
||||||
|
%% 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);
|
||||||
|
else
|
||||||
|
val_width = max(headers_length,values_length)+4;
|
||||||
|
end
|
||||||
|
value_format = sprintf('%%%d.%df',val_width,val_precis);
|
||||||
|
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|';
|
||||||
|
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'];
|
||||||
|
end
|
||||||
|
end
|
||||||
|
header_string=[header_string '\\\\\n'];
|
||||||
|
|
||||||
|
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '.TeX'];
|
||||||
|
fidTeX = fopen(filename,'w');
|
||||||
|
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||||
|
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,header_string);
|
||||||
|
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||||
|
fprintf(fidTeX,'\\caption{(continued)}\\\\\n ');
|
||||||
|
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||||
|
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');
|
||||||
|
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{center}\n');
|
||||||
|
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||||
|
fclose(fidTeX);
|
|
@ -107,6 +107,12 @@ if ~options_.noprint
|
||||||
headers = char('Variables',labels);
|
headers = char('Variables',labels);
|
||||||
lh = size(labels,2)+2;
|
lh = size(labels,2)+2;
|
||||||
dyntable(my_title,headers,labels,M_.Sigma_e,lh,10,6);
|
dyntable(my_title,headers,labels,M_.Sigma_e,lh,10,6);
|
||||||
|
if options_.TeX
|
||||||
|
labels = deblank(M_.exo_names_tex);
|
||||||
|
headers = char('Variables',labels);
|
||||||
|
lh = size(labels,2)+2;
|
||||||
|
dyn_latex_table(M_,my_title,'covar_ex_shocks',headers,labels,M_.Sigma_e,lh,10,6);
|
||||||
|
end
|
||||||
if options_.partial_information
|
if options_.partial_information
|
||||||
skipline()
|
skipline()
|
||||||
disp('SOLUTION UNDER PARTIAL INFORMATION')
|
disp('SOLUTION UNDER PARTIAL INFORMATION')
|
||||||
|
|
|
@ -123,7 +123,8 @@ end;
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
|
|
||||||
stoch_simul(order=1,irf=20,graph_format=eps,contemporaneous_correlation);
|
stoch_simul(order=1,irf=20,graph_format=eps,periods=1000,contemporaneous_correlation,conditional_variance_decomposition=[1,3]);
|
||||||
|
stoch_simul(order=1,irf=20,graph_format=eps,periods=0,contemporaneous_correlation,conditional_variance_decomposition=[1,3]);
|
||||||
|
|
||||||
write_latex_original_model;
|
write_latex_original_model;
|
||||||
write_latex_static_model;
|
write_latex_static_model;
|
||||||
|
|
Loading…
Reference in New Issue