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