File: gfore.m

package info (click to toggle)
dynare 4.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,408 kB
  • sloc: cpp: 84,998; ansic: 29,058; pascal: 13,843; sh: 4,833; objc: 4,236; yacc: 3,622; makefile: 2,278; lex: 1,541; python: 236; lisp: 69; xml: 8
file content (102 lines) | stat: -rw-r--r-- 3,437 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function gfore(yrEnd,qmEnd,q_m,yearsCal,yactCalyg,forepy,...
                       yhatCalygml,xlab,ylab,forelabel,conlab,keyindx,rnum,cnum)
% gfore(yrEnd,qmEnd,q_m,yearsCal,yactCalyg,forepy,...
%                       yhatCalygml,xlab,ylab,forelabel,conlab,keyindx,rnum,cnum)
%   Graph (calendar year) forecasts vs actual (actual from "msstart.m")
%     Make sure that actup in "msstart.m" is set at the length for visual graphs
%
% yrEnd:  the end year for the sample
% qmEnd:  last q_m before out-of-sample forecasting
% q_m:   quarterly or monthly for the underlying model
% yearsCal: calendar years including actual and forecast data
% yactCalyg:  actual calendar annual growth data
% yhatCalygml:  conditional (calendar annual) forecasts on particular shocks
% forepy:  forecast periods (yearly)
% xlab:  label for structural equations
% ylab:  label for the variables
% forelabel:  title label for as of time of forecast
% conlab:  label for what conditions imposed; e.g., conlab = 'All bar MS shocks inspl'
% keyindx:  index for the variables to be graphed
% rnum:  number of rows in subplot
% cnum:  number of columns in subplot
%-------------
% No output argument for this graph file
%
% October 1998 Tao Zha; revised, 03/17/99 -- May not be compatible with previous programs
%
% Copyright (C) 1997-2012 Tao Zha
%
% This free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% It is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% If you did not received a copy of the GNU General Public License
% with this software, see <http://www.gnu.org/licenses/>.
%



%*** Begining period
fbegm = qmEnd+1;   % +1 because the first month out of sample
if fbegm > q_m    % the first forecast month into the next year
	fbegm = 1;
	fbegy = yrEnd+1;   % the first forecast year for the graph
else
	fbegy = yrEnd;    % the first forecast year for the graph
end
abegy = min(yearsCal);   % the actual beginning year for the graph
abegm = 1;
ifbegy = find(yearsCal==fbegy-1);   % index for the year before the first
                % forecast first year in actual data "yactCalyg"

%*** Final period
ffiny = fbegy+forepy-1;   % the forecast final year
afiny = max(yearsCal);    % the actual final year



figure

nvar = size(yhatCalygml,2);      %  Pcm,M2,FFR,GdP, CPI, U
%keyindx = 1:nvar;      %  Pcm,M2,FFR,GdP, CPI, U
%keyindx = [4:nvar 3 2];      %  GdP, CPI, U, FFR, M2

hornum = cell(length(abegy:ffiny),1);    % horizontal number
count=0;
for k=abegy:ffiny
	count=count+1;
	jnk=num2str(k);
	hornum{count}=jnk(3:4);   % e.g., with '1990', we have '90'
end

count=0;
cnum = 2;
%
for i = keyindx
   count = count+1;
   subplot(rnum,cnum,count)
	%
   if abegy>fbegy-1
      plot(abegy:afiny,yactCalyg(:,i),fbegy:ffiny,yhatCalygml(:,i),'-.')
      set(gca,'XTick',abegy:ffiny)
   else
      plot(abegy:afiny,yactCalyg(:,i),...
        fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygml(:,i)],'-.')
      set(gca,'XTick',abegy:ffiny)
   end
	set(gca,'XTickLabel',char(hornum))
   if i<=cnum
   	title(forelabel)
	elseif i>=nvar-1
		xlabel(conlab)
	end
	%
	grid
	ylabel(char(ylab(i)))
end