function F=MyfunctionSS(z) % date: 10.12
% known variables
beta = 0.995;
phi_m = 0.06;
% pi = 1; % inflation rate which at SS point will be 1.
alpha = 0.7556;
phi_l = 0.40;
eta = 2;
phi = 0.50;
theta = 1.5;
theta_p = 10;
psi_bar = 0.9;
phi_tilda = (1-phi)^(phi-1)/phi^phi;
alpha_tilda = (1-alpha)^(alpha-1)/alpha^alpha;
v = (theta_p - 1)/theta_p;
ca = 0;


% Unknown variables
c = z(1); % HH consumptions
M = z(2); % the nominal money balance
P = z(3); % domestic price level
B = z(4); % nominal domestic bond 
e = z(5); % nominal exchange rate
Bf_p = z(6); % nominal foreign bond
l = z(7); % labor hours
D = z(8); % nominal dividends
q = z(9); % real exchange rate
gamma_h = z(10); % domestically produced goods (quantities)
gamma_f = z(11); % imported goods (quantities)
Bf = z(12);  % aggregate nominal foreign bonds
GDP = z(13); % real GDP
R = z(14);% Nominal interest rate and R = Rf;

% Equations

% HH budget contraints eq.2
F(1)= c * (phi_l*l^(1+eta)-1) + (B+e*Bf_p*(R-1))/P + D/P-c-(B+e*Bf_p)/P;
% optimal money demand eq.3
F(2)= M/P*(1-beta)-c*phi_m;
% marginal cost for firms (comb eq.8&eq.12)
F(3)= phi_tilda*(alpha_tilda*q^(1-alpha))^phi*(phi_l*l^eta*c)^(1-phi)-v;
% wage for firms FOC of l for eq.7  
F(4)= (1-phi)*(gamma_h^alpha*gamma_f^(1-alpha)/l)^phi-phi_l*l^eta*c;
% price of intermediate goods FOC of gamma for eq.7 
F(5)= phi*(gamma_h^alpha*gamma_f^(1-alpha)/l)^(phi-1)-alpha_tilda * q^(1-alpha);
% price of foreign goods to produce intermediate goods FOC eq.13
F(6)= (1-alpha)*(gamma_h/gamma_f)^alpha-q*P;
% price of domestic goods to produce intermediate goods FOC eq.13
F(7)= alpha*(gamma_h/gamma_f)^(alpha-1) - P;
% current account eq.16
F(8)= q^theta - q*gamma_f+e*(R-1)*Bf/P - ca;
% flow-fund constrainteq.21
F(9)= B - e*(Bf-Bf_p);
% market clear condition for final goods eq.22
F(10)= c+gamma_h+q^theta -((gamma_h^alpha*gamma_f^(1-alpha))^phi)*l^(1-phi);
% real GDP approach with expenditure eq.28
F(11)= c + q^theta - q*gamma_f - GDP;
% real GDP approach with HH BC and eq.21.
F(12)= phi_l*l^(1+eta)*c + D/P - GDP;
% Def. of psi
F(13)= B/(B+e*Bf_p) - psi_bar;
% Nominal interest rate R. eq.(a) from DIY
F(14)= 1/beta - R;



