%
% GROUTPUT  load quarterly data for real gross output computed in mleinputs
%    


load fillqtr1.out   % Y2 from mleinputs.m
load logago.dat     % log(AGO0*100) from mleinputs.m
load tlogago.dat    % HP trend of log(AGO0*100) from mleinputs.m

gy          = zeros(268,22);
lgy         = zeros(268,22);
for i=1:22;
  ii        = (i-1)*268+1:i*268;
  Y2        = fillqtr1((i-1)*268+1:i*268,2:4);
  qtrend    = ann2qtr([[1948:2014]',tlogago(:,i)],4,1);
  qtrend    = qtrend(:,2);
  qgopred   = exp(Y2(:,3)+qtrend);
  gy(:,i)   = qgopred;
  lgy(:,i)  = log(qgopred./1.0079.^[-267:0]');
  dlgy(:,i) = lgy(:,i)-mean(lgy(249:268,i));
end;
t           = ptime(1948.1,268,4);

%
% Use available quarterly data
%
gyhld       = gy;
load ./rawdata/NIPA/NIPA/table1_1_9Q.dat
load ./rawdata/Industry/Qtrly/GO05to15Q.dat
load ./rawdata/Industry/Qtrly/GO12to15Qdetail.dat
qgo05       = GO05to15Q([3:7,10:14,17,21,24,27,28,1],1:40)./ ...
              (ones(16,1)*table1_1_9Q(3,145:184)/100);
qgo12       = GO12to15Qdetail([32,52,19,21],1:12)./ ...
              (ones(4,1)*table1_1_9Q(3,173:184)/100);
for i=1:15;
  gy(:,i)   = [gy(1:229,i)/gy(229,i)*qgo05(i,1);qgo05(i,2:40)'];
end;
gy(:,22)    = [gy(1:229,22)/gy(229,22)*qgo05(16,1);qgo05(16,2:40)'];
gy(:,16)    = [gy(1:257,16)/gy(257,16)*qgo12(1,1);qgo12(1,2:12)'];
gy(:,17)    = [gy(1:257,17)/gy(257,17)*qgo12(2,1);qgo12(2,2:12)'];
gy(:,20)    = [gy(1:257,20)/gy(257,20)*qgo12(3,1);qgo12(3,2:12)'];
gy(:,21)    = [gy(1:257,21)/gy(257,21)*qgo12(4,1);qgo12(4,2:12)'];

% In per capita terms:
%
load ./rawdata/NIPA/NIPAhist/table2_1Q.dat
popq          = table2_1Q(42,1:88);
load ./rawdata/NIPA/NIPA/table2_1Q.dat
popq          = [popq,table2_1Q(42,1:184)]';
for i=1:22;
  gypc(:,i)   = 10^9*gy(:,i)./(popq(5:272)*1000);
  dgypc(:,i)  = gypc(:,i)./1.005.^[-267:0]';
  ldgypc(:,i) = log(dgypc(:,i)/mean(dgypc(209:268,i)));
end;

%save ldgypc.dat ldgypc -ascii

