Debian Codegraph @

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

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