%Code to calculate initial ss values for IRBC.mod
clear all
close all
clc

%
% Call data
%

data = csvread('AGG_ASIA_LATAM_ROW.csv',1,0);

%
% Organize data
%

year      = data(:,1);

Y_ROW     = data(:,2);
C_ROW     = data(:,3);
I_ROW     = data(:,4);
G_ROW     = data(:,5);
M_ROW     = data(:,6);
X_ROW     = data(:,7);
%NX_ROW    = data(:,8);
H_ROW     = data(:,9);
E_ROW     = data(:,10);
K1_ROW    = data(:,11);
POP_ROW   = data(:,16);
K3_ROW    = data(:,12);
K4_ROW    = data(:,13);
K0_N_ROW  = data(:,14);
K0_E_ROW  = data(:,15);
%NX_Y_ROW  = data(:,49);


Y_LATAM   = data(:,17);
C_LATAM   = data(:,18);
I_LATAM   = data(:,19);
G_LATAM   = data(:,20);
M_LATAM   = data(:,21);
X_LATAM   = data(:,22);
NX_LATAM  = data(:,23);
H_LATAM   = data(:,24);
E_LATAM   = data(:,25);
K1_LATAM  = data(:,26);
POP_LATAM = data(:,31);
K3_LATAM  = data(:,27);
K4_LATAM  = data(:,28);
K0_N_LATAM= data(:,29);
K0_E_LATAM= data(:,30);
NX_Y_LATAM= data(:,48);

Y_ASIA    = data(:,32);
C_ASIA    = data(:,33);
I_ASIA    = data(:,34);
G_ASIA    = data(:,35);
M_ASIA    = data(:,36);
X_ASIA    = data(:,37);
NX_ASIA   = data(:,38);
H_ASIA    = data(:,39);
E_ASIA    = data(:,40);
K1_ASIA   = data(:,41);
POP_ASIA  = data(:,46);
K3_ASIA   = data(:,42);
K4_ASIA   = data(:,43);
K0_N_ASIA = data(:,44);
K0_E_ASIA = data(:,45);
NX_Y_ASIA = data(:,47);

%
% Recalculate NX of ROW
%

NX_ROW   = -NX_LATAM - NX_ASIA;
NX_Y_ROW = NX_ROW./Y_ROW;

dlogY1 = [0;log(Y_ROW(2:55))     - log(Y_ROW(1:54))];  
dlogY2 = [0;log(Y_LATAM(2:55))   - log(Y_LATAM(1:54))]; 
dlogY3 = [0;log(Y_ASIA(2:55))    - log(Y_ASIA(1:54))]; 
dlogC1 = [0;log(C_ROW(2:55))     - log(C_ROW(1:54))]; 
dlogC2 = [0;log(C_LATAM(2:55))   - log(C_LATAM(1:54))];
dlogC3 = [0;log(C_ASIA(2:55))    - log(C_ASIA(1:54))]; 
Hours1 = log((1000/8760)*H_ROW);
Hours2 = log((1000/8760)*H_LATAM); 
Hours3 = log((1000/8760)*H_ASIA); 
dlogI1 = [0;log(I_ROW(2:55))     - log(I_ROW(1:54))]; 
dlogI2 = [0;log(I_LATAM(2:55))   - log(I_LATAM(1:54))]; 
dlogI3 = [0;log(I_ASIA(2:55))    - log(I_ASIA(1:54))]; 
dlogN1 = [0;log(POP_ROW(2:55))   - log(POP_ROW(1:54)) + 1]; 
dlogN2 = [0;log(POP_LATAM(2:55)) - log(POP_LATAM(1:54))];  
dlogN3 = [0;log(POP_ASIA(2:55))  - log(POP_ASIA(1:54))]; 
NX1    = log(NX_Y_ROW);
NX2    = log(NX_Y_LATAM); 
NX3    = log(NX_Y_ASIA);

clear data year Y_ROW C_ROW I_ROW G_ROW M_ROW X_ROW H_ROW E_ROW K1_ROW POP_ROW K3_ROW K4_ROW K0_N_ROW K0_E_ROW Y_LATAM C_LATAM I_LATAM G_LATAM M_LATAM X_LATAM NX_LATAM ...
      H_LATAM E_LATAM K1_LATAM POP_LATAM K3_LATAM K4_LATAM K0_N_LATAM K0_E_LATAM NX_Y_LATAM Y_ASIA C_ASIA I_ASIA G_ASIA M_ASIA X_ASIA NX_ASIA H_ASIA E_ASIA...    
      K1_ASIA POP_ASIA K3_ASIA K4_ASIA K0_N_ASIA K0_E_ASIA NX_Y_ASIA NX_ROW NX_Y_ROW
  
  
  
  