-
Notifications
You must be signed in to change notification settings - Fork 13
/
create_fig_var_calib.m
102 lines (78 loc) · 2.69 KB
/
create_fig_var_calib.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
99
100
101
clear;
% Create figure of coverage and length
% based on empirically calibrated VAR simulation results
% MPM 2020-11-20
%% Settings
% Overall experiment
exper = 'gk'; % Either 'gk' (Gertler & Karadi) or 'kk' (Kilian & Kim)
% File names
load_filename = fullfile('results', strcat('sim_var_calib_', exper, '.mat')); % Load results from this file
save_filename = fullfile('figures', strcat('var_calib_', exper)); % First part of file name for saved figures
save_suffix = '.png'; % Suffix for saved figures
% Plot titles for response variables
switch exper
case 'gk'
title_vars = {'CPI', 'Indu. product.', 'Bond premium'};
case 'kk'
title_vars = {'Real activity', 'CPI inflation', 'Commod. inf.'};
end
% Specifications and legend
procs = [1 2;
2 4]; % Index of specification (left) and associated CI (right)
legend_text = {'Lag-aug. VAR', 'Lag-aug. LP'}; % Legend for specifications
% Axis limits
switch exper
case 'gk'
ylim_cover = [0.75 1]; % y-limits for coverage prob plot
case 'kk'
ylim_cover = [0.85 1];
end
xticks = [1 12:12:48]; % x-axis ticks
% Line specs
line_colors = [lines(1); 0 0 0];
line_specs = {'--', '-'};
%% Load results
load(load_filename);
numspec = size(procs,1); % No. of specifications to plot
%% Create figure
numvar = length(settings.resp_vars); % No. of response variables
numhorz = length(settings.horzs); % No. of estimated impulse response horizons
the_f = figure('Units', 'normalize', 'Position', [0.1 0.1 0.8 0.8]);
for i=1:numvar
% Coverage probability
subplot(2,numvar,i);
hold on;
for j=1:numspec
plot(1:numhorz, squeeze(results.coverage_prob(i,procs(j,1),:,procs(j,2))), line_specs{j}, 'Color', line_colors(j,:), 'LineWidth', 2);
end
plot([1 numhorz], (1-settings.alpha)*[1 1], 'Color', 'k', 'LineStyle', ':'); % Nominal confidence level
hold off;
set(gca, 'XTick', xticks);
xlim([1 numhorz]);
% xlabel('horizon');
ylim(ylim_cover);
title(['Coverage: ', title_vars{i}]);
set(gca, 'FontSize', 12);
% Median length
subplot(2,numvar,numvar+i);
hold on;
for j=1:numspec
plot(1:numhorz, squeeze(results.median_length(i,procs(j,1),:,procs(j,2))), line_specs{j}, 'Color', line_colors(j,:), 'LineWidth', 2);
end
hold off;
set(gca, 'XTick', xticks);
xlim([1 numhorz]);
% xlabel('horizon');
title(['Median length: ', title_vars{i}]);
set(gca, 'FontSize', 12);
if i==1
legend(legend_text, 'Location', 'NorthWest');
end
end
% Save
status = mkdir('figures');
if strcmp(save_suffix, '.eps')
print(the_f,strcat(save_filename, save_suffix),'-depsc','-loose');
else
saveas(the_f,strcat(save_filename, save_suffix));
end