%Solves steady state system of equations 

% November 2014

function F=ss_fun(x)

%global M_
 
% Here we load the values of the deep parameters in a loop.
 
%NumberOfParameters = M_.param_nbr;                            % Number of deep parameters.
%for i = 1:NumberOfParameters                                  % Loop...
  %paramname = deblank(M_.param_names(i,:));                   %    Get the name of parameter i. 
 % eval([ paramname ' = M_.params(' int2str(i) ');']);         %    Get the value of parameter i.
%end                                                           % End of the loop.  
%check = 0;


%% High wage sector

ug_ss=x(1);
ng_ss=x(2);
vg_ss=x(3);
mg_ss=x(4);
pg_ss=x(5);
qg_ss=x(6);
epsilong_ss=x(7);
thetag_ss=x(8);
wg_ss=x(9);

%% Low wage sector

ub_ss=x(10);
nb_ss=x(11);
vb_ss=x(12);
mb_ss=x(13);
pb_ss=x(14);
qb_ss=x(15);
epsilonb_ss=x(16);
thetab_ss=x(17);
wb_ss=x(18);
e_ss=x(19);
s_ss=x(20);
qr_ss=x(21);

%% Aggregates, unemployment benefits

q_ss=x(22);
n_ss=x(23);
v_ss=x(24);
m_ss=x(25);
c_ss=x(26);
b=x(27);

%% Parameter definitions


betta=0.99;
tau=1.1;            % Search cost elasticity parameter
kappa=0.04;         % Scale parameter search cost function
%sigma=2;            % Relative risk aversion
alphha=0.4;        % Input in final output from low wage sector
rhox=0.1;            % Job separation rate
gammma=11;
eta=0.5;                      % Relative bargaining power worker
xi=0.7;                       % Elasticity of the matching function
cg=0.16;                      % Vacancy posting costs (high wage sector)                     
cb=0.04;                      % Vacancy posting costs (low wage sector)
chig=0.6;                     % Matching efficiency (high wage sector)                     
chib=0.6;   
zeta=betta*(1-rhox);
u_ss=0.12;                      % Unemployment rate
Ass=1;                          % Steady state level of technology

%% Steady state system of equations

F=[mg_ss-chig*(ug_ss+e_ss)^xi*vg_ss^(1-xi);
   mb_ss-chib*ub_ss^xi*vb_ss^(1-xi);
   m_ss-(mg_ss+mb_ss);
   v_ss-(vg_ss+vb_ss);
   n_ss-(ng_ss+nb_ss);
   u_ss-(ug_ss+ub_ss);
   u_ss-(1-n_ss);
   qb_ss-mb_ss/vb_ss;
   qg_ss-mg_ss/vg_ss;
   q_ss-m_ss/v_ss;
   pb_ss-mb_ss/vb_ss;
   pg_ss-mg_ss/(ug_ss+e_ss);
   cg/qg_ss*(1-zeta)-zeta*(epsilong_ss*Ass-wg_ss);
   cb/qb_ss*(1-zeta*(1-pg_ss*s_ss))-zeta*(epsilonb_ss*Ass-wb_ss);
   wg_ss-(eta*(epsilong_ss*Ass+cg*thetag_ss)+(1-eta)*b);
   wb_ss-(eta*(epsilonb_ss*Ass+(1-(1-rhox)*s_ss)*cb*thetab_ss)+(1-eta)*(b+kappa*s_ss^tau));
   kappa*tau*s_ss^(tau-1)-eta/(1-eta)*pg_ss*(cg/qg_ss-cb/qb_ss);
   (rhox-(1-rhox)*s_ss*pg_ss)*nb_ss-mb_ss;
   rhox*ng_ss-mg_ss;
   (gammma-1)/gammma-(epsilonb_ss/alphha)^alphha*(epsilong_ss/(1-alphha))^(1-alphha);
   e_ss-s_ss*nb_ss;
   thetab_ss-vb_ss/ub_ss;
   thetag_ss-vg_ss/(ug_ss+e_ss);
   qr_ss-e_ss*pg_ss/n_ss;
   c_ss-gammma/(gammma-1)*(epsilong_ss*(ng_ss-cg*vg_ss)/(1-alphha));
   cg*thetag_ss-cb*thetab_ss];

























