Home > matlab > PosteriorIRF_core2.m

PosteriorIRF_core2

PURPOSE ^

PARALLEL CONTEXT

SYNOPSIS ^

function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab)

DESCRIPTION ^

 PARALLEL CONTEXT
 Perfome in parallel a portion of  PosteriorIRF.m code.
 See also the comment in random_walk_metropolis_hastings_core.m funtion.

 INPUTS
   See the comment in random_walk_metropolis_hastings_core.m funtion.

 OUTPUTS
 o myoutput  [struc]
  Contained:
  OutputFileName (i.e. the figures without the file .txt).

 ALGORITHM
   Portion of PosteriorIRF.m function code. Specifically the last 'for' cycle.

 SPECIAL REQUIREMENTS.
   None.

 Copyright (C) 2006-2011 Dynare Team

 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/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab)
0002 % PARALLEL CONTEXT
0003 % Perfome in parallel a portion of  PosteriorIRF.m code.
0004 % See also the comment in random_walk_metropolis_hastings_core.m funtion.
0005 %
0006 % INPUTS
0007 %   See the comment in random_walk_metropolis_hastings_core.m funtion.
0008 %
0009 % OUTPUTS
0010 % o myoutput  [struc]
0011 %  Contained:
0012 %  OutputFileName (i.e. the figures without the file .txt).
0013 %
0014 % ALGORITHM
0015 %   Portion of PosteriorIRF.m function code. Specifically the last 'for' cycle.
0016 %
0017 % SPECIAL REQUIREMENTS.
0018 %   None.
0019 %
0020 % Copyright (C) 2006-2011 Dynare Team
0021 %
0022 % This file is part of Dynare.
0023 %
0024 % Dynare is free software: you can redistribute it and/or modify
0025 % it under the terms of the GNU General Public License as published by
0026 % the Free Software Foundation, either version 3 of the License, or
0027 % (at your option) any later version.
0028 %
0029 % Dynare is distributed in the hope that it will be useful,
0030 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0031 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0032 % GNU General Public License for more details.
0033 %
0034 % You should have received a copy of the GNU General Public License
0035 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0036 
0037 global options_  M_ 
0038 
0039 if nargin<4,
0040     whoiam=0;
0041 end
0042 
0043 % Reshape 'myinputs' for local computation.
0044 % In order to avoid confusion in the name space, the instruction struct2local(myinputs) is replaced by:
0045 
0046 Check=options_.TeX;
0047 if (Check)
0048     varlist_TeX=myinputs.varlist_TeX;
0049 end
0050 
0051 nvar=myinputs.nvar;
0052 MeanIRF=myinputs.MeanIRF;
0053 tit=myinputs.tit;
0054 nn=myinputs.nn;
0055 MAX_nirfs_dsgevar=myinputs.MAX_nirfs_dsgevar;
0056 HPDIRF=myinputs.HPDIRF;
0057 if options_.dsge_var
0058     HPDIRFdsgevar=myinputs.HPDIRFdsgevar;
0059     MeanIRFdsgevar=myinputs.MeanIRFdsgevar;
0060 end
0061 
0062 varlist=myinputs.varlist;
0063 MaxNumberOfPlotPerFigure=myinputs.MaxNumberOfPlotPerFigure;
0064 
0065 % Necessary only for remote computing!
0066 if whoiam
0067     Parallel=myinputs.Parallel;
0068 end
0069 
0070 % To save the figures where the function is computed!
0071 
0072 DirectoryName = CheckPath('Output',M_.dname);
0073 
0074 RemoteFlag = 0;
0075 if whoiam,
0076     if Parallel(ThisMatlab).Local==0,
0077         RemoteFlag =1;
0078     end
0079     prct0={0,whoiam,Parallel(ThisMatlab)};
0080     dyn_waitbar(prct0,'PosteriorIRF Plots ...');
0081 end
0082 
0083 OutputFileName={};
0084 
0085 subplotnum = 0;
0086 for i=fpar:npar,
0087     figunumber = 0;
0088     
0089     for j=1:nvar
0090         if max(abs(MeanIRF(:,j,i))) > 10^(-6)
0091             subplotnum = subplotnum+1;
0092             dyn_figure(options_,'Name',['Relative response to orthogonalized shock to ' tit(i,:)])
0093             if subplotnum == 1 && options_.relative_irf
0094                 hh = dyn_figure(options_,'Name',['Relative response to orthogonalized shock to ' tit(i,:)]);
0095             elseif subplotnum == 1 && ~options_.relative_irf
0096                 hh = dyn_figure(options_,'Name',['Orthogonalized shock to ' tit(i,:)]);
0097             end
0098             
0099             set(0,'CurrentFigure',hh)
0100             subplot(nn,nn,subplotnum);
0101             if ~MAX_nirfs_dsgevar
0102                 h1 = area(1:options_.irf,HPDIRF(:,2,j,i));
0103                 set(h1,'FaceColor',[.9 .9 .9]);
0104                 set(h1,'BaseValue',min(HPDIRF(:,1,j,i)));
0105                 hold on
0106                 h2 = area(1:options_.irf,HPDIRF(:,1,j,i),'FaceColor',[1 1 1],'BaseValue',min(HPDIRF(:,1,j,i)));
0107                 set(h2,'FaceColor',[1 1 1]);
0108                 set(h2,'BaseValue',min(HPDIRF(:,1,j,i)));
0109                 plot(1:options_.irf,MeanIRF(:,j,i),'-k','linewidth',3)
0110                 % plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
0111                 box on
0112                 axis tight
0113                 xlim([1 options_.irf]);
0114                 hold off
0115             else    
0116                 h1 = area(1:options_.irf,HPDIRF(:,2,j,i));
0117                 set(h1,'FaceColor',[.9 .9 .9]);
0118                 set(h1,'BaseValue',min([min(HPDIRF(:,1,j,i)),min(HPDIRFdsgevar(:,1,j,i))]));
0119                 hold on;
0120                 h2 = area(1:options_.irf,HPDIRF(:,1,j,i));
0121                 set(h2,'FaceColor',[1 1 1]);
0122                 set(h2,'BaseValue',min([min(HPDIRF(:,1,j,i)),min(HPDIRFdsgevar(:,1,j,i))]));
0123                 plot(1:options_.irf,MeanIRF(:,j,i),'-k','linewidth',3)
0124                 % plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
0125                 plot(1:options_.irf,MeanIRFdsgevar(:,j,i),'--k','linewidth',2)
0126                 plot(1:options_.irf,HPDIRFdsgevar(:,1,j,i),'--k','linewidth',1)
0127                 plot(1:options_.irf,HPDIRFdsgevar(:,2,j,i),'--k','linewidth',1)
0128                 box on
0129                 axis tight
0130                 xlim([1 options_.irf]);
0131                 hold off
0132             end
0133             name = deblank(varlist(j,:));
0134             title(name,'Interpreter','none')
0135         end
0136         
0137         if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar  && subplotnum> 0)
0138             figunumber = figunumber+1;
0139             dyn_saveas(hh,[DirectoryName '/'  M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)],options_);
0140             if RemoteFlag==1,
0141                 OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}];
0142             end
0143             subplotnum = 0;
0144         end
0145     end% loop over selected endo_var
0146     if whoiam,
0147         fprintf('Done! \n');
0148         waitbarString = [ 'Exog. shocks ' int2str(i) '/' int2str(npar) ' done.'];
0149 %         fMessageStatus((i-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
0150         dyn_waitbar((i-fpar+1)/(npar-fpar+1),[],waitbarString);
0151     end
0152 end% loop over exo_var
0153 
0154 
0155 
0156 myoutput.OutputFileName = OutputFileName;
0157

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005