
function F = fun_megabe(c,mu,sigma,beta_e,beta_u,etaa,chi,gammaa,theta,vepsilon,nu,Te)

%[name='Unemployed BC']
F(1) = c(3) + (1+(1/beta_u - 1))*c(9) - c(9) - nu - Te;

%[name='Marginal utility of hours']
F(2) = c(4) - chi*c(2)*(c(5)^(1/etaa));

%[name='Wage and MC']
F(3)= c(4) - c(7);

%[name='Aggregate hours']
F(4) = c(6) - gammaa*c(5);

%[name='Production technology']
F(5) = c(8) - c(6);

%[name='Aggregate consumption']
F(6) = c(1) - gammaa*c(2) - (1 - gammaa)*c(3);

%[name='Output']
%F(7) = (1 - (xi/2) * (Pi^2))*c(8) - c(1);
F(7) = c(8)-c(1);

%[name='Total loan']
F(8) = c(10) - (1-gammaa) * c(9);

%[name='Total deposit']
F(9) = c(12) - gammaa * c(11);

%[name='Net worth']
F(10) = c(10) - c(13) - c(12);

%[name='Net worth accumulation']
%F(11) = c(13) - ((1/beta_u - 1)-(1/beta_e - 1))*c(10) - ((1/beta_e - 1))*c(13);
F(11) = c(13) - (1-mu+sigma)* (1/beta_u - 1)*  c(10) + (1-mu)* (1/beta_e - 1) *c(12);

%[name='Leverage ratio']
F(12) = c(10) - (c(14)*c(13))/(theta - c(15));

%[name='Augmenting factor for SDF']
F(13) = c(16) - mu - (1-mu)*((theta*c(14))/(theta - c(15)));

%[name='SDF']
%F(1) = beta_e - beta_e*c(2)(-1)/c(2);

%[name='Marginal value of deposits']
F(14) = c(14) - beta_e*c(16)*(1/beta_e - 1);

%[name='Excess value of holding loans']
F(15) = c(15) - beta_e*c(16)*((1/beta_u - 1)-(1/beta_e - 1));

%[name='NKPC']
%0 = (1-vepsilon) + vepsilon*c(7) - xi*Pi*(1+Pi) + xi*beta_e(+1)*(c(8)(+1)/c(8))*Pi(+1)*(1+Pi(+1));
F(16) = (1-vepsilon) + vepsilon*c(7);

% F(17) = c(17)-Te;

%[name='Employed utility']
F(17) = c(17) - log(c(2)) + chi*(c(5)^(1+1/etaa))/(1+(1/etaa));

%[name='Employed welfare']
F(18) = c(18) - c(17) - beta_e*c(18);

%[name='Unemployed utility']
F(19) = c(19) - log(c(3)) + chi*(nu^(1+1/etaa))/(1+(1/etaa));

%[name='Unemployed welfare']
F(20) = c(20) - c(19) - beta_u*c(20);

%[name='Consumption equivalence - employed']
F(21) = c(21) - (log(1.01*c(2)) - chi*(c(5)^(1+1/etaa))/(1+(1/etaa))) + c(17);

%[name='Consumption equivalence - unemployed']
F(22) = c(22) - (log(1.01*c(3)) - chi*(nu^(1+1/etaa))/(1+(1/etaa))) + c(19);

%[name='Total welfare']
F(23) = c(23) - gammaa*(c(18))-(1-gammaa)*(c(20));

end