Merge pull request #405 from JohannesPfeifer/cond_forecast_graphs
Make unconditional forecasts save figures to graph foldertime-shift
commit
353d864429
|
@ -81,14 +81,19 @@ if estimated_model
|
|||
switch options_cond_fcst.parameter_set
|
||||
case 'posterior_mode'
|
||||
xparam = get_posterior_parameters('mode');
|
||||
graph_title='Posterior Mode';
|
||||
case 'posterior_mean'
|
||||
xparam = get_posterior_parameters('mean');
|
||||
graph_title='Posterior Mean';
|
||||
case 'posterior_median'
|
||||
xparam = get_posterior_parameters('median');
|
||||
graph_title='Posterior Median';
|
||||
case 'prior_mode'
|
||||
xparam = bayestopt_.p5(:);
|
||||
graph_title='Prior Mode';
|
||||
case 'prior_mean'
|
||||
xparam = bayestopt_.p1;
|
||||
graph_title='Prior Mean';
|
||||
otherwise
|
||||
disp('imcforecast:: If the input argument is a string, then it has to be equal to:')
|
||||
disp(' ''calibration'', ')
|
||||
|
@ -232,5 +237,7 @@ for i = 1:EndoSize
|
|||
eval(['forecasts.uncond.ci.' deblank(M_.endo_names(oo_.dr.order_var(i),:)) ...
|
||||
' = [tmp(t1,:)'' ,tmp(t2,:)'' ]'';']);
|
||||
end
|
||||
forecasts.graph.title=graph_title;
|
||||
forecasts.graph.fname=M_.fname;
|
||||
|
||||
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,:) ');']);
|
||||
end
|
||||
|
||||
forecasts.graph.OutputDirectoryName = CheckPath('graphs',forecasts.graph.fname);
|
||||
|
||||
for i=1:size(Variables,1)
|
||||
eval(['ci1 = forecasts.cond.ci.' Variables(i,:) ';'])
|
||||
eval(['m1 = forecasts.cond.Mean.' Variables(i,:) ';'])
|
||||
eval(['ci2 = forecasts.uncond.ci.' 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
|
||||
|
||||
function build_figure(name,cci1,cci2,mm1,mm2,options_)
|
||||
hh = dyn_figure(options_,'Name',['Conditional forecast: ' name '.']);
|
||||
function build_figure(name,cci1,cci2,mm1,mm2,options_,graphoptions)
|
||||
hh = dyn_figure(options_,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
|
||||
H = length(mm1);
|
||||
h1 = area(1:H,cci1(2,1:H));
|
||||
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(2,:),'--k','linewidth',1)
|
||||
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