0001 function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 comp_nbr = size(z,2)-1;
0023
0024 gend = size(z,3);
0025 freq = initial_date.freq;
0026 initial_period = initial_date.period + initial_date.subperiod/freq;
0027 x = initial_period-1/freq:(1/freq):initial_period+(gend-1)/freq;
0028
0029 nvar = length(i_var);
0030
0031 for j=1:nvar
0032 z1 = squeeze(z(i_var(j),:,:));
0033 xmin = x(1);
0034 xmax = x(end);
0035 ix = z1 > 0;
0036 ymax = max(sum(z1.*ix));
0037 ix = z1 < 0;
0038 ymin = min(sum(z1.*ix));
0039 if ymax-ymin < 1e-6
0040 continue
0041 end
0042 figure('Name',endo_names(i_var(j),:));
0043 ax=axes('Position',[0.1 0.1 0.6 0.8]);
0044 axis(ax,[xmin xmax ymin ymax]);
0045 plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2)
0046 hold on;
0047 for i=1:gend
0048 i_1 = i-1;
0049 yp = 0;
0050 ym = 0;
0051 for k = 1:comp_nbr
0052 zz = z1(k,i);
0053 if zz > 0
0054 fill([x(i) x(i) x(i+1) x(i+1)],[yp yp+zz yp+zz yp],k);
0055 yp = yp+zz;
0056 else
0057 fill([x(i) x(i) x(i+1) x(i+1)],[ym ym+zz ym+zz ym],k);
0058 ym = ym+zz;
0059 end
0060 hold on;
0061 end
0062 end
0063 plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2)
0064 hold off;
0065
0066 axes('Position',[0.75 0.1 0.2 0.8]);
0067 axis([0 1 0 1]);
0068 axis off;
0069 hold on;
0070 y1 = 0;
0071 height = 1/comp_nbr;
0072 labels = char(shock_names,'Initial values');
0073
0074 for j=1:comp_nbr
0075 fill([0 0 0.2 0.2],[y1 y1+0.7*height y1+0.7*height y1],j);
0076 hold on
0077 text(0.3,y1+0.3*height,labels(j,:),'Interpreter','none');
0078 hold on
0079 y1 = y1 + height;
0080 end
0081 hold off
0082 end