Home > matlab > graph_decomp.m

graph_decomp

PURPOSE ^

function []=graph_decomp(z,varlist,initial_period,freq)

SYNOPSIS ^

function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date)

DESCRIPTION ^

function []=graph_decomp(z,varlist,initial_period,freq)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date)
0002 %function []=graph_decomp(z,varlist,initial_period,freq)
0003 
0004 % Copyright (C) 2010 Dynare Team
0005 %
0006 % This file is part of Dynare.
0007 %
0008 % Dynare is free software: you can redistribute it and/or modify
0009 % it under the terms of the GNU General Public License as published by
0010 % the Free Software Foundation, either version 3 of the License, or
0011 % (at your option) any later version.
0012 %
0013 % Dynare is distributed in the hope that it will be useful,
0014 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016 % GNU General Public License for more details.
0017 %
0018 % You should have received a copy of the GNU General Public License
0019 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 % number of components equals number of shocks + 1 (initial conditions)
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

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