beta=0.95;
sigma=2;
delta=0.025;
phi=1;
tc=0.2;
th=0.15;
ga1=0.15;
ga2=0.1;
ksi1=1;
alpha1=0.5;
alpha2=0.33;
eta1=0.05;
eta2=0.1;
gammad=0.35;
gammam=9;
s=0.8;
kappal=0.9;
cg=0.5;
%%
y=1;%xxx
tp=0.25;%xxx
y1=0.53;%xxx
M=2.2*y;%xxx
%%
rD=1/beta-1;%3
y2=y-y1;%28
h1=2*y1/3;%xxx
h2=y2*0.55;%xxx
rk1=(1/beta+delta-1)/(1-eta1);%23
rk2=(1/beta+delta-1)/(1-eta2);%24
k1=alpha1*y1*(1-tp)*(1-ga1)/(delta*(1-tp)*(1-ga1)+rk1);%14
k2=alpha2*y2*(1-tp)*(1-ga2)/(delta*(1-tp)*(1-ga2)+rk2);%19
syms  kg  ksi2 
eq1=y1==(kg^ksi1)*(k1^alpha1)*(h1^(1-alpha1));%10
eq2=y2==(kg^ksi2)*(k2^alpha2)*(h2^(1-alpha2));%15
solve([eq1 eq2],[ksi2 kg])
ksi2=double(ans.ksi2);
kg=double(ans.kg);
clear ans;
w1=(1-alpha1)*y1/h1;%13
w2=(1-alpha2)*y2/h2;%18
c1=(w1*(1-th)/(kappal*h1^phi*(1+tc)))^(1/sigma);%1
c2=(w2*(1-th)/(kappal*h2^phi*(1+tc)))^(1/sigma);%4
pai1=(1-eta1)*(y1-w1*h1-delta*k1)*(1-tp)*(1-ga1);%11
pai2=(1-eta2)*(y2-w2*h2-delta*k2)*(1-tp)*(1-ga2);%16
bpai1=pai1-(1-eta1)*rk1*k1;%12
bpai2=pai2-(1-eta2)*rk2*k2;%17
B1=ga1/(1-ga1)*pai1;%6
B2=ga2/(1-ga2)*pai2;%7
D1=((1+tc)*c1-w1*h1*(1-th)-B1*(1-th))/rD;%2
D2=((1+tc)*c2-w2*h2*(1-th)-B2*(1-th))/rD;%5
Ww1=c1*(1+tc)+D1;%8
Ww2=c2*(1+tc)+D2;%9
I1=delta*k1;%21
I2=delta*k2;%22
Ig=delta*kg;%29
rg=rD;%XXX
syms ck Dk D Bond
eq3=(1+tc)*ck+I1+I2+Dk==(1-eta1)*rk1*k1+(1-eta2)*rk2*k2+(1+rD)*Dk;%20
eq4=D==D1+D2+Dk;%25
eq5=Bond==gammad*D;%26
eq6=cg+Ig+(1+rg)+Bond==(w1*h1+w2*h2+B1+B2)*th+(c1+c2+ck)*tc+(pai1+pai2)*(tp/(1-tp))+s*pai1+Bond;%27
solve([eq3 eq4 eq5 eq6],[ck Dk D Bond])
ck=double(ans.ck);
Dk=double(ans.Dk);
D=double(ans.D);
Bond=double(ans.Bond);
%%
rgss=rg;
rDss=rD;
Igss=Ig;
tpss=tp;
betag=0.44;
rhog=0.5;
rhot=0.5;
save kgtm beta sigma delta phi tc th ga1 ga2 ksi1 ksi2 alpha1 alpha2 eta1 eta2 gammad gammam s kappal cg rgss rDss Igss tpss betag rhog rhot
dynare kgsss







