
ew =6;
kappa=2;
zetaH=1.5;
beta=0.99;
thetaG=0.0;
h=0.25;

delta =0.0227;


psi=.1;

vv=1;

AG=1;

thetaW=0.5;
lamW=0.5;

phiH=.5;
phiNT=.5;

muW=1.5;

zeta=zetaH;
omega=0.65;
muY=1;

etaH =1.5;
omegaH =0.6;
thetaH =0.5;
thetaNT =thetaH ;
ita1=0.0328;
ita2=1;
eH=6;
eNT=6;
eF=6;


aH=0.289365;
xH=0;

aNT=.299365;
xNT=0;


lamH=0.5;
lamNT=0.5;
lamF=0.5; 
thetaF=thetaH;

lamG=0.5;

vR = 0.5;
vNR = 0.5;

psiD=0;

rhoK=1; 
rhoC=1; 
rhoL=1; 
rhoGC=1; 
rhoGI=1; 
rhoZ=1; 
gammaK=1; 
gammaC=1; 
gammaL=1; 
gammaGC=1; 
gammaGI=1; 
gammaZ=1;

Rstarbar = 1;
DEPS=1 ;
sDbar=1;
%zetastar=zeta;

sZbar= 0.2;
sZ=sZbar;
sGCbar = 0.2 ;
sGIbar = 0.03;
sGC = sGCbar;
sGI = sGIbar;
TAUKbar = 0.2;
TAULbar = 0.3;
TAUCbar = 0.2;
sD=0.8;

TAUK = TAUKbar ;
TAUL = TAULbar;
TAUC= TAUCbar; 


Ystar=3;
rKH = (1/beta - (1-delta))/(1-TAUKbar);
rKNT = (1/beta - (1-delta))/(1-TAUKbar);
eqh =1 ;
eqnt =1 ;
AH = 1;
ANT = 1;
epNT = 1;
epH = 1;
epF=1;
uH=1;
uNT=1;
RER=1;
pistar=1;
pi = pistar;
R = 1/beta*pi;
Rstar=R;
piH =pi ;
piNT=pi ;
piF= pi; 
qH  =1 ;
qNT =1 ;
MCH =(eH-1)/eH ;
MCNT =(eNT-1)/eNT ;
WH = (MCH/ (aH^(-aH)*(1-aH)^(aH-1)*rKH^aH   ) )^(1-aH);
WNT = (MCNT/ (aNT^(-aNT)*(1-aNT)^(aNT-1)*rKNT^aNT   ) )^(1-aNT);


KNT_LNT= (aNT/(1-aNT)*WNT/rKNT);
LNT_YNT = (KNT_LNT)^(-aNT);
KH_LH= (aH/(1-aH)*WH/rKH);
LH_YH = (KH_LH)^(-aH);

YH_Y = 0.35;
YNT_Y = 0.65;
LH_Y = LH_YH*YH_Y;
LNT_Y = LNT_YNT*YNT_Y;
KH_Y = KH_LH*YH_Y;
KNT_Y = KNT_LNT*YNT_Y;
LH_LNT = LH_Y/LNT_Y;
phiH = 1/( (LH_LNT)*(WH/WNT)^(-muW)+1 );
phiNT=1-phiH;
w=(phiH*WH^(1+muW) + phiNT*WNT^(1+muW)  )^(1/(1+muW) );   
Wstar=w;
L_Y= LNT_Y/(phiH*(WH/w)^(muW));


IH_Y = delta*KH_Y;
INT_Y =delta*KNT_Y; 
CNR_Y = ((1-TAULbar)*w*L_Y + sZ )/(1+TAUCbar);
CR_Y =( 1- (1-vR)*CNR_Y-IH_Y-INT_Y -sGC-sGI)/vR; 
CstarR_Y =CR_Y;


Y = ((ew-1)/ew * (1-TAULbar)/(1-TAUCbar) * 1/ (CstarR_Y*(1-h)) * w/(L_Y^kappa))^(1/(1+kappa));

LH=LH_Y*Y ;
LNT=LNT_Y*Y;
KH = KH_Y*Y ;
KNT= KNT_Y*Y;
L= (phiH^(1/(muW+1))*LH^(muW/(muW+1))  +  phiNT^(1/(muW+1))*LNT^(muW/(muW+1)) )^(muW/(muW+1));  %;L_Y*Y;
IH=IH_Y*Y ;
INT = INT_Y*Y ; 
CNR = CNR_Y*Y ;
CR= CR_Y*Y; 
CstarR= CstarR_Y*Y;
YH = YH_Y*Y;
YNT = YNT_Y*Y;
YGDP = YH + YNT;
TAXREV = TAUCbar* (vR*CR+vNR*CNR) + TAUKbar*(vR*rKH*uH*KH+vR*rKNT*uNT*KNT) + TAULbar * w*L;
YT = ((1-(1-omega)^(1/zeta)*(YNT/Y)^((zeta-1)/zeta)) /((omega)^(1/zeta)) )^(zeta/(zeta-1))*Y;
LAM = 1/((CstarR-h*CstarR)*(1+TAUCbar)) ;

PT_PNT = (YT/YNT*(1-omega)/omega)^(-1/zeta);

pNT = ( omega*( PT_PNT)^(1-zeta) +(1-omega))^(1/(zeta-1));
pT = (YT/YNT*(1-omega)/omega)^(-1/zeta)*( omega*( PT_PNT)^(1-zeta) +(1-omega))^(1/(zeta-1));
pF = RER;

PH_PF =  ( ((pT/RER)^(1-zetaH) -(1-omegaH) ) /omegaH )^(1/(1-zetaH));

pH = PH_PF*pF;

YHd_YF = omegaH/(1-omegaH)*(PH_PF)^(-zetaH);

YF = ( omegaH^(1/zetaH)*(YHd_YF)^((zetaH-1)/zetaH)  + (1-omegaH)^(1/zetaH) )^(-zetaH/(zetaH-1))*YT;
YHd = YHd_YF *YF;
YX = YH - YHd;

zetastar =log(YX/Ystar) / log(pF/pH);

D = sD*YGDP;

FG = (1-lamG)*D;  


F= ((FG*RER*(1/Rstar-1/pi )   + pH*YX - pF*YF) / ( RER*(1/Rstar-1/pi ) ))/vR; 


p1H = epH*MCH*(YH+YX) /(1- beta*thetaH*(piH/(piH^lamH*piH^(1-lamH))  )^eH); 
p2H = pH*(YH+YX)     /(1-  beta*thetaH*(piH/(piH^lamH*piH^(1-lamH))  )^(eH-1)); 
pHbar = 1; 

p1NT = epNT*MCNT*(YNT) /(1- beta*thetaNT*LAM/LAM*(piNT/(piNT^lamNT*piNT^(1-lamNT)))^eNT); 
p2NT = pNT*(YNT)/       (1- beta*thetaNT*LAM/LAM*(piNT/(piNT^lamNT*piNT^(1-lamNT)))^(eNT-1)); 
pNTbar = 1;%eNT/ (eNT-1) * p1NT/p2NT; 

p1F = epF*pF*(YF)/(1-  beta*thetaF*LAM/LAM*(piF/(piF^lamF*piF^(1-lamF)))^eF); 
p2F = pF*(YF)/    (1-  beta*thetaF*LAM/LAM*(piF/(piF^lamF*piF^(1-lamF)))^(eF-1)); 
pFbar = eF/ (eF-1)*p1F/p2F;


YY = ( omega^(1/zeta)*YT^((zeta-1)/zeta) + (1-omega)^(1/zeta)*YNT^((zeta-1)/zeta) )^(zeta/(zeta-1));

YYY = vR*CstarR+vNR*CNR + vR*IH + vR*INT+  sGCbar*YGDP+sGIbar*YGDP + sZ*Y +vR*(ita1*(uH-1) +ita2/2*(uH-1)^2)*uH*KH ;
+vR*(ita1*(uNT-1) +ita2/2*(uNT-1)^2)*uNT*KNT

mm = muY* (omega*(pT)^(1-zeta) +(1- omega)*(pNT)^(1-zeta) )^(1/(1-zeta))
;
kk
CstarR 
CR 
KH 
KNT  
IH 
INT 
uH 
uNT 
F 
D 
LAM 
CNR 
    LH 
    LNT
    L 
    w 
    Wstar 
    Y 
    YT 
    YHd
    YF 
    YH 
    MCH 
    pH 
    pHbar 
    WH 
    %DELH 
    YNT 
    MCNT 
    pNT 
    pNTbar 
    WNT 
    %DELNT 
    rKH 
    rKNT 
    qH  
    qNT 
    R 
    Rstar 
    pT 
    pi 
    TAXREV  
    %GI 
    %GC
    %Z 
    TAUC 
    TAUK 
    TAUL 
    %W1 
    %W2 
    p1H 
    p2H 
    p1NT 
    p2NT  
    YGDP   
    piH 
    piNT 
    piF 
    RER 
    FG 
    YX   
    sGC 
    sGI  
    sZ 
    sD