2012-04-20 20:17:20 +02:00
|
|
|
function plot_icforecast(Variables,periods,options_)
|
2009-10-22 15:03:30 +02:00
|
|
|
% Build plots for the conditional forecasts.
|
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% o Variables [char] m*x array holding the names of the endogenous variables to be plotted.
|
|
|
|
%
|
|
|
|
% OUTPUTS
|
|
|
|
% None.
|
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% This routine has to be called after imcforecast.m.
|
2008-08-01 20:53:30 +02:00
|
|
|
|
2013-06-12 16:42:09 +02:00
|
|
|
% Copyright (C) 2006-2013 Dynare Team
|
2008-08-01 20:53:30 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-11-04 10:54:45 +01:00
|
|
|
if isoctave && octave_ver_less_than('3.4.0')
|
2011-10-21 18:15:35 +02:00
|
|
|
% The set() command on the handle returned by area() crashes in Octave 3.2
|
|
|
|
error('plot_conditional_forecast: you need Octave >= 3.4 (because of a bug in older versions)')
|
|
|
|
end
|
|
|
|
|
2006-12-15 12:37:24 +01:00
|
|
|
load conditional_forecasts;
|
|
|
|
|
2012-04-28 15:11:49 +02:00
|
|
|
if nargin==1 || isempty(periods) % Set default number of periods.
|
2013-03-17 22:47:47 +01:00
|
|
|
eval(['periods = length(forecasts.cond.Mean.' Variables(1,:) ');']);
|
2009-10-22 17:56:32 +02:00
|
|
|
end
|
|
|
|
|
2013-05-19 23:41:59 +02:00
|
|
|
forecasts.graph.OutputDirectoryName = CheckPath('graphs',forecasts.graph.fname);
|
|
|
|
|
2009-10-22 15:03:30 +02:00
|
|
|
for i=1:size(Variables,1)
|
|
|
|
eval(['ci1 = forecasts.cond.ci.' Variables(i,:) ';'])
|
2013-03-17 22:47:47 +01:00
|
|
|
eval(['m1 = forecasts.cond.Mean.' Variables(i,:) ';'])
|
2009-10-22 15:03:30 +02:00
|
|
|
eval(['ci2 = forecasts.uncond.ci.' Variables(i,:) ';'])
|
2013-03-17 22:47:47 +01:00
|
|
|
eval(['m2 = forecasts.uncond.Mean.' Variables(i,:) ';'])
|
2013-05-19 23:41:59 +02:00
|
|
|
build_figure(Variables(i,:),ci1(:,1:periods),ci2(:,1:periods),m1(1:periods),m2(1:periods),options_,forecasts.graph);
|
2009-10-22 15:03:30 +02:00
|
|
|
end
|
|
|
|
|
2013-05-19 23:41:59 +02:00
|
|
|
function build_figure(name,cci1,cci2,mm1,mm2,options_,graphoptions)
|
|
|
|
hh = dyn_figure(options_,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
|
2009-12-16 18:17:34 +01:00
|
|
|
H = length(mm1);
|
|
|
|
h1 = area(1:H,cci1(2,1:H));
|
|
|
|
set(h1,'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))]))
|
|
|
|
set(h1,'FaceColor',[.9 .9 .9])
|
|
|
|
hold on
|
|
|
|
h2 = area(1:H,cci1(1,1:H));
|
|
|
|
set(h2,'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))]))
|
|
|
|
set(h2,'FaceColor',[1 1 1])
|
|
|
|
plot(1:H,mm1,'-k','linewidth',3)
|
|
|
|
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
|
2013-05-19 23:41:59 +02:00
|
|
|
hold off
|
|
|
|
dyn_saveas(hh,[graphoptions.OutputDirectoryName '/Conditional_forecast_',strrep(deblank(graphoptions.title),' ','_'),'_',deblank(name)],options_)
|