| 1 |
function scaleout = imc2errgraph(imf,firstl1,firsth1,... |
| 2 |
firstl,firsth,nvar,imstp,xlab,ylab,indxGimfml,xTick) |
| 3 |
% imc2errgraph: impulse, c (column: shock 1 to N), 2 error bands, graph |
| 4 |
% |
| 5 |
% imf: imstp-by-nvar^2 matrix of impulse responses. Column (responses to 1st shock, responses to 2nd shock |
| 6 |
% etc), Row (impusle steps), |
| 7 |
% firstl1: lower band, .68 |
| 8 |
% highth1: high band, .68 |
| 9 |
% firstl: lower band, .90 |
| 10 |
% highth: high band, .90 |
| 11 |
% nvar: number of variables |
| 12 |
% imstp: number of steps of impulse responses |
| 13 |
% xlab,ylab: labels |
| 14 |
% indxGimfml: 1, graph; 0, no graph |
| 15 |
% xTick: optional. Eg: [12 24 36]. |
| 16 |
%--------------- |
| 17 |
% scaleout: column 1 represents maximums; column 2 minimums. Rows: nvar variables. |
| 18 |
% |
| 19 |
% See imrgraph, fn_imcerrgraph, imrerrgraph |
| 20 |
% |
| 21 |
% Copyright (C) 1997-2012 Tao Zha |
| 22 |
% |
| 23 |
% This free software: you can redistribute it and/or modify |
| 24 |
% it under the terms of the GNU General Public License as published by |
| 25 |
% the Free Software Foundation, either version 3 of the License, or |
| 26 |
% (at your option) any later version. |
| 27 |
% |
| 28 |
% It is distributed in the hope that it will be useful, |
| 29 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 |
% GNU General Public License for more details. |
| 32 |
% |
| 33 |
% If you did not received a copy of the GNU General Public License |
| 34 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 35 |
% |
| 36 |
|
| 37 |
|
| 38 |
if nargin < 11, xTick = []; end |
| 39 |
|
| 40 |
t = 1:imstp; |
| 41 |
temp1=zeros(nvar,1); |
| 42 |
temp2=zeros(nvar,1); |
| 43 |
maxval=zeros(nvar,1); |
| 44 |
minval=zeros(nvar,1); |
| 45 |
for i = 1:nvar |
| 46 |
for j = 1:nvar |
| 47 |
jnk1=max(firsth(:,(j-1)*nvar+i)); |
| 48 |
jnk2=max(firstl(:,(j-1)*nvar+i)); |
| 49 |
jnk3=max(firsth1(:,(j-1)*nvar+i)); |
| 50 |
jnk4=max(firstl1(:,(j-1)*nvar+i)); |
| 51 |
jnk5=max(imf(:,(j-1)*nvar+i)); |
| 52 |
|
| 53 |
temp1(j)=max([jnk1 jnk2 jnk3 jnk4 jnk5]); |
| 54 |
% |
| 55 |
jnk1=min(firstl(:,(j-1)*nvar+i)); |
| 56 |
jnk2=min(firsth(:,(j-1)*nvar+i)); |
| 57 |
jnk3=min(firstl1(:,(j-1)*nvar+i)); |
| 58 |
jnk4=min(firsth1(:,(j-1)*nvar+i)); |
| 59 |
jnk5=min(imf(:,(j-1)*nvar+i)); |
| 60 |
|
| 61 |
temp2(j)=min([jnk1 jnk2 jnk3 jnk4 jnk5]); |
| 62 |
end |
| 63 |
maxval(i)=max(temp1); |
| 64 |
minval(i)=min(temp2); |
| 65 |
end |
| 66 |
|
| 67 |
scaleout = [maxval(:) minval(:)]; |
| 68 |
|
| 69 |
%-------------- |
| 70 |
% Column j: Shock 1 to N; Row i: Responses to |
| 71 |
%------------- |
| 72 |
if indxGimfml |
| 73 |
%figure |
| 74 |
rowlabel = 1; |
| 75 |
for i = 1:nvar |
| 76 |
columnlabel = 1; |
| 77 |
|
| 78 |
if minval(i)<0 |
| 79 |
if maxval(i)<=0 |
| 80 |
yt=[minval(i) 0]; |
| 81 |
else |
| 82 |
yt=[minval(i) 0 maxval(i)]; |
| 83 |
end |
| 84 |
else % (minval(i) >=0) |
| 85 |
if maxval(i) > 0 |
| 86 |
yt=[0 maxval(i)]; |
| 87 |
else % (identically zero responses) |
| 88 |
yt=[-1 0 1]; |
| 89 |
end |
| 90 |
end |
| 91 |
|
| 92 |
scale=[1 imstp minval(i) maxval(i)]; |
| 93 |
for j = 1:nvar |
| 94 |
k1=(i-1)*nvar+j; |
| 95 |
k2=(j-1)*nvar+i; |
| 96 |
subplot(nvar,nvar,k1) |
| 97 |
plot(t,imf(:,k2),t,[firstl1(:,k2) firsth1(:,k2)],'--',... |
| 98 |
t,[firstl(:,k2) firsth(:,k2)],'-.',t,zeros(length(imf(:,k2)),1),'-'); |
| 99 |
|
| 100 |
set(gca,'XTick',xTick) |
| 101 |
set(gca,'YTick',yt) |
| 102 |
grid; |
| 103 |
|
| 104 |
axis(scale); % put limits on both axes. |
| 105 |
%set(gca,'YLim',[minval(i) maxval(i)]) |
| 106 |
if 1 % no numbers on axes |
| 107 |
set(gca,'XTickLabel',' '); |
| 108 |
set(gca,'YTickLabel',' '); |
| 109 |
else % put numbers on both axes |
| 110 |
if i<nvar |
| 111 |
set(gca,'XTickLabelMode','manual','XTickLabel',[]) |
| 112 |
end |
| 113 |
if j>1 |
| 114 |
set(gca,'YTickLabel',' '); |
| 115 |
end |
| 116 |
end |
| 117 |
|
| 118 |
if rowlabel == 1 |
| 119 |
%title(['x' num2str(j)]) |
| 120 |
%title(eval(['x' num2str(j)])) |
| 121 |
title(char(xlab(j))) |
| 122 |
end |
| 123 |
if columnlabel == 1 |
| 124 |
%ylabel(['x' num2str(i)]) |
| 125 |
%ylabel(eval(['x' num2str(i)])) |
| 126 |
ylabel(char(ylab(i))) |
| 127 |
end |
| 128 |
columnlabel = 0; |
| 129 |
end |
| 130 |
rowlabel = 0; |
| 131 |
end |
| 132 |
end |