%Japan BCA
var y c l x k gov z taul taux;
varexo ez el ex eg;

parameters pai beta theta delta sai G sigma zbar tlbar txbar gbar rhozz rholl rhoxx rhogg rhozl rhozx rhozg rholz rholg rholx rhoxz rhoxl rhoxg rhogz rhogl rhogx;

global ybar cbar xbar lbar kbar zbar tlbar txbar gbar theta delta G sigma beta sai P Sigma_e_

theta=0.388341593;
gamma=0.003549337;
nbar=0.001925381;
delta=0.022152134;
G=(1+gamma)*(1+nbar);
lbar=0.252755944;
zbar=1;
sigma=1;

yok=0.104082217;
coy=0.533891906;
xok=G-(1-delta);
xoy=xok/yok;
goy=1-coy-xoy;

kbar=yok^(1/(theta-1))*lbar;
ybar=yok*kbar;
cbar=coy*ybar;
xbar=xok*kbar;
gbar=goy*ybar;
pai=kbar/xbar;

tlbar=1;
txbar=1;
sai1=(1-theta)*(1-lbar)/(coy*lbar)/tlbar;
sai=1/(1+sai1);
beta=G/(theta*yok+1-delta);

model;
c^(sai*(1-sigma)-1)*(1-l)^((1-sai)*(1-sigma))*(taux*G+pai*G^2*(k/k(-1)-1))=beta*c(+1)^(sai*(1-sigma)-1)*(1-l(+1))^((1-sai)*(1-sigma))*(theta*y(+1)/k+(1-delta)*taux(+1)+pai*G^2*(k(+1)/k-1)*k(+1)/k-pai/2*G^2*(k(+1)/k-1)^2);
(1-sai)/sai*c/(1-l)=(1-theta)*y/l/taul;
y=c+x+gov+(pai/2*G^2*(k/k(-1)-1)^2*k(-1));
y=z*k(-1)^theta*l^(1-theta);
x=G*k-(1-delta)*k(-1);
log(z)=rhozz*log(z(-1))+rhozl*log(taul(-1))+rhozx*log(taux(-1))+rhozg*log(gov(-1))+(1-rhozz)*log(zbar)-rhozl*log(tlbar)-rhozx*log(txbar)-rhozg*log(gbar)+ez;
log(taul)=rholz*log(z(-1))+rholl*log(taul(-1))+rholx*log(taux(-1))+rholg*log(gov(-1))-rholz*log(zbar)+(1-rholl)*log(tlbar)-rholx*log(txbar)-rholg*log(gbar)+el;
log(taux)=rhoxz*log(z(-1))+rhoxl*log(taul(-1))+rhoxx*log(taux(-1))+rhoxg*log(gov(-1))-rhoxz*log(zbar)-rhoxl*log(tlbar)+(1-rhoxx)*log(txbar)-rhoxg*log(gbar)+ex;
log(gov)=rhogz*log(z(-1))+rhogl*log(taul(-1))+rhogx*log(taux(-1))+rhogg*log(gov(-1))-rhogz*log(zbar)-rhogl*log(tlbar)-rhogx*log(txbar)+(1-rhogg)*log(gbar)+eg;
end;

initval;
y=ybar;
c=cbar;
x=xbar;
l=lbar;
k=kbar;
gov=gbar;
z=zbar;
taul=1;
taux=1;

eg=0;
el=0;
ex=0;
ez=0;
end;

estimated_params;
rhozz,beta_pdf,0.8,0.2;
rholl,beta_pdf,0.8,0.2;
rhoxx,beta_pdf,0.8,0.2;
rhogg,beta_pdf,0.8,0.2;
rhozl,normal_pdf,0,0.2;
rhozx,normal_pdf,0,0.2;
rhozg,normal_pdf,0,0.2;
rholz,normal_pdf,0,0.2;
rholx,normal_pdf,0,0.2;
rholg,normal_pdf,0,0.2;
rhoxz,normal_pdf,0,0.2;
rhoxl,normal_pdf,0,0.2;
rhoxg,normal_pdf,0,0.2;
rhogz,normal_pdf,0,0.2;
rhogl,normal_pdf,0,0.2;
rhogx,normal_pdf,0,0.2;
stderr ez,inv_gamma_pdf, 0.05,inf;
stderr el,inv_gamma_pdf, 0.05,inf;
stderr ex,inv_gamma_pdf, 0.05,inf;
stderr eg,inv_gamma_pdf, 0.05,inf;
corr ez,el, normal_pdf, 0,0.2;
corr ez,ex, normal_pdf, 0,0.2;
corr ez,eg, normal_pdf, 0,0.2;
corr el,ex, normal_pdf, 0,0.2;
corr el,eg, normal_pdf, 0,0.2;
corr ex,eg, normal_pdf, 0,0.2;
end;

varobs y c x l;

estimation(datafile=data_bcajp, order=1,mh_replic=0);

close all
