0001 function plot_ms_forecast(M_, options_, forecast, figure_name)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 nc = 2;
0036 nr = 2;
0037 nvars = M_.endo_nbr;
0038 endo_names = M_.endo_names;
0039 var_list = endo_names(1:M_.orig_endo_nbr,:);
0040 names = {};
0041 tex_names = {};
0042 m = 1;
0043 for i = 1:size(var_list)
0044 tmp = strmatch(var_list(i,:),endo_names,'exact');
0045 if isempty(tmp)
0046 error([var_list(i,:) ' isn''t and endogenous variable'])
0047 end
0048 tex_name = deblank(M_.endo_names_tex(i,:));
0049 if ~isempty(tex_name)
0050 names{m} = deblank(var_list(i,:));
0051 tex_names{m} = tex_name;
0052 m = m + 1;
0053 end
0054 end
0055
0056 dims = size(forecast);
0057 if (length(dims) == 2)
0058
0059 horizon = dims(1);
0060 num_percentiles = 1;
0061 elseif (length(dims) == 3)
0062
0063 horizon = dims(2);
0064 num_percentiles = dims(1);
0065 else
0066 error('The impulse response matrix passed to be plotted does not appear to be the correct size');
0067 end
0068
0069 if num_percentiles == 1
0070 plot_point_forecast(forecast, nvars, nr, nc, var_list, figure_name, ...
0071 options_.graph_save_formats, options_.TeX, names, tex_names, ...
0072 [options_.ms.output_file_tag filesep 'Output' filesep 'Forecast']);
0073 else
0074 plot_banded_forecast(forecast, nvars, nr, nc, var_list, num_percentiles, ...
0075 figure_name, options_.graph_save_formats, options_.TeX, names, tex_names, ...
0076 [options_.ms.output_file_tag filesep 'Output' filesep 'Forecast']);
0077 end
0078
0079 end
0080
0081 function plot_point_forecast(forecast,nvars,nr,nc,endo_names,figure_name,save_graph_formats,TeX,names,tex_names,dirname)
0082 if nvars > nr*nc
0083 graph_name = ['MS (1) ' figure_name];
0084 figure('Name', graph_name);
0085 else
0086 graph_name = figure_name;
0087 figure('Name', graph_name);
0088 end
0089 m = 1;
0090 n_fig = 1;
0091 for j=1:nvars
0092 if m > nr*nc
0093 graph_name = ['MS (' int2str(n_fig) ') ' figure_name];
0094 dyn_save_graph(dirname,['MS-forecast-' int2str(n_fig)],...
0095 save_graph_formats,TeX,names,tex_names,graph_name);
0096 n_fig =n_fig+1;
0097 figure('Name', graph_name);
0098 m = 1;
0099 end
0100 subplot(nr,nc,m);
0101 vn = deblank(endo_names(j,:));
0102 plot(forecast(:,j))
0103 title(vn,'Interpreter','none');
0104 grid on;
0105 m = m+1;
0106 end
0107 if m > 1
0108 dyn_save_graph(dirname,['MS-forecast-' int2str(n_fig)],...
0109 save_graph_formats,TeX,names,tex_names,graph_name);
0110 end
0111 end
0112
0113 function plot_banded_forecast(forecast,nvars,nr,nc,endo_names,num_percentiles,figure_name,save_graph_formats,TeX,names,tex_names,dirname)
0114 if nvars > nr*nc
0115 graph_name = ['MS (1) ' figure_name];
0116 figure('Name', graph_name);
0117 else
0118 graph_name = figure_name;
0119 figure('Name', graph_name);
0120 end
0121 m = 1;
0122 n_fig = 1;
0123 for j=1:nvars
0124 if m > nr*nc
0125 graph_name = ['MS (' int2str(n_fig) ') ' figure_name];
0126 dyn_save_graph(dirname,['MS-forecast-' int2str(n_fig)],...
0127 save_graph_formats,TeX,names,tex_names,graph_name);
0128 n_fig =n_fig+1;
0129 figure('Name',graph_name);
0130 m = 1;
0131 end
0132 subplot(nr,nc,m);
0133 vn = deblank(endo_names(j,:));
0134 for k=1:num_percentiles
0135 if ceil(num_percentiles/2) == k
0136 plot(forecast(k,:,j),'LineWidth',1.5)
0137 else
0138 plot(forecast(k,:,j),'LineWidth',1.1)
0139 end
0140 if k==1
0141 hold on;
0142 end
0143 end
0144 title(vn,'Interpreter','none');
0145 hold off
0146 grid on;
0147 m = m+1;
0148 end
0149 if m > 1
0150 dyn_save_graph(dirname,['MS-forecast-' int2str(n_fig)],...
0151 save_graph_formats,TeX,names,tex_names,graph_name);
0152 end
0153 end