clear all
clc

mew_nk = 0.3;
mew_ne  = 0.3;
delta_n = 0.02;
delta_e = 0.02;
epsilon_n = 0.8;
mew_e = 0.1;
epsilon = epsilon_n;

sigma = 2;
gamma = 1;


omega = 0.424;

kappa = 12.9165;


betta = 0.97;
phi_n = 10;
phi_e = 10;

rho_The = 0.9;
rho_se = 0.9;
rho_ne = 0.9;

rho_Ae = 0.9;
rho_An = 0.9;


s_e_ss = 0.01;
T_n_e_ss = 0.01;
T_h_e_ss = 0.01;



P_e_ss = 1;
A_n_ss = 1;

R_n_ss = (1/betta) - (1 - delta_n);
R_e_ss = ((1 - s_e_ss)/betta) - ((1 - s_e_ss) * (1 - delta_e));

xau = mew_nk^((epsilon_n-1)/epsilon_n) * (A_n_ss/R_n_ss)^(epsilon_n-1);
zetta = ((1-omega) * (1-mew_e)^(1/epsilon))/kappa;

Kn_Yn = mew_nk * A_n_ss^(epsilon_n - 1)* R_n_ss^-epsilon_n;
Enstar_Yn = mew_ne * A_n_ss^(epsilon_n - 1) * P_e_ss^-epsilon_n;
Kn_Enstar = mew_nk * P_e_ss^epsilon_n * mew_ne^-1 * R_n_ss^-epsilon_n;
Enstar_Kn = Kn_Enstar^-1;
H_Yn = ((A_n_ss^-((epsilon_n-1)/epsilon_n) - (mew_nk^(1/epsilon_n) * Kn_Yn^((epsilon_n-1)/epsilon_n) + mew_ne^(1/epsilon_n) * Enstar_Yn^((epsilon_n-1)/epsilon_n))) / (1 - mew_nk - mew_ne)^(1/epsilon_n))^(epsilon_n/(epsilon_n-1));
H_Kn = ((xau^-1 - mew_nk^(1/epsilon_n) - mew_ne^(1/epsilon_n) * Enstar_Kn^((epsilon_n-1)/epsilon_n)) / (1 - mew_nk - mew_ne)^(1/epsilon_n))^(epsilon_n/(epsilon_n-1));
H_ss = 0.3;
Yn_H = H_Yn^-1;
Kn_H = H_Kn^-1;
W_ss = (1 - mew_nk - mew_ne)^(1/epsilon_n) * A_n_ss^((epsilon_n-1)/epsilon_n) * Yn_H^(1/epsilon_n);

Y_n_ss = Yn_H * H_ss;
K_n_ss = Kn_H * H_ss;
E_n_star_ss = Enstar_Yn * Y_n_ss;
E_n_ss = (mew_ne * A_n_ss^((epsilon_n-1)) * Y_n_ss * P_e_ss^-epsilon_n) - (T_n_e_ss/P_e_ss);

Y_e_ss = 1;
K_e_ss = (P_e_ss * Y_e_ss)/ R_e_ss;
A_e_ss = Y_e_ss / K_e_ss;

INV_n_ss = delta_n * K_n_ss;
INV_e_ss = delta_e * K_e_ss;

T_ss = (omega * W_ss * H_ss) - T_h_e_ss - T_n_e_ss - s_e_ss * INV_e_ss;

C_n_ss = ((1-omega) * W_ss * H_ss + T_ss + (R_n_ss * K_n_ss) + (R_e_ss * K_e_ss) - INV_n_ss - ((1-s_e_ss) * INV_e_ss) + T_h_e_ss) / (1 + mew_e * (1 - mew_e)^-1 * P_e_ss^(1-epsilon));
C_e_ss = mew_e * (1-mew_e)^-1 * C_n_ss * P_e_ss^-epsilon - T_h_e_ss/P_e_ss;
%C_ss = (H_ss^sigma/(zetta * W_ss * C_n_ss^(-1/epsilon)))^(1/(-gamma+(1/epsilon)));
C_e_star_ss = C_e_ss + (T_h_e_ss / P_e_ss);

C_ss = (mew_e^(1/epsilon) * (C_e_ss + (T_h_e_ss/P_e_ss))^((epsilon-1)/epsilon) + (1 - mew_e)^(1/epsilon) * C_n_ss^((epsilon-1)/epsilon))^(epsilon/(epsilon-1));

H_ss_test = ((((1-omega) * (1-mew_e)^(1/epsilon))/kappa) * W_ss * C_ss^(-gamma+(1/epsilon)) * C_n_ss^(-1/epsilon))^(1/sigma);
kappa_test = (1-omega) * (1-mew_e)^(1/epsilon) * W_ss * C_ss^(-gamma + (1/epsilon)) * C_n_ss^(-1/epsilon) * H_ss^-sigma;
Y_n_ss_test = A_n_ss * (mew_nk^(1/epsilon_n) *  K_n_ss^((epsilon_n-1)/epsilon_n) + mew_ne^(1/epsilon_n) * (E_n_ss + (T_n_e_ss / P_e_ss))^((epsilon_n-1)/epsilon_n) + (1 - mew_nk - mew_ne)^(1/epsilon_n) * H_ss^((epsilon_n-1)/epsilon_n))^(epsilon_n/(epsilon_n-1));
P_e_ss_test = mew_ne^(1/epsilon_n) * A_n_ss * (Y_n_ss * A_n_ss^-1 * (E_n_ss + (T_n_e_ss/P_e_ss))^-1)^1/epsilon_n;

C_ss/(Y_n_ss + Y_e_ss)
(INV_n_ss + INV_e_ss)/(Y_n_ss + Y_e_ss)
Y_n_ss + (P_e_ss * Y_e_ss) - (C_n_ss + (P_e_ss * C_e_ss) + (P_e_ss * E_n_ss) + INV_n_ss + INV_e_ss + T_h_e_ss + T_n_e_ss)


