| 1 |
function fn_forerrgraph(yfore,yforel,yforeh,yacte,keyindx,rnum,cnum,q_m,ylab,forelabel,conlab) |
| 2 |
% |
| 3 |
% Graph annual (or calendar year) forecasts with one error band vs actual |
| 4 |
% Import some data from "msstart.m" |
| 5 |
% |
| 6 |
% yfore: both actual and forecast annual growth data with dates in the first 2 columns |
| 7 |
% in the order of year and month (or quarter). |
| 8 |
% yforel: lower bound of the forecast. |
| 9 |
% yforeh: high bound of the forecast. |
| 10 |
% yacte: actual annual growth data with dates. |
| 11 |
% keyindx: index for the variables to be graphed |
| 12 |
% rnum: number of rows in subplot |
| 13 |
% cnum: number of columns in subplot |
| 14 |
% q_m: if 4 or 12, quarterly or monthly data. |
| 15 |
% ylab: string array for the length(keyindx)-by-1 variables |
| 16 |
% forelabel: title label for as of time of forecast |
| 17 |
% conlab: x-axis label for what conditions imposed; e.g., conlab = 'All bar MS shocks inspl' |
| 18 |
%------------- |
| 19 |
% No output argument for this graph file. |
| 20 |
% See fn_seriesgraph.m, fn_foregraph.m. |
| 21 |
% |
| 22 |
% Tao Zha, August 2000 |
| 23 |
% |
| 24 |
% Copyright (C) 1997-2012 Tao Zha |
| 25 |
% |
| 26 |
% This free software: you can redistribute it and/or modify |
| 27 |
% it under the terms of the GNU General Public License as published by |
| 28 |
% the Free Software Foundation, either version 3 of the License, or |
| 29 |
% (at your option) any later version. |
| 30 |
% |
| 31 |
% It is distributed in the hope that it will be useful, |
| 32 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 33 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 34 |
% GNU General Public License for more details. |
| 35 |
% |
| 36 |
% If you did not received a copy of the GNU General Public License |
| 37 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 38 |
% |
| 39 |
|
| 40 |
|
| 41 |
vyrs = yfore(:,1); % vectorized |
| 42 |
hornum = cell(length(vyrs),1); % horizontal year (number) |
| 43 |
count=0; |
| 44 |
for k=vyrs' |
| 45 |
count=count+1; |
| 46 |
jnk=num2str(k); |
| 47 |
hornum{count}=jnk(3:4); % e.g., with '1990', we have '90' |
| 48 |
end |
| 49 |
|
| 50 |
count=0; |
| 51 |
for i = keyindx |
| 52 |
count = count+1; |
| 53 |
subplot(rnum,cnum,count) |
| 54 |
plot(yacte(:,1)+yacte(:,2)/q_m,yacte(:,2+i),yfore(:,1)+yfore(:,2)/q_m,yfore(:,2+i),'--',... |
| 55 |
yforel(:,1)+yforel(:,2)/q_m,yforel(:,2+i),'-.',yforeh(:,1)+yforeh(:,2)/q_m,yforeh(:,2+i),'-.') |
| 56 |
|
| 57 |
if (yfore(1,2)==0) % only for annual growth rates (not for, say, monthly annualized rates) |
| 58 |
set(gca,'XLim',[vyrs(1) vyrs(end)]) |
| 59 |
set(gca,'XTick',vyrs) |
| 60 |
set(gca,'XTickLabel',char(hornum)) |
| 61 |
end |
| 62 |
|
| 63 |
if i==keyindx(1) |
| 64 |
title(forelabel) |
| 65 |
elseif i>=length(keyindx) %i>=length(keyindx)-1 |
| 66 |
xlabel(conlab) |
| 67 |
end |
| 68 |
% |
| 69 |
grid |
| 70 |
ylabel(char(ylab(i))) |
| 71 |
end |