
[lData, codeData,tc] = ReadDataNews_levels_long_luca;

fa = 100;
gsave = xlsread('gsave.xlsx');
lData(:,15) = fa*log(gsave(1:end-1));

lData(:,7) = fa*log(exp(lData(:,7)/fa)+exp(lData(:,13)/fa)); % inv
lData(:,11) = fa*log(exp(lData(:,12)/fa)+exp(lData(:,14)/fa));% cons

% prices in growth rates
pd = [32 34 35 36 37 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85];
%pd = [34 35 36 37 75 76 77 78 79 80 81 82 83 84 85];
temp2 = diff(lData(:,pd));
%temp2 = (exp(Data(2:end,pd))-exp(Data(1:end-1,pd)))./exp(Data(1:end-1,pd));
lData = lData(2:end,:);
lData(:,pd) = temp2;

lData = lData(4:end,:);

lData(:,[102 103 106:109]) = cumsum(lData(:,[102 103 106:109]))/4;

pop = xlsread('population.xls');
%pop_d = [1:19 21:22 27 98:101 104 105];
pop_d = [1:19 21:22 27 104 105];% as mario
%pop_d = [1:15  27];
lData(:,pop_d) = fa*log(exp(lData(:,pop_d)/fa)./kron(pop(1:size(lData,1),1),ones(1,length(pop_d))));

%[19 64 65 66 92 95 96 97 100]
a = ones(1,size(lData,2));a([19 64 65 66 92 95 96 97 100]) = 0;[b I] = find(a);
lData = lData(:,I);

% [PC IPC] = baingcriterion(standardize(center(diff(Data))),20);
% [a,rhat] = min(IPC(:,2));disp(rhat)
% qq = baingdftest(standardize(center(diff(Data))),rhat,2)
% rhat = 8;
% q = 6;
maxnpc = 10;
[pc,b,c,Chi] = principalcomponents(center(standardize(lData)),maxnpc);

