Debian Codegraph @

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

raw
1 function gaf(yrEnd,qmEnd,q_m,yearsCal,yactCalyg,forepy,...
2 yhatCalygml,xlab,ylab,forelabel,conlab,keyindx,rnum,cnum)
3 % gaf(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/20/99
26
27 %
28 % Copyright (C) 1997-2012 Tao Zha
29 %
30 % This free software: you can redistribute it and/or modify
31 % it under the terms of the GNU General Public License as published by
32 % the Free Software Foundation, either version 3 of the License, or
33 % (at your option) any later version.
34 %
35 % It is distributed in the hope that it will be useful,
36 % but WITHOUT ANY WARRANTY; without even the implied warranty of
37 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 % GNU General Public License for more details.
39 %
40 % If you did not received a copy of the GNU General Public License
41 % with this software, see <http://www.gnu.org/licenses/>.
42 %
43
44
45
46 %*** Begining forecast (actual) 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 abegy = min(yearsCal); % the actual beginning year for the graph, NOT the same as
55 % the first forecast year
56 %abegm = 1;
57 ifbegy = find(yearsCal==fbegy-1); % index for the actual year in "yactCalyg"
58 % before the first forecast year
59
60 %*** Final forecast (and actual) period
61 ffiny = fbegy+forepy-1; % the forecast final year
62 afiny = max(yearsCal); % the actual final year for the graph, coinciding with
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 cnum = 2;
82 %
83 for i = keyindx
84 count = count+1;
85 subplot(rnum,cnum,count)
86 %
87 if abegy>fbegy-1
88 plot(abegy:afiny,yactCalyg(:,i),fbegy:ffiny,yhatCalygml(:,i),'-.')
89 set(gca,'XTick',abegy:ffiny)
90 else
91 plot(abegy:afiny,yactCalyg(:,i),...
92 fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygml(:,i)],'-.')
93 set(gca,'XTick',abegy:ffiny)
94 end
95 set(gca,'XTickLabel',char(hornum))
96 if i<=cnum
97 title(forelabel)
98 elseif i>=nvar-1
99 xlabel(conlab)
100 end
101 %
102 grid
103 ylabel(char(ylab(i)))
104 end