clear all
close all

eta = 0.89;
beta = 0.99;
alpha =1/3;
delta = 0.025;
b = 0.65;
tau = 2;
phi = 1;
omegags = 0.2;


phiw =0.75;
phip=0.75;
phipi = 1.5;
phiy = 0.5;
chi1 = 1/beta - (1-delta);
chi2 = 0.01;

rhog = 0.9;
rhoak =0.9;
rhoal =0.9;
rhomw =0.9;
rhomp =0.9;
rhoi =0.9;
rhoz =0.9;
sdg =0.01;
sdak =0.01;
sdal =0.01;
sdmw =0.01;
sdmp =0.01;
sdi =0.0;
sdz =0.01;


dps = 1;
us  =1;
zs =1;
Als = 1;
Aks = 1;
mws = 1.5;
mps = 1.5;
pis = 1; %zeros inflation steady state
pistars =1;
is = pis/beta; %nominal interest rate



%xs means the steady state value of x;
Rks= 1/beta - (1-delta); %capital rate
mcs= 1/mps;
ws= Als*(1-alpha)^(eta/(eta-1))/(mcs^(1-eta)-alpha^(eta)*(Aks/Rks)^(eta-1))^(1/(eta-1));
kn= ((Aks/Als)^((eta-1)/eta)*alpha*ws/(1-alpha)/Rks)^eta;
yn= ((1-alpha)*Als^((eta-1)/eta)+alpha*Aks^((eta-1)/eta)*kn^((eta-1)/eta))^(eta/(eta-1));
yk= ((1-alpha)*Als^((eta-1)/eta)*kn^((1-eta)/eta)+alpha*Aks^((eta-1)/eta))^(eta/(eta-1));
iy = delta/yk;
cy = 1 - iy -omegags;
Ns = 1/3;
c1 = (1-beta*b)/(1-b); %simplifying parameter
Ks = kn*Ns;
Ys = Ks*yk;
invs = delta*Ks;
Gs = Ys*omegags;
Cs = Ys - invs - Gs;
psi = ws/mws/Cs/Ns^phi*c1;

Kbars = Ks;
lams = c1/Cs;
mus = lams;
qs = mus/lams;
wstars = ws;
x1s = lams*mcs*Ys/(1-phip*beta);
x2s = lams*Ys/(1-phip*beta);
h1s = psi*Ns^(1+phi)/(1-phiw*beta);
h2s = lams*Ns/(1-phiw*beta);

%save all the variables into mat file and then load in mod file
save mediumdsge;

%run the dynare mod file or the compiled mod m file
dynare mediumdsge