clear datab.mat;
clear all; 
load DATAb.txt;
load datai.txt;
% name = ['  y  ';'  c  ';' hc  ';' gc  ';'  i  ';' imp ';' ex ';'  l  ';'  w  ';' yea ';'impea';' iea ';' cea ';' gcea';' hc  ';'exea';' wea ';' lea ';' CPI ';'CPIea'];
ny = DATAb(:,1);
nc= DATAb(:,2);
nhc= DATAb(:,3);
ngovc= DATAb(:,4);
ni= DATAb(:,5);
nimp= DATAb(:,6);
nex= DATAb(:,7);
l= DATAb(:,8);
nw= DATAb(:,9);
nyea= DATAb(:,10);
nimpea= DATAb(:,11);
niea= DATAb(:,12);
ncea= DATAb(:,13);
ngovcea= DATAb(:,14);
nhcea= DATAb(:,15);
nexea= DATAb(:,16);
nwea= DATAb(:,17);
lea= DATAb(:,18);
nCPI= DATAb(:,19);
nCPIea= DATAb(:,20);
nr = datai(2:end);   

r = log(1+nr/400);
CPI = nCPI;
CPIea = nCPIea;

y=ny./nCPI;
c=nc./nCPI;
hc=nhc./nCPI;
govc=ngovc./nCPI;
i=ni./nCPI;
imp=nimp./nCPI;
ex=nex./nCPI;
w=nw./nCPI;

yea=nyea./nCPIea;
cea=ncea./nCPIea;
hcea=nhcea./nCPIea;
govcea=ngovcea./nCPIea;
iea=niea./nCPI;
impea=nimpea./nCPI;
exea=nexea./nCPI;
wea=nwea./nCPI;

ly = log(y);
gy = ly(2:end) - ly(1:end-1);
lc = log(c);
gc = lc(2:end) - lc(1:end-1);
lhc = log(hc);
ghc = lhc(2:end) - lhc(1:end-1);
lgc = log(govc);
ggc = lgc(2:end) - lgc(1:end-1);
li = log(i);
gi = li(2:end) - li(1:end-1);
limp = log(imp);
gimp = limp(2:end) - limp(1:end-1);
lex = log(ex);
gex = lex(2:end) - lex(1:end-1);
ll = log(l);
gl = ll(2:end) - ll(1:end-1);
lw = log(w);
gw = lw(2:end) - lw(1:end-1);

lyea = log(yea);
gyea = lyea(2:end) - lyea(1:end-1);
lcea = log(cea);
gcea = lcea(2:end) - lcea(1:end-1);
lhcea = log(hcea);
ghcea = lhcea(2:end) - lhcea(1:end-1);
lgcea = log(govcea);
ggcea = lgcea(2:end) - lgcea(1:end-1);
liea = log(iea);
giea = liea(2:end) - liea(1:end-1);
limpea = log(impea);
gimpea = limpea(2:end) - limpea(1:end-1);
lexea = log(exea);
gexea = lexea(2:end) - lexea(1:end-1);
llea = log(lea);
glea = llea(2:end) - llea(1:end-1);
lwea = log(wea);
gwea = lwea(2:end) - lwea(1:end-1);
lCPI = log(CPI);
gcpi = lCPI(2:end) - lCPI(1:end-1);
lCPIea = log(CPIea);
gcpiea = lCPIea(2:end) - lCPIea(1:end-1);


D = [gy gc ghc ggc gi gimp gex gl  gw  gyea gcea ghcea  ggcea  giea  gimpea  gexea  glea  gwea gcpi gcpiea r];
plot(D);
maxi = max(D);mini = min(D);
stdvar = std(D); 
save  datac.mat  gy gc gcpi gcpiea ghc ggc gi gimp gex gl  gw  gyea gcea ghcea  ggcea  giea  gimpea  gexea  glea  gwea r;

G_Y         = gy;
G_Y_star    = gyea;
PI          = gcpi;
PIf         = gcpiea;
G_C         = gc;
G_I         = gi;
G_L         = gl; 
PIw         = gw;
G_C_star  =  gcea;
G_I_star  =  giea;
G_L_star  = glea; 
PIw_star  =  gwea ;
R           = r;

save  datad.mat  G_Y G_Y_star PI PIf G_C G_I G_L PIw G_C_star G_I_star G_L_star PIw_star R;

save  datae.mat  G_Y G_Y_star PI PIf G_C G_I G_L PIw G_C_star G_I_star G_L_star PIw_star R  gy gc gcpi gcpiea ghc ggc gi gimp gex gl  gw  gyea gcea ghcea  ggcea  giea  gimpea  gexea  glea  gwea r;