Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/fn_imcgraph.m

raw
1 function scaleout = fn_imcgraph(imf,nvar,imstp,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 temp1=zeros(nvar,1);
40 temp2=zeros(nvar,1);
41 maxval=zeros(nvar,1);
42 minval=zeros(nvar,1);
43 for i = 1:nvar
44 for j = 1:nvar
45 temp1(j)=max(imf(:,(j-1)*nvar+i));
46 temp2(j)=min(imf(:,(j-1)*nvar+i));
47 end
48 maxval(i)=max(temp1);
49 minval(i)=min(temp2);
50 end
51
52 scaleout = [maxval(:) minval(:)];
53
54 %--------------
55 % Column j: Shock 1 to N; Row i: Responses to
56 %-------------
57 if indxGimfml
58 %figure
59 rowlabel = 1;
60 for i = 1:nvar % Responses of
61 columnlabel = 1;
62
63 if minval(i)<0
64 if maxval(i)<=0
65 yt=[minval(i) 0];
66 else
67 yt=[minval(i) 0 maxval(i)];
68 end
69 else % (minval(i) >=0)
70 if maxval(i) > 0
71 yt=[0 maxval(i)];
72 else % (identically zero responses)
73 yt=[-1 0 1];
74 end
75 end
76
77
78 scale=[1 imstp minval(i) maxval(i)];
79 for j = 1:nvar % To shocks
80 k1=(i-1)*nvar+j;
81 k2=(j-1)*nvar+i;
82 subplot(nvar,nvar,k1)
83 plot(t,imf(:,k2),t,zeros(length(imf(:,k2)),1),'r:');
84
85 if ~isempty(xTick)
86 set(gca,'XTick',xTick)
87 end
88 set(gca,'YTick',yt)
89 grid
90
91 axis(scale); % put limits on both axes.
92 %
93 % if maxval(i)>minval(i)
94 % set(gca,'YLim',[minval(i) maxval(i)])
95 % end
96
97
98 if ~isempty(xTick)
99 if i<nvar
100 set(gca,'XTickLabelMode','manual','XTickLabel',[])
101 end
102 if j>1
103 set(gca,'YTickLabel',' ');
104 end
105 end
106
107
108 if rowlabel == 1
109 %title(['x' num2str(j)])
110 %title(eval(['x' num2str(j)]))
111 title(char(xlab(j)))
112 end
113 if columnlabel == 1
114 %ylabel(['x' num2str(i)])
115 %ylabel(eval(['x' num2str(i)]))
116 ylabel(char(ylab(i)))
117 end
118 columnlabel = 0;
119 end
120 rowlabel = 0;
121 end
122 end