Debian Codegraph @

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

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