Debian Codegraph @

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

raw
1 function ExactSmyear = gshock(begy,begm,finy,finm,xlab,idfile,tlinput)
2 % ExactSmyear = gshock(begy,begm,finy,finm,xlab)
3 % Plot the structural shocks for the range given by the inputs
4 %
5 % begy: the beginning year for the graph
6 % begm: the begiining month for the graph
7 % finy: the end year for the graph
8 % finm: the end month for the graph
9 % xlab: label for each structural equation
10 %-----------
11 % ExactSmyear: time (myears) and all structural shocks
12 % if no nargout, plot graphics.
13 %
14 % October 1998 by Tao A. Zha
15 %
16 % Copyright (C) 1997-2012 Tao Zha
17 %
18 % This free software: you can redistribute it and/or modify
19 % it under the terms of the GNU General Public License as published by
20 % the Free Software Foundation, either version 3 of the License, or
21 % (at your option) any later version.
22 %
23 % It is distributed in the hope that it will be useful,
24 % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 % GNU General Public License for more details.
27 %
28 % If you did not received a copy of the GNU General Public License
29 % with this software, see <http://www.gnu.org/licenses/>.
30 %
31
32
33
34 eval(['load ' idfile '.mat']);
35
36 %
37 ibegy = find(myears==begy);
38 ifiny = find(myears==finy);
39
40 ibegy1 = find(myears==begy+1);
41
42 %
43 if isempty(ibegy) & isempty(ibegy1)
44 warning('Either ibegy or begm is out of the range of myears')
45 disp('Print myears to see the range')
46 disp('Or change actuap to make the range longer and save new results to Xshock.mat')
47 pause
48 elseif isempty(ibegy) & (begm<myears(1))
49 warning('Either ibegy or begm is out of the range of myears')
50 disp('Print myears to see the range')
51 disp('Or change actuap to make the range longer and save new results to Xshock.mat')
52 pause
53 elseif isempty(ibegy)
54 ibegy = -myears(1)+2; % +2 is needed for the following -1 in
55 % bar(Estrexa(ibegy+begm-1:ifiny+finm-1,i))
56 %so that it 2-1=1 so that +1 is what we want
57 end
58
59 %
60 if isempty(ifiny)
61 warning('Either ifiny or finm is out of the range of myears')
62 disp('Print myears to see the range')
63 disp('Or change actuap to make the range longer and save new results to Xshock.mat')
64 pause
65 elseif (ifiny+finm-1>size(myears,1))
66 warning('Either ifiny or finm is out of the range of myears')
67 disp('Print myears to see the range')
68 disp('Or change actuap to make the range longer and save new results to Xshock.mat')
69 pause
70 end
71
72
73 if nargout==0
74 t=length(Estrexa(ibegy+begm-1:ifiny+finm-1,1));
75 for i=1:size(Estrexa,2)
76 figure
77 %plot(1:t, Estrexa(ibegy+begm-1:ifiny+finm-1,i));
78 bar(Estrexa(ibegy+begm-1:ifiny+finm-1,i))
79 title([ tlinput ' Monthly Structural Shocks' ])
80 ylabel(char(xlab(i)))
81 xlabel([ 'From ' num2str(begy) ':' num2str(begm) ' to ' ...
82 num2str(finy) ':' num2str(finm) ])
83 grid
84 end
85 else
86 ExactSmyear = [myears(ibegy+begm-1:ifiny+finm-1) Estrexa(ibegy+begm-1:ifiny+finm-1,:)];
87 end