var Ni C wi Nj wj rK RD pi m K I di Yi Ai Ki mci piistar piii xi1 xi2 pii dj Yj Aj Kj mcj pijstar pijj xj1 xj2 pij Y gm;
varexo ei ej em;
parameters etai sigma etaj beta delta alpha theta varepsilon k phi rhom rhoi rhoj;
parameters dis djs pis piistars piiis piis pijstars pijjs pijs Ais Ajs rKs RDs mcis mcjs gms wjs wis Kis Kjs Nis Njs Cs Yis Yjs Ks Is Ys xi1s xi2s xj1s xj2s ms;
etai = 1;
sigma = 2;
etaj= 1.803228369;
beta = 0.99;
delta = 0.025;
alpha = 1/3;
theta = 0.75;
varepsilon = 10;
k = 0.8;
phi = 2;
rhom = 0.5;
rhoi = 0.9583;
rhoj = 0.7348;
dis =1;
djs =1;
pis =1;
piistars = 1;
piiis =1;
piis =1;
pijstars =1;
pijjs =1;
pijs =1;
Ais = 1;
Ajs = 0.5;
rKs = 1/beta-1+delta;
RDs = pis/beta;
mcis = (varepsilon-1)/varepsilon;
mcjs = (varepsilon-1)/varepsilon;
gms = 0;
wjs = Ajs*(Ajs*mcjs*alpha/rKs)^(alpha/(1-alpha))*mcjs*(1-alpha) ;
wis = Ais*(Ais*mcis*alpha/rKs)^(alpha/(1-alpha))*mcis*(1-alpha);
Kis = (wis*(Ais*alpha*mcis/rKs)^(1/(1-alpha))/(Ais/k/(Ais*alpha*mcis/rKs)-delta/k)^sigma)^(1/(sigma+1));
Kjs = Kis/k*(1-k);
Nis = Kis/(Ais*alpha*mcis/rKs)^(1/(1-alpha));
Njs = wis*Nis*(1-k)/wjs/k;
Cs = (wis/Nis)^(1/sigma);
Yis = Ais*Kis^alpha*Nis^(1-alpha);
Yjs = Ajs*Kjs^alpha*Njs^(1-alpha);
Ks = Kis+Kjs;
Is = delta*Ks;
Ys = Is+Cs;
xi1s = Cs^(-sigma)*mcis*Yis/(1-beta*theta);
xi2s = Cs^(-sigma)*Yis/(1-beta*theta);
xj1s = Cs^(-sigma)*mcjs*Yjs/(1-beta*theta);
xj2s = Cs^(-sigma)*Yjs/(1-beta*theta);
ms = Cs^sigma/(1-1/RDs);
model;
%家庭
%(1) 新兴产业劳动供给
Ni^(etai) = C^(-sigma)*wi;
%(2) 传统产业劳动供给
Nj^(etaj) = C^(-sigma)*wj;
%(3) 资本存量一阶条件
beta*(rK+1-delta) = (C/C(-1))^sigma;
%(4) 债券的一阶条件
beta*RD/pi(+1)*C(+1)^(-sigma)=C^(-sigma);
%(5) 货币需求方程
m^(-1)=C^(-sigma)*(1-1/RD);
%(6) 资本积累
K = (1-delta)*K(-1)+I;
% 中间品厂商i
%(7) 中间品厂商新兴产业生产函数
di*Yi = Ai*(Ki)^(alpha)*Ni^(1-alpha);
%(8) 边际成本方程
rK=mci*alpha*Yi/Ki;
%(9) 资本收益方程
wi=mci*(1-alpha)*Yi/Ni;
%(10) 价格离散核递归方程
di=(1-theta)*(piistar)^(-varepsilon)*piii^(varepsilon)+theta*(piii)^(varepsilon)*di(-1);
%(11) CPI通胀递归方程
piii^(1-varepsilon)=(1-theta)*(piistar)^(1-varepsilon)+theta;
%(12) 最优价格方程
piistar=varepsilon/(varepsilon-1)*piii*xi1/xi2;
%(13) 最优价格辅助方程
xi1=C^(-sigma)*mci*Yi+beta*theta*xi1(+1)*(piii(+1))^(varepsilon);
%(14) 最优价格辅助方程
xi2=C^(-sigma)*pii/pi*Yi+beta*theta*xi2(+1)*(piii(+1))^(varepsilon-1);
% 中间品厂商j
%(15) 中间品厂商传统产业生产函数
dj*Yj = Aj*(Kj)^(alpha)*Nj^(1-alpha);
%(16) 边际成本方程
rK=mcj*alpha*Yj/Kj;
%(17) 资本收益方程
wj=mcj*(1-alpha)*Yj/Nj;
%(18) 价格离散核递归方程
dj=(1-theta)*(pijstar)^(-varepsilon)*pijj^(varepsilon)+theta*(pijj)^(varepsilon)*dj(-1);
%(19) CPI通胀递归方程
pijj^(1-varepsilon)=(1-theta)*(pijstar)^(1-varepsilon)+theta;
%(20) 最优价格方程
pijstar=varepsilon/(varepsilon-1)*pijj*xj1/xj2;
%(21) 最优价格辅助方程
xj1=C^(-sigma)*mcj*Yj+beta*theta*xj1(+1)*(pijj(+1))^(varepsilon);
%(22) 最优价格辅助方程
xj2=C^(-sigma)*pij/pi*Yj+beta*theta*xj2(+1)*(pijj(+1))^(varepsilon-1);
%最终品厂商部门
%(23) 生产函数
Y = (k^(1/phi)*Yi^((phi-1)/phi)+(1-k)^(1/phi)*Yj^((phi-1)/phi))^(phi/(phi-1));
%(24) 新兴行业生产量
Yi = k*Y*(pi/pii)^phi;
%(25) 传统行业生产量
Yj = (1-k)*Y*(pi/pij)^phi;
%央行部门
%(26) 传统行业生产量
gm = -log(pi)+rhom*gm(-1)+rhom*log(pi(-1))+em;
%(27) 货币供给
gm = log(m)-log(m(-1));
%市场出清
%(28)
Y = C+I;
%(29)
K(-1) = Ki+Kj;
%(30)
pii/pii(-1) = piii/pi(-1);
%(31)
pij/pij(-1) = pijj/pi(-1);
%(32)
log(Ai)-log(Ais) = rhoi*(log(Ai(-1))-log(Ais))+ei;
%(33)
log(Aj)-log(Ajs) = rhoj*(log(Aj(-1))-log(Ajs))+ej;
end;
initval;
Ni = Nis;
C = Cs;
wi = wis;
Nj = Njs;
wj = wjs;
rK = rKs;
RD = RDs;
pi = pis;
m = ms;
K = Ks;
I = Is;
di =dis;
Yi = Yis;
Ai = Ais;
Ki = Kis;
mci = mcis;
piistar =piistars;
piii = piiis;
xi1 = xi1s;
xi2 = xi2s;
pii =piis;
dj =djs;
Yj = Yjs;
Aj = Ajs;
Kj = Kjs;
mcj = mcjs;
pijstar = pijstars;
pijj = pijjs;
xj1 = xj1s;
xj2 = xj2s;
pij = pijs;
Y = Ys;
gm = gms;
end;
shocks;
var ei = 0.01^2;
var ej = 0.01^2;
var em = 0.01^2;
end;
resid(1);
steady;
check;
stoch_simul(order=1);