var l w c_s c_e d b T r_d r_b pi y t_p q_h a eps_h gfd k i B j_b h lb Delta;
varexo epsh eps_a epsg;
parameters psi gamma_s G gamma_e beta_p beta_e beta_b nu_b mu_k rho_a ass rho_epsh rho_epsg epshss epsgss m yss j v alph iss phipie phix piss delt alph1 alph2;
alph=0.443914003;
psi=2.219566009;
delt=1.009174312;
gamma_s=2;
gamma_e=2;
beta_p=0.99;
beta_e=0.975;
beta_b=0.99;
m=0.55;
v=1.5;
nu_b=0.09;
mu_k=0.5;
rho_a=0.99;
rho_epsh=0.99;
rho_epsg=0.99;
ass=1;
epshss=1;
epsgss=1;
iss=0.010101;
r_dss=1/beta_p; %1.010101
G=0.2;
yss=1;
j=0.049088209;
phipie=2;
phix=0.5;
piss=1;
alph1=0.2;
alph2=0.5;
model;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%savers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h=1;
B=0;
Delta=1;
y=a*l^alph;
c_e^(-gamma_e)*(a*alph*l^(alph-1)-w)=0;
psi*l^v=w*c_s^(-gamma_s);
c_e=y-c_s-G+T;
c_s^(-gamma_s)=beta_p*r_d*c_s(+1)^(-gamma_s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Agricultural Entrepreneur
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lb=c_e^(-gamma_e)-beta_e*r_b*c_e(+1)^(-gamma_e);
j*eps_h=q_h*(c_e^(-gamma_e)*(1-beta_e));
(r_b)*b = m*pi(+1)*q_h(+1);
c_e+Delta*r_b(-1)*b(-1)+w*l+q_h*(h-h(-1))=y+b;
t_p=c_s+d+T-w*l-r_d(-1)*d(-1)/pi;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Banks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d+k+i*B=b+B(+1)-B;
r_b=r_d - mu_k*(k/b - nu_b)*k*beta_b^(-1);
beta_b*r_d*(1+i) = pi*r_d(-1);
j_b=r_b*b-r_d*d;
k=(1-delt)*k(-1)+j_b;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Government
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
G+(1+i)*B=B(+1)+T;
gfd = G-T;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Monetary Policy - Taylor Rule
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
log(1+i) = log(1+iss) + phipie*log(pi/piss) + phix*log(y/yss);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Exogenous Processes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a = rho_a*a(-1)+ (1-rho_a)*ass+eps_a;
%eta = rho_eta*eta(-1)+ (1-rho_eta)*etass+eps_eta;
eps_h = rho_epsh*eps_h(-1)+ (1-rho_epsh)*epshss+epsh;
%eps_g = rho_epsg*eps_g(-1)+ (1-rho_epsg)*epsgss+epsg;
%G = alph1*B(-1)-alph2*(y-yss)-epsg;
%Market Clearing
end;
initval;
l=1;
B=0;
Delta=1;
y=1;
h=1;
pi=piss;
w=alph;
c_s=0.447214;
c_e=0.552786;
r_d=r_dss;
r_b=r_d;
i=iss;
q_h=0.6;
b=0.326700003;
j_b=0.0297;
k=0.029403;
d=0.297297002;
%G=0.2;
T=G;
t_p=0.200297;
lb=(1-beta_e*r_b)/c_e^gamma_e;
end;
shocks;
var eps_a;
stderr 1;
var epsh;
stderr 1;
var epsg;
stderr 1;
end;
steady;
%check;
stoch_simul (order=1, nocorr, nomoments, irf=0);