0001 function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam, ThisMatlab)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 global options_ M_
0038
0039 if nargin<4,
0040 whoiam=0;
0041 end
0042
0043
0044
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
0066 if whoiam
0067 Parallel=myinputs.Parallel;
0068 end
0069
0070
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
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
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
0146 if whoiam,
0147 fprintf('Done! \n');
0148 waitbarString = [ 'Exog. shocks ' int2str(i) '/' int2str(npar) ' done.'];
0149
0150 dyn_waitbar((i-fpar+1)/(npar-fpar+1),[],waitbarString);
0151 end
0152 end
0153
0154
0155
0156 myoutput.OutputFileName = OutputFileName;
0157