Debian Codegraph @

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

raw
1 function gforerr1(yrEnd,qmEnd,q_m,forepy,yhatCalygml,yhatCalygl1,...
2 yhatCalygh1,xlab,ylab,forelabel,conlab,keyindx,rnum,cnum)
3
4 %
5 % One (.68) error band: (calendar year) forecasts only (no actual)
6 %
7 % yrEnd: the end year for the sample
8 % qmEnd: last q_m before out-of-sample forecasting
9 % q_m: quarterly or monthly for the underlying model
10 % yearsCal: calendar years including actual and forecast data
11 % yactCalyg: actual calendar annual growth data
12 % yhatCalygml: conditional (calendar annual) forecasts on particular shocks
13 % yhatCalygl1: 0.68 lower band
14 % yhatCalygh1: 0.68 upper band
15 % forepy: forecast periods (yearly)
16 % xlab: label for structural equations
17 % ylab: label for the variables
18 % forelabel: title label for as of time of forecast
19 % conlab: label for what conditions imposed; e.g., conlab = 'All bar MS shocks inspl'
20 % keyindx: index for the variables to be graphed
21 % rnum: number of rows in subplot
22 % cnum: number of columns in subplot
23 %-------------
24 % No output argument for this graph file
25 %
26 % 03/19/99
27
28 %
29 % Copyright (C) 1997-2012 Tao Zha
30 %
31 % This free software: you can redistribute it and/or modify
32 % it under the terms of the GNU General Public License as published by
33 % the Free Software Foundation, either version 3 of the License, or
34 % (at your option) any later version.
35 %
36 % It is distributed in the hope that it will be useful,
37 % but WITHOUT ANY WARRANTY; without even the implied warranty of
38 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 % GNU General Public License for more details.
40 %
41 % If you did not received a copy of the GNU General Public License
42 % with this software, see <http://www.gnu.org/licenses/>.
43 %
44
45
46 %*** Begining period
47 fbegm = qmEnd+1; % +1 because the first month out of sample
48 if fbegm > q_m % the first forecast month into the next year
49 fbegm = 1;
50 fbegy = yrEnd+1; % the first forecast year for the graph
51 else
52 fbegy = yrEnd; % the first forecast year for the graph
53 end
54 %
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(fbegy:ffiny),1); % horizontal number
73 count=0;
74 for k=fbegy: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 plot(fbegy:ffiny,yhatCalygml(:,i),'-',...
87 fbegy:ffiny,yhatCalygl1(:,i),'--',fbegy:ffiny,yhatCalygh1(:,i),'--' )
88 set(gca,'XTick',fbegy:ffiny)
89 set(gca,'XTickLabel',char(hornum))
90 if i<=cnum
91 title(forelabel)
92 elseif i>=nvar-1
93 xlabel(conlab)
94 end
95 %
96 grid
97 ylabel(char(ylab(i)))
98 end