clear
close all

rhoksi  =0.9;
rhoz    =0.9;
rhog    =0.9;
rhoV    =0.9;
rhoX    =0.9;


beta   = 0.99;
theta  = 0.975;
delta  = 0.025;
hh     = 5;
alpha  = 0.6;
w2     = 1;
rc     = 0.01;
rhoc   = 0.96;
rhoR   = 0.8;
kappay = 0.5;
kappapi= 1.5;
taus   = 0.001;
taub   = 0.001;
Vk     = 50;
Vb     = 50;
e      = 0.5;
phi0   = 1;
gamma  = 2;

pis    = 0.005;
ksis   = 1;
zs     = 1;
Vs     = 1;
Xs     = 1;
qks    = 1;

rds    = 1/beta-1;
Rds    = (1+rds)*(1+pis);
phis   = 5;
phiks  = 0.1;
phibs  = 0.2;

TAU    = ((1+rds)^4-1)*0.01;
rks    = rds + TAU;
lam     = fsolve(@(lam) ((1/phis +TAU/(1+rds))*(1+rds)*beta*(1-theta+theta*lam*phis)-lam),0);

omegas  = beta*((1-theta)+theta*lam*phis);
nuks    = omegas*TAU;
rhos    = omegas*(1+rds);
rbs     = (1-e)*TAU;
qbs     = rc/(1+rbs-rhoc);
k_y     = alpha/(rks+delta);
b_y     = 5/qbs;
g_y     = 0.2;
sgks_y   = phiks*k_y;
sgbs_y   = phibs*b_y;
c_y     = 1-delta*k_y -g_y-taus*qks*sgks_y-taub*qbs*sgbs_y;
ws      = fsolve(@(ws) ((rks+delta)^alpha*ws^(1-alpha)/(alpha^alpha *(1-alpha)^(1-alpha)*zs)-1),0);
l_y     = (1-alpha)/ws;
ys      = ((1-alpha)*l_y^(-1)*c_y^(-gamma)/(w2*Xs*l_y^phi0))^(1/(phi0+gamma));
ks      = k_y*ys;
ls      = l_y*ys;
cs      = c_y*ys;
bs      =b_y*ys;
gs      =g_y*ys;
sgks    = sgks_y*ys;
sgbs    = sgbs_y*ys;
spks    = ks-sgks;
spbs    = bs-sgbs;
ns      = (qks*spks+(1-e)*qbs*spbs)/phis;
chi     = fsolve(@(chi) (theta*(TAU*qks*spks+(rbs-rds)*qbs*spbs)+(theta*(1+rds)+chi)*ns-ns),0);
Lams    = Vs*cs^(-gamma);
Taus    = gs+rbs*qbs*bs-(TAU-taus)*qks*sgks-(rbs-rds-taub)*qbs*sgbs;
sgks    = phiks*ks;
sgbs    = phibs*bs;
is      = delta*ks;
sks     = ks;
sbs     = bs;
nubs     = (1-e)*nuks;


save QE
dynare effectivenessQE

















