%SETUPDATA    Set up data file for maximum likelihood estimation
%             Store matrix `mled' in mxzvarq.dat.

%             Ellen McGrattan, 1-1-05

load ../data/oecd/oecd_q_mx.dat
load ../data/ilo/emp_a_mx.dat
load ../data/pwt/pwt_mx.dat
load ../data/wdi/wdi_mx.dat

T            = 1:176;
RGDP_mx_q    = oecd_q_mx(16,T)';           % Billions 1993 pesos
RC_mx_q      = oecd_q_mx(18,T)';           % Billions 1993 pesos
RGC_mx_q     = oecd_q_mx(19,T)';           % Billions 1993 pesos
RIF_mx_q     = oecd_q_mx(20,T)';           % Billions 1993 pesos
RII_mx_q     = oecd_q_mx(21,T)';           % Billions 1993 pesos
REX_mx_q     = oecd_q_mx(22,T)';           % Billions 1993 pesos
RIM_mx_q     = oecd_q_mx(23,T)';           % Billions 1993 pesos
GDP_mx_q     = oecd_q_mx(16,T)';           % Billions pesos
HRSmfg_mx_q  = oecd_q_mx(3,T)';
EMPmfg_mx_q  = oecd_q_mx(2,T)';
EMP_mx_a     = pwt_mx(11:51,3)./pwt_mx(11:51,5).*pwt_mx(11:51,2)*1000;
EMP_mx_a     = [EMP_mx_a;
                EMP_mx_a(41)*emp_a_mx(2,33)/emp_a_mx(2,32);
                EMP_mx_a(41)*emp_a_mx(2,34)/emp_a_mx(2,32);
                EMP_mx_a(41)*emp_a_mx(2,35)/emp_a_mx(2,32)];
EMP_mx_q     = interp0(EMP_mx_a,4);
POP1564_mx_q = interp0(wdi_mx(23,:)',4);
t            = ptime(1960.1,176,4);
q2000        = 161:164;

Y_mx_q       = RGDP_mx_q./POP1564_mx_q;
RG_mx_q      = RGC_mx_q+REX_mx_q-RIM_mx_q;
RNX_mx_q     = REX_mx_q-RIM_mx_q;
G_mx_q       = RG_mx_q./POP1564_mx_q;
G_mx_q       = G_mx_q  * mean(GDP_mx_q(q2000))/mean(Y_mx_q(q2000));
NX_mx_q      = RNX_mx_q./POP1564_mx_q;
NX_mx_q      = NX_mx_q  * mean(GDP_mx_q(q2000))/mean(Y_mx_q(q2000));
C_mx_q       = RC_mx_q./POP1564_mx_q;
C_mx_q       = C_mx_q  * mean(GDP_mx_q(q2000))/mean(Y_mx_q(q2000));
RI_mx_q      = RIF_mx_q+RII_mx_q;
I_mx_q       = RI_mx_q./POP1564_mx_q;
I_mx_q       = I_mx_q  * mean(GDP_mx_q(q2000))/mean(Y_mx_q(q2000));
Y_mx_q       = Y_mx_q  * mean(GDP_mx_q(q2000))/mean(Y_mx_q(q2000));
L_mx_q       = (EMP_mx_q./POP1564_mx_q).* (HRSmfg_mx_q./EMPmfg_mx_q)*.4;

t            = t(81:176);
Y_mx_q       = Y_mx_q(81:176);
I_mx_q       = I_mx_q(81:176);
L_mx_q       = L_mx_q(81:176);
G_mx_q       = G_mx_q(81:176);
NX_mx_q      = NX_mx_q(81:176);
adjY_mx_q    = seasadj(Y_mx_q,4);
adjI_mx_q    = seasadj(I_mx_q,4);
adjL_mx_q    = seasadj(L_mx_q,4);
adjG_mx_q    = seasadj(G_mx_q,4);
gz           = (1.00^(1/4))^60;
mled         = [t,adjY_mx_q/adjY_mx_q(60)*gz,adjI_mx_q/adjY_mx_q(60)*gz, ...
                  adjL_mx_q,adjG_mx_q/adjY_mx_q(60)*gz];
