-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcreate_table.m
98 lines (75 loc) · 2.78 KB
/
create_table.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
clear;
% Create table of coverage and length
% based on AR(1) and bivariate VAR(p) simulation results
%% Settings
% DGP type
dgp_type = 'ar1_iid'; % Either 'ar1_iid', 'ar1_arch', 'ar1_homosk', or 'var_pX' (where X is integer)
% File names
load_filename = fullfile('results', strcat('sim_', dgp_type, '.mat')); % Load results from this file
save_filename = dgp_type; % File name for saved table
% Select DGPs
T_sel = 240; % Sample size (single number)
switch dgp_type(1:3)
case 'ar1'
rhos_sel = [0.0 0.5 0.95 1]; % rho values (array)
case 'var'
rhos_sel = [0.0 0.5 0.95 1];
end
% Select CI procedures
switch dgp_type(1:3)
case 'ar1'
proc_names = {'$\text{LP-LA}_b$', '$\text{LP-LA}$', '$\text{LP}_b$', '$\text{LP}$', '$\text{AR-LA}_b$', '$\text{AR}$'};
procs = [7 4; % First index: inference procedure; second index: type of confidence interval
7 1;
6 4;
6 1
4 2
1 1];
case 'var'
proc_names = {'$\text{LP-LA}_b$', '$\text{LP-LA}_b^8$', '$\text{LP}_b$', '$\text{AR-LA}_b$', '$\text{AR}$'};
procs = [4 4;
5 4;
3 4;
2 2;
1 1];
end
%% Load results
load(load_filename);
% Pick out indices of selected DGPs
numdgp_sel = length(rhos_sel);
dgp_sel = zeros(1,numdgp_sel);
for j=1:numdgp_sel
dgp_sel(j) = find(dgp.dgps(1,:)==rhos_sel(j) & dgp.dgps(2,:)==T_sel);
end
numproc = length(proc_names); % Number of inference procedures
%% Write table
status = mkdir('tables');
f = fopen(fullfile('tables', strcat(save_filename, '.tex')), 'w'); % Open file for writing
fprintf(f, '%s%s%s%s%s\n', '\begin{tabular}{r|', repmat('c', 1, numproc), '|', repmat('c', 1, numproc), '}');
fprintf(f, '%s%d%s%d%s\n', '& \multicolumn{', numproc, '}{c|}{Coverage} & \multicolumn{', numproc, '}{c}{Median length} \\');
fprintf(f, '%s', '$h$');
for i=1:2
for j=1:numproc
fprintf(f, '%s%s', ' & ', proc_names{j});
end
end
fprintf(f, '%s\n%s\n', ' \\', '\hline');
for d=dgp_sel
rho = dgp.dgps(1,d);
fprintf(f, '%s%d%s%4.2f%s\n', '\multicolumn{', 1+2*numproc, '}{c}{$\rho = ', rho, '$} \\');
for ih=1:length(settings.horzs)
h = settings.horzs(ih);
fprintf(f, '%3d', h);
for j=1:numproc
cp = results.coverage_prob(d,procs(j,1),ih,procs(j,2));
fprintf(f, '%s%5.3f', ' & ', cp);
end
for j=1:numproc
ml = results.median_length(d,procs(j,1),ih,procs(j,2));
fprintf(f, '%s%5.3f', ' & ', ml);
end
fprintf(f, '%s\n', ' \\');
end
end
fprintf(f, '%s', '\end{tabular}');
fclose(f);