%ROW    Calculate rest of world GDP and population
%       using data from GGDC for
%
%              Technology Capital and the Current Account
%              by Ellen McGrattan and Edward Prescott
%
%       See ./ggdc/FDIrelevantNAMES.pdf

%       Ellen McGrattan, 3-1-08


%
% Load in GDPs and Populations, 1950-2007
%

load ./ggdc/FDIrelevantGDP.csv
load ./ggdc/FDIrelevantPOP.csv

[T,N]     = size(FDIrelevantGDP);
t         = FDIrelevantGDP(:,1);
gdp       = FDIrelevantGDP(:,2:N);
pop       = FDIrelevantPOP(:,2:N);
N         = N-1;

%
% For Germany, use "All Germany" for 1989 and later
% and combine West and East prior to 1989.
%
i         = 1:39;
gdp(i,7)  = gdp(i,8)+gdp(i,30);
gdpus     = gdp(:,24);
gdprow    = sum(gdp(:,[1:7,9:23,25:29,31:N])')';
pop(i,7)  = pop(i,8)+pop(i,30);
popus     = pop(:,24);
poprow    = sum(pop(:,[1:7,9:23,25:29,31:N])')';

usrowpop  = [t,popus,poprow,popus./(popus+poprow)];
usrowgdp  = [t,gdpus,gdprow,gdpus./(gdpus+gdprow)*100];

save dusrowpop.dat usrowpop -ascii
save dusrowgdp.dat usrowgdp -ascii
