Merge pull request #920 from JohannesPfeifer/Bayesian_IRF_display

Fix plotting of Bayesian IRFs where IRFs turn from negative to positive.
time-shift
Stéphane Adjemian 2015-05-07 14:07:21 +02:00
commit 0e0cb1a191
1 changed files with 25 additions and 24 deletions

View File

@ -1,17 +1,28 @@
function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab) function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam,ThisMatlab)
% function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab)
% Generates the Posterior IRFs plot from the IRFs generated in % Generates the Posterior IRFs plot from the IRFs generated in
% PosteriorIRF_core1 % PosteriorIRF_core1
%
% PARALLEL CONTEXT % PARALLEL CONTEXT
% Perform in parallel execution a portion of the PosteriorIRF.m code. % Performs in parallel execution a portion of the PosteriorIRF.m code.
% See also the comment in random_walk_metropolis_hastings_core.m funtion. % For more information, see the comment in random_walk_metropolis_hastings_core.m
% function.
% %
% INPUTS % INPUTS
% See the comment in random_walk_metropolis_hastings_core.m funtion. % o myimput [struc] The mandatory variables for local/remote
% parallel computing obtained from random_walk_metropolis_hastings.m
% function.
% o fblck and nblck [integer] The Metropolis-Hastings chains.
% o whoiam [integer] In concurrent programming a modality to refer to the differents thread running in parallel is needed.
% The integer whoaim is the integer that
% allows us to distinguish between them. Then it is the index number of this CPU among all CPUs in the
% cluster.
% o ThisMatlab [integer] Allows us to distinguish between the
% 'main' matlab, the slave matlab worker, local matlab, remote matlab,
% ... Then it is the index number of this slave machine in the cluster.
% %
% OUTPUTS % OUTPUTS
% o myoutput [struc] % o myoutput [struc] Contained: OutputFileName (i.e. the figures without the file .txt).
% Contained:
% OutputFileName (i.e. the figures without the file .txt).
% %
% ALGORITHM % ALGORITHM
% Portion of PosteriorIRF.m function code. Specifically the last 'for' cycle. % Portion of PosteriorIRF.m function code. Specifically the last 'for' cycle.
@ -19,7 +30,7 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab)
% SPECIAL REQUIREMENTS. % SPECIAL REQUIREMENTS.
% None. % None.
% %
% Copyright (C) 2006-2013 Dynare Team % Copyright (C) 2006-2015 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -100,13 +111,9 @@ for i=fpar:npar,
set(0,'CurrentFigure',hh) set(0,'CurrentFigure',hh)
subplot(nn,nn,subplotnum); subplot(nn,nn,subplotnum);
if ~MAX_nirfs_dsgevar if ~MAX_nirfs_dsgevar
h1 = area(1:options_.irf,HPDIRF(:,2,j,i)); h1 = area(1:options_.irf,HPDIRF(:,2,j,i),'FaceColor',[.9 .9 .9],'BaseValue',min(HPDIRF(:,1,j,i))); %grey below HPDIsup and minimum of HPDIinf
set(h1,'FaceColor',[.9 .9 .9]);
set(h1,'BaseValue',min(HPDIRF(:,1,j,i)));
hold on hold on
h2 = area(1:options_.irf,HPDIRF(:,1,j,i),'FaceColor',[1 1 1],'BaseValue',min(HPDIRF(:,1,j,i))); h2 = area(1:options_.irf,HPDIRF(:,1,j,i),'FaceColor',[1 1 1],'BaseValue',min(HPDIRF(:,1,j,i))); %white below HPDIinf and minimum of HPDIinf
set(h2,'FaceColor',[1 1 1]);
set(h2,'BaseValue',min(HPDIRF(:,1,j,i)));
plot(1:options_.irf,MeanIRF(:,j,i),'-k','linewidth',3) plot(1:options_.irf,MeanIRF(:,j,i),'-k','linewidth',3)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5); % plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
box on box on
@ -114,18 +121,14 @@ for i=fpar:npar,
xlim([1 options_.irf]); xlim([1 options_.irf]);
hold off hold off
else else
h1 = area(1:options_.irf,HPDIRF(:,2,j,i)); h1 = area(1:options_.irf,HPDIRF(:,2,j,i),'FaceColor',[.9 .9 .9],'BaseValue',min([min(HPDIRF(:,1,j,i)),min(HPDIRFdsgevar(:,1,j,i))])); %grey below HPDIsup and minimum of HPDIinf and HPDIRFdsgevar
set(h1,'FaceColor',[.9 .9 .9]); hold on
set(h1,'BaseValue',min([min(HPDIRF(:,1,j,i)),min(HPDIRFdsgevar(:,1,j,i))])); h2 = area(1:options_.irf,HPDIRF(:,1,j,i),'FaceColor',[1 1 1],'BaseValue',min([min(HPDIRF(:,1,j,i)),min(HPDIRFdsgevar(:,1,j,i))])); %white below HPDIinf and minimum of HPDIinf and HPDIRFdsgevar
hold on;
h2 = area(1:options_.irf,HPDIRF(:,1,j,i));
set(h2,'FaceColor',[1 1 1]);
set(h2,'BaseValue',min([min(HPDIRF(:,1,j,i)),min(HPDIRFdsgevar(:,1,j,i))]));
plot(1:options_.irf,MeanIRF(:,j,i),'-k','linewidth',3) plot(1:options_.irf,MeanIRF(:,j,i),'-k','linewidth',3)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
plot(1:options_.irf,MeanIRFdsgevar(:,j,i),'--k','linewidth',2) plot(1:options_.irf,MeanIRFdsgevar(:,j,i),'--k','linewidth',2)
plot(1:options_.irf,HPDIRFdsgevar(:,1,j,i),'--k','linewidth',1) plot(1:options_.irf,HPDIRFdsgevar(:,1,j,i),'--k','linewidth',1)
plot(1:options_.irf,HPDIRFdsgevar(:,2,j,i),'--k','linewidth',1) plot(1:options_.irf,HPDIRFdsgevar(:,2,j,i),'--k','linewidth',1)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
box on box on
axis tight axis tight
xlim([1 options_.irf]); xlim([1 options_.irf]);
@ -156,6 +159,4 @@ for i=fpar:npar,
end end
end% loop over exo_var end% loop over exo_var
myoutput.OutputFileName = OutputFileName; myoutput.OutputFileName = OutputFileName;