| 1 |
function noargout = ghistd(qmEnd,yrEnd,forepy,q_m,HDv,lendlab,titlab,ylab,timelab,rnum,cnum) |
| 2 |
% |
| 3 |
% Plot historical decompositions (annually at this time), no argument out |
| 4 |
% |
| 5 |
% qmEnd: the end month before the forecast |
| 6 |
% yrEnd: the end year before the forecast |
| 7 |
% forepy: the number of forecast calendar years |
| 8 |
% q_m: 12 or 4 (monthly or quarterly) |
| 9 |
% HDv: nHD-by-1 cell where nHD is number of decompositions; |
| 10 |
% each cell is forepy-by-nvar |
| 11 |
% lendlab: label for the lengend |
| 12 |
% titlab: label for the title |
| 13 |
% ylab: label for the variables |
| 14 |
% timelab: label for the time of forecast and indication of insample or out-of-sample |
| 15 |
% rnum: row number for the subplot (e.g., 3) |
| 16 |
% cnum: column number for the subplot (e.g., 2) |
| 17 |
%--------------- |
| 18 |
% no argument out |
| 19 |
% |
| 20 |
% October 1998 Tao Zha |
| 21 |
% |
| 22 |
% Copyright (C) 1997-2012 Tao Zha |
| 23 |
% |
| 24 |
% This free software: you can redistribute it and/or modify |
| 25 |
% it under the terms of the GNU General Public License as published by |
| 26 |
% the Free Software Foundation, either version 3 of the License, or |
| 27 |
% (at your option) any later version. |
| 28 |
% |
| 29 |
% It is distributed in the hope that it will be useful, |
| 30 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 |
% GNU General Public License for more details. |
| 33 |
% |
| 34 |
% If you did not received a copy of the GNU General Public License |
| 35 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 36 |
% |
| 37 |
|
| 38 |
% To be done: |
| 39 |
% lengend does not work well |
| 40 |
% colormap should be replaced by some non-color shading |
| 41 |
% title: need to have only one. |
| 42 |
|
| 43 |
fbegm = qmEnd+1; % +1 because the first month out of sample |
| 44 |
if fbegm > q_m % the first forecast month into the next year |
| 45 |
fbegm = 1; % reset |
| 46 |
fbegy = yrEnd+1; % the first forecast year for the graph |
| 47 |
else |
| 48 |
fbegy = yrEnd; % the first forecast year for the graph |
| 49 |
end |
| 50 |
ffiny = fbegy+forepy-1; % the forecast final year |
| 51 |
|
| 52 |
figure |
| 53 |
%cnum = 2; |
| 54 |
nvar = size(HDv{1},2); |
| 55 |
rnum = nvar/cnum; |
| 56 |
if ~(rnum==fix(rnum)) |
| 57 |
warning('Make that subplot is divided properly') |
| 58 |
disp('Check rnum as well as cnum') |
| 59 |
return |
| 60 |
end |
| 61 |
|
| 62 |
hornum = cell(length(fbegy:ffiny),1); % horizontal number |
| 63 |
count=0; |
| 64 |
for k=fbegy:ffiny |
| 65 |
count=count+1; |
| 66 |
jnk=num2str(k); |
| 67 |
hornum{count}=jnk(3:4); % e.g., with '1990', we have '90' |
| 68 |
end |
| 69 |
|
| 70 |
|
| 71 |
for k=1:nvar |
| 72 |
bardata = []; |
| 73 |
for n=1:size(HDv,1) |
| 74 |
bardata = [bardata HDv{n}(:,k)]; |
| 75 |
end |
| 76 |
|
| 77 |
subplot(rnum,cnum,k) |
| 78 |
bar(fbegy:ffiny,bardata,0.75,'group') |
| 79 |
set(gca,'XTickLabel',char(hornum)) |
| 80 |
if k==1 |
| 81 |
legend(char(lendlab),1) |
| 82 |
end |
| 83 |
colormatrix = [0.2 0.2 0.2;0.8 0.8 0.8]; |
| 84 |
colormap(colormatrix) |
| 85 |
if k<=cnum |
| 86 |
title(char(titlab)) |
| 87 |
end |
| 88 |
if k>((rnum-1)*cnum) |
| 89 |
xlabel(timelab) |
| 90 |
end |
| 91 |
grid |
| 92 |
ylabel(char(ylab{k})) |
| 93 |
end |