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 ;
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;
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);
lb=0;
j*eps_h=q_h*(c_e^(-gamma_e)*(1-beta_e));
(r_b)*b = m*pi(+1)*q_h(+1);
c_e+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;
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);