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 103 104 105 106
|
function gaferr1(yrEnd,qmEnd,q_m,yearsCal,yactCalyg,forepy,yhatCalygml,yhatCalygl1,...
yhatCalygh1,xlab,ylab,forelabel,conlab,keyindx,rnum,cnum)
%
% One (.68) error band: (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
% yhatCalygl1: 0.68 lower band
% yhatCalygh1: 0.68 upper band
% 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
%
% 03/19/99
%
% 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;
%
for i = keyindx
count = count+1;
subplot(rnum,cnum,count)
%
if abegy>fbegy-1
plot(abegy:afiny,yactCalyg(:,i),fbegy:ffiny,yhatCalygml(:,i),'-.',...
fbegy:ffiny,yhatCalygl1,'--',fbegy:ffiny,yhatCalygh1,'--' )
set(gca,'XTick',abegy:ffiny)
else
plot(abegy:afiny,yactCalyg(:,i),...
fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygml(:,i)],'-.',...
fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygl1(:,i)],'--',...
fbegy-1:ffiny,[yactCalyg(ifbegy,i);yhatCalygh1(:,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
|