| 1 |
function actual = gactual(begy,begm,begq,finy,finm,finq,ylab,mqyIndx,idfile) |
| 2 |
% |
| 3 |
% actual = gactual(begy,begm,begq,finy,finm,finq,ylab,mqyIndx,idfile) |
| 4 |
% Actual data according to mqyIndx; graph if no output argument is specified. |
| 5 |
% |
| 6 |
% begy: the beginning year for the graph |
| 7 |
% begm: the begiining month for the graph |
| 8 |
% begq: the begiining quarter for the graph |
| 9 |
% finy: the end year for the graph |
| 10 |
% finm: the end month for the graph |
| 11 |
% finq: the end quarter for the graph |
| 12 |
% ylab: label for each variable |
| 13 |
% mqyIndx: 1-by-3 index of monthly log, qg, and calendar yg. 1: yes; 0: no. |
| 14 |
% Only one at a time |
| 15 |
% idfile: import xinample.mat in the LZ paper under \condz |
| 16 |
%-------------- |
| 17 |
% actual: T-by-nvar+1; 1st column is the dates; 2nd-7th columns: actual data of |
| 18 |
% of nvar variables with mlog, qg, or calendar yg, one at a time, |
| 19 |
% depending on mqyIndx |
| 20 |
% graph if no output argument is specified. |
| 21 |
% |
| 22 |
% |
| 23 |
% When insampleg.m is run, xinsample.mat is loaded for a long |
| 24 |
% history (e.g.,1960-1998) |
| 25 |
% When mspoint.m is run, outxshock.mat from msstart is loaded, which varies |
| 26 |
% with parac.m. |
| 27 |
% |
| 28 |
% October 1998 by Tao A. Zha |
| 29 |
% |
| 30 |
% Copyright (C) 1997-2012 Tao Zha |
| 31 |
% |
| 32 |
% This free software: you can redistribute it and/or modify |
| 33 |
% it under the terms of the GNU General Public License as published by |
| 34 |
% the Free Software Foundation, either version 3 of the License, or |
| 35 |
% (at your option) any later version. |
| 36 |
% |
| 37 |
% It is distributed in the hope that it will be useful, |
| 38 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 39 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 40 |
% GNU General Public License for more details. |
| 41 |
% |
| 42 |
% If you did not received a copy of the GNU General Public License |
| 43 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 44 |
% |
| 45 |
|
| 46 |
|
| 47 |
eval(['load ' idfile '.mat']); |
| 48 |
% |
| 49 |
|
| 50 |
if length(find(mqyIndx))>1 |
| 51 |
warning('To get the number (not graph) out, only one at a time') |
| 52 |
disp('Make sure that mqyIndx has only 1 in a vector of 1 and 0s') |
| 53 |
disp(' ') |
| 54 |
disp('Press Enter to continue or Ctrl to abort') |
| 55 |
pause |
| 56 |
end |
| 57 |
|
| 58 |
if mqyIndx(1)==1 % monthly log |
| 59 |
ibegy = find(myears==begy); |
| 60 |
ifiny = find(myears==finy); |
| 61 |
|
| 62 |
ibegy1 = find(myears==begy+1); |
| 63 |
% |
| 64 |
if isempty(ibegy) & isempty(ibegy1) |
| 65 |
warning('Either ibegy or begm is out of the range of myears in xinsample.mat') |
| 66 |
disp('Print myears to see the range') |
| 67 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 68 |
disp('Press ctrl-c to abort now') |
| 69 |
pause |
| 70 |
elseif isempty(ibegy) & (begm<myears(1)) |
| 71 |
warning('Either ibegy or begm is out of the range of myears in xinample.mat') |
| 72 |
disp('Print myears to see the range') |
| 73 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 74 |
disp('Press ctrl-c to abort now') |
| 75 |
pause |
| 76 |
elseif isempty(ibegy) |
| 77 |
ibegy = -myears(1)+2; % +2 is needed for the following -1 in |
| 78 |
% bar(Estrexa(ibegy+begm-1:ifiny+finm-1,i)) |
| 79 |
%so that it 2-1=1 so that +1 is what we want |
| 80 |
end |
| 81 |
% |
| 82 |
if isempty(ifiny) |
| 83 |
warning('Either ifiny or finm is out of the range of myears') |
| 84 |
disp('Print myears to see the range') |
| 85 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 86 |
return |
| 87 |
elseif (ifiny+finm-1>size(myears,1)) |
| 88 |
warning('Either ifiny or finm is out of the range of myears') |
| 89 |
disp('Print myears to see the range') |
| 90 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 91 |
return |
| 92 |
end |
| 93 |
|
| 94 |
|
| 95 |
if nargout==0 |
| 96 |
t=length(yact(ibegy+begm-1:ifiny+finm-1,1)); |
| 97 |
for i=1:size(yact,2) |
| 98 |
figure |
| 99 |
plot(1:t, yact(ibegy+begm-1:ifiny+finm-1,i),'*:'); |
| 100 |
%bar(yact(ibegy+begm-1:ifiny+finm-1,i)) |
| 101 |
title('Monthly Log') |
| 102 |
ylabel(char(ylab(i))) |
| 103 |
xlabel([ 'From ' num2str(begy) ':' num2str(begm) ' to ' ... |
| 104 |
num2str(finy) ':' num2str(finm) ]) |
| 105 |
grid |
| 106 |
end |
| 107 |
end |
| 108 |
|
| 109 |
actual = [myears(ibegy+begm-1:ifiny+finm-1) yact(ibegy+begm-1:ifiny+finm-1,:)]; |
| 110 |
end |
| 111 |
|
| 112 |
|
| 113 |
if mqyIndx(2)==1 % quarterly |
| 114 |
ibegy = find(qyears==begy); |
| 115 |
ifiny = find(qyears==finy); |
| 116 |
|
| 117 |
ibegy1 = find(qyears==begy+1); |
| 118 |
% |
| 119 |
if isempty(ibegy) & isempty(ibegy1) |
| 120 |
warning('Either ibegy or begq is out of the range of qyears') |
| 121 |
disp('Print qyears to see the range') |
| 122 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 123 |
return |
| 124 |
elseif isempty(ibegy) & (begq<qyears(1)) |
| 125 |
warning('Either ibegy or begq is out of the range of qyears') |
| 126 |
disp('Print qyears to see the range') |
| 127 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 128 |
return |
| 129 |
elseif isempty(ibegy) |
| 130 |
ibegy = -qyears(1)+2; % +2 is needed for the following -1 in |
| 131 |
% bar(Estrexa(ibegy+begq-1:ifiny+finm-1,i)) |
| 132 |
%so that it 2-1=1 so that +1 is what we want |
| 133 |
end |
| 134 |
% |
| 135 |
if isempty(ifiny) |
| 136 |
warning('Either ifiny or finq is out of the range of qyears') |
| 137 |
disp('Print qyears to see the range') |
| 138 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 139 |
return |
| 140 |
elseif (ifiny+finq-1>size(qyears,1)) |
| 141 |
warning('Either ifiny or finq is out of the range of qyears') |
| 142 |
disp('Print qyears to see the range') |
| 143 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 144 |
return |
| 145 |
end |
| 146 |
|
| 147 |
|
| 148 |
if nargout==0 |
| 149 |
t=length(yactqg(ibegy+begq-1:ifiny+finq-1,1)); |
| 150 |
for i=1:size(yactqg,2) |
| 151 |
figure |
| 152 |
plot(1:t, yactqg(ibegy+begq-1:ifiny+finq-1,i),'*:'); |
| 153 |
title('Quarter-to-quarter Growth Rate') |
| 154 |
ylabel(char(ylab(i))) |
| 155 |
xlabel([ 'From ' num2str(begy) ':' num2str(begq) ' to ' ... |
| 156 |
num2str(finy) ':' num2str(finq) ]) |
| 157 |
grid |
| 158 |
end |
| 159 |
end |
| 160 |
|
| 161 |
actual = [qyears(ibegy+begq-1:ifiny+finq-1) yactqg(ibegy+begq-1:ifiny+finq-1,:)]; |
| 162 |
end |
| 163 |
|
| 164 |
|
| 165 |
if mqyIndx(3)==1 % calendar year |
| 166 |
ibegy = find(yearsCal==begy); |
| 167 |
ifiny = find(yearsCal==finy); |
| 168 |
% |
| 169 |
if isempty(ibegy) |
| 170 |
warning('Either ibegy or begq is out of the range of yearsCal') |
| 171 |
disp('Print yearsCal to see the range') |
| 172 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 173 |
return |
| 174 |
end |
| 175 |
% |
| 176 |
if isempty(ifiny) |
| 177 |
warning('Either ifiny or finq is out of the range of yearsCal') |
| 178 |
disp('Print yearsCal to see the range') |
| 179 |
disp('Or change actuap to make the range longer and save new results to Xshock.mat') |
| 180 |
return |
| 181 |
end |
| 182 |
|
| 183 |
if nargout==0 |
| 184 |
t=length(yactCalyg(ibegy:ifiny,1)); |
| 185 |
for i=1:size(yactCalyg,2) |
| 186 |
figure |
| 187 |
plot(1:t, yactCalyg(ibegy:ifiny,i),'*:'); |
| 188 |
title('Calendar Annual Average Growth Rate') |
| 189 |
ylabel(char(ylab(i))) |
| 190 |
xlabel([ 'From 19' num2str(begy) ' to 19' ... |
| 191 |
num2str(finy) ]) |
| 192 |
grid |
| 193 |
end |
| 194 |
end |
| 195 |
|
| 196 |
actual = [yearsCal(ibegy:ifiny) yactCalyg(ibegy:ifiny,:)]; |
| 197 |
end |