Debian Codegraph @

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

raw
1 function gaferr1(yrEnd,qmEnd,q_m,yearsCal,yactCalyg,forepy,yhatCalygml,yhatCalygl1,...
2 yhatCalygh1,xlab,ylab,forelabel,conlab,keyindx,rnum,cnum)
3
4 %
5 % One (.68) error band: (calendar year) forecasts vs actual (actual from "msstart.m")
6 % Make sure that actup in "msstart.m" is set at the length for visual graphs
7 %
8 % yrEnd: the end year for the sample
9 % qmEnd: last q_m before out-of-sample forecasting
10 % q_m: quarterly or monthly for the underlying model
11 % yearsCal: calendar years including actual and forecast data
12 % yactCalyg: actual calendar annual growth data
13 % yhatCalygml: conditional (calendar annual) forecasts on particular shocks
14 % yhatCalygl1: 0.68 lower band
15 % yhatCalygh1: 0.68 upper band
16 % forepy: forecast periods (yearly)
17 % xlab: label for structural equations
18 % ylab: label for the variables
19 % forelabel: title label for as of time of forecast
20 % conlab: label for what conditions imposed; e.g., conlab = 'All bar MS shocks inspl'
21 % keyindx: index for the variables to be graphed
22 % rnum: number of rows in subplot
23 % cnum: number of columns in subplot
24 %-------------
25 % No output argument for this graph file
26 %
27 % 03/19/99
28
29 %
30 % Copyright (C) 1997-2012 Tao Zha
31 %
32 % This free software: you can redistribute it and/or modify
33 % it under the terms of the GNU General Public License as published by
34 % the Free Software Foundation, either version 3 of the License, or
35 % (at your option) any later version.
36 %
37 % It is distributed in the hope that it will be useful,
38 % but WITHOUT ANY WARRANTY; without even the implied warranty of
39 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 % GNU General Public License for more details.
41 %
42 % If you did not received a copy of the GNU General Public License
43 % with this software, see <http://www.gnu.org/licenses/>.
44 %
45
46
47 %*** Begining period
48 fbegm = qmEnd+1; % +1 because the first month out of sample
49 if fbegm > q_m % the first forecast month into the next year
50 fbegm = 1;
51 fbegy = yrEnd+1; % the first forecast year for the graph
52 else
53 fbegy = yrEnd; % the first forecast year for the graph
54 end
55 abegy = min(yearsCal); % the actual beginning year for the graph
56 abegm = 1;
57 ifbegy = find(yearsCal==fbegy-1); % index for the year before the first
58 % forecast first year in actual data "yactCalyg"
59
60 %*** Final period
61 ffiny = fbegy+forepy-1; % the forecast final year
62 afiny = max(yearsCal); % the actual final year
63
64
65
66 figure
67
68 nvar = size(yhatCalygml,2); % Pcm,M2,FFR,GdP, CPI, U
69 %keyindx = 1:nvar; % Pcm,M2,FFR,GdP, CPI, U
70 %keyindx = [4:nvar 3 2]; % GdP, CPI, U, FFR, M2
71
72 hornum = cell(length(abegy:ffiny),1); % horizontal number
73 count=0;
74 for k=abegy:ffiny
75 count=count+1;
76 jnk=num2str(k);
77 hornum{count}=jnk(3:4); % e.g., with '1990', we have '90'
78 end
79
80 count=0;
81 %
82 for i = keyindx
83 count = count+1;
84 subplot(rnum,cnum,count)
85 %
86 if abegy>fbegy-1
87 plot(abegy:afiny,yactCalyg(:,i),fbegy:ffiny,yhatCalygml(:,i),'-.',...
88 fbegy:ffiny,yhatCalygl1,'--',fbegy:ffiny,yhatCalygh1,'--' )
89 set(gca,'XTick',abegy:ffiny)
90 else
91 plot(abegy:afiny,yactCalyg(:,i),...
92 fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygml(:,i)],'-.',...
93 fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygl1(:,i)],'--',...
94 fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygh1(:,i)],'--')
95 set(gca,'XTick',abegy:ffiny)
96 end
97 set(gca,'XTickLabel',char(hornum))
98 if i<=cnum
99 title(forelabel)
100 elseif i>=nvar-1
101 xlabel(conlab)
102 end
103 %
104 grid
105 ylabel(char(ylab(i)))
106 end