% Steady State Calculation from scratch
clear all;
clc;

format long
OMEGA_Y_STEADY = 0.65; % With 0.8 the sum of residuals is the lowest
THETA_P=11;
DELTA_K_STEADY=0.015;
ALPHA_STEADY=0.6;
%PHI=1.445;
PHI_STEADY=1.445;


XI_P=0.815;
VARPHI=0.156; 
GAMMA_I=15;
DELTA_M=1-0.9965;
GAMMA0 = -0.0204;
GAMMA1 = 3.5017e-05;
GAMMA2 = -9.0468e-10;
BR_SHARE=0.0146;
M=851;

% govt_to_GDP = 0.1905;   % Government consumption to GDP
% priv_to_GDP = 0.6161;   % Private consumption to GDP
% inv_to_GDP  = 0.1934;   % Investment to GDP

govt_to_GDP = 0.2;   % Government consumption to GDP
priv_to_GDP = 0.6;   % Private consumption to GDP
inv_to_GDP  = 0.2;   % Investment to GDP



Z_TOTAL=DELTA_M*M;
Z_STEADY=Z_TOTAL*BR_SHARE;
Z_STAR_STEADY=Z_TOTAL-Z_STEADY;

Y_STEADY=Z_STEADY/VARPHI;
YF_STEADY=OMEGA_Y_STEADY*Y_STEADY;
YS_STEADY=(1-OMEGA_Y_STEADY)*Y_STEADY;

I_STEADY=Y_STEADY*inv_to_GDP;
K_STEADY=I_STEADY/DELTA_K_STEADY;
G_STEADY=Y_STEADY*govt_to_GDP;
C_STEADY=Y_STEADY-I_STEADY-G_STEADY;

L_STEADY=0.2;
LF_STEADY=0.15;
LS_STEADY=L_STEADY-LF_STEADY;

AS_STEADY=YS_STEADY/((1-GAMMA0-GAMMA1*M-GAMMA2*M^2)*LS_STEADY);
AF_STEADY=YF_STEADY/((1-GAMMA0-GAMMA1*M-GAMMA2*M^2)*(K_STEADY^ALPHA_STEADY)*(LF_STEADY^(1-ALPHA_STEADY)));

% Ratio of PSIS and PSIF
RATIO_PSIF_PSIS = (1-ALPHA_STEADY)*(OMEGA_Y_STEADY/(1-OMEGA_Y_STEADY))*(LS_STEADY/LF_STEADY);
MC_SS=(THETA_P-1)/THETA_P;
PSIF_STEADY=MC_SS/(1+RATIO_PSIF_PSIS);
PSIS_STEADY=MC_SS-PSIF_STEADY;

W_STEADY=(1-ALPHA_STEADY)*(YF_STEADY/LF_STEADY)*PSIF_STEADY;
RK_STEADY=ALPHA_STEADY*(YF_STEADY/K_STEADY)*PSIF_STEADY;

% Implied Beta
BET_STEADY = 1/(RK_STEADY+(1-DELTA_K_STEADY));

% Implied MU_L

MU_L_STEADY = W_STEADY/((L_STEADY^PHI_STEADY)*C_STEADY);


