Make unconditional forecasts save figures to graph folder
Also provides more expressive titletime-shift
parent
7bbe121769
commit
5842c6c1c5
|
@ -81,14 +81,19 @@ if estimated_model
|
||||||
switch options_cond_fcst.parameter_set
|
switch options_cond_fcst.parameter_set
|
||||||
case 'posterior_mode'
|
case 'posterior_mode'
|
||||||
xparam = get_posterior_parameters('mode');
|
xparam = get_posterior_parameters('mode');
|
||||||
|
graph_title='Posterior Mode';
|
||||||
case 'posterior_mean'
|
case 'posterior_mean'
|
||||||
xparam = get_posterior_parameters('mean');
|
xparam = get_posterior_parameters('mean');
|
||||||
|
graph_title='Posterior Mean';
|
||||||
case 'posterior_median'
|
case 'posterior_median'
|
||||||
xparam = get_posterior_parameters('median');
|
xparam = get_posterior_parameters('median');
|
||||||
|
graph_title='Posterior Median';
|
||||||
case 'prior_mode'
|
case 'prior_mode'
|
||||||
xparam = bayestopt_.p5(:);
|
xparam = bayestopt_.p5(:);
|
||||||
|
graph_title='Prior Mode';
|
||||||
case 'prior_mean'
|
case 'prior_mean'
|
||||||
xparam = bayestopt_.p1;
|
xparam = bayestopt_.p1;
|
||||||
|
graph_title='Prior Mean';
|
||||||
otherwise
|
otherwise
|
||||||
disp('imcforecast:: If the input argument is a string, then it has to be equal to:')
|
disp('imcforecast:: If the input argument is a string, then it has to be equal to:')
|
||||||
disp(' ''calibration'', ')
|
disp(' ''calibration'', ')
|
||||||
|
@ -232,5 +237,7 @@ for i = 1:EndoSize
|
||||||
eval(['forecasts.uncond.ci.' deblank(M_.endo_names(oo_.dr.order_var(i),:)) ...
|
eval(['forecasts.uncond.ci.' deblank(M_.endo_names(oo_.dr.order_var(i),:)) ...
|
||||||
' = [tmp(t1,:)'' ,tmp(t2,:)'' ]'';']);
|
' = [tmp(t1,:)'' ,tmp(t2,:)'' ]'';']);
|
||||||
end
|
end
|
||||||
|
forecasts.graph.title=graph_title;
|
||||||
|
forecasts.graph.fname=M_.fname;
|
||||||
|
|
||||||
save('conditional_forecasts.mat','forecasts');
|
save('conditional_forecasts.mat','forecasts');
|
|
@ -38,16 +38,18 @@ if nargin==1 || isempty(periods) % Set default number of periods.
|
||||||
eval(['periods = length(forecasts.cond.Mean.' Variables(1,:) ');']);
|
eval(['periods = length(forecasts.cond.Mean.' Variables(1,:) ');']);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
forecasts.graph.OutputDirectoryName = CheckPath('graphs',forecasts.graph.fname);
|
||||||
|
|
||||||
for i=1:size(Variables,1)
|
for i=1:size(Variables,1)
|
||||||
eval(['ci1 = forecasts.cond.ci.' Variables(i,:) ';'])
|
eval(['ci1 = forecasts.cond.ci.' Variables(i,:) ';'])
|
||||||
eval(['m1 = forecasts.cond.Mean.' Variables(i,:) ';'])
|
eval(['m1 = forecasts.cond.Mean.' Variables(i,:) ';'])
|
||||||
eval(['ci2 = forecasts.uncond.ci.' Variables(i,:) ';'])
|
eval(['ci2 = forecasts.uncond.ci.' Variables(i,:) ';'])
|
||||||
eval(['m2 = forecasts.uncond.Mean.' Variables(i,:) ';'])
|
eval(['m2 = forecasts.uncond.Mean.' Variables(i,:) ';'])
|
||||||
build_figure(Variables(i,:),ci1(:,1:periods),ci2(:,1:periods),m1(1:periods),m2(1:periods),options_);
|
build_figure(Variables(i,:),ci1(:,1:periods),ci2(:,1:periods),m1(1:periods),m2(1:periods),options_,forecasts.graph);
|
||||||
end
|
end
|
||||||
|
|
||||||
function build_figure(name,cci1,cci2,mm1,mm2,options_)
|
function build_figure(name,cci1,cci2,mm1,mm2,options_,graphoptions)
|
||||||
hh = dyn_figure(options_,'Name',['Conditional forecast: ' name '.']);
|
hh = dyn_figure(options_,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
|
||||||
H = length(mm1);
|
H = length(mm1);
|
||||||
h1 = area(1:H,cci1(2,1:H));
|
h1 = area(1:H,cci1(2,1:H));
|
||||||
set(h1,'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))]))
|
set(h1,'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))]))
|
||||||
|
@ -61,4 +63,5 @@ plot(1:H,mm2,'--k','linewidth',3)
|
||||||
plot(1:H,cci2(1,:),'--k','linewidth',1)
|
plot(1:H,cci2(1,:),'--k','linewidth',1)
|
||||||
plot(1:H,cci2(2,:),'--k','linewidth',1)
|
plot(1:H,cci2(2,:),'--k','linewidth',1)
|
||||||
axis tight
|
axis tight
|
||||||
hold off
|
hold off
|
||||||
|
dyn_saveas(hh,[graphoptions.OutputDirectoryName '/Conditional_forecast_',strrep(deblank(graphoptions.title),' ','_'),'_',deblank(name)],options_)
|
Loading…
Reference in New Issue