%% Calibration file
%parameters

% Households' holding of long term bonds
b_h_B=0.7321; %ratio bbar_h/B
f_h_F=0; %ratio fbar_h/F
tau_B=2.1; %portfolio adjustment costs public bonds
%tau_F=11; %portfolio adjustment costs private bonds %the demand of private bonds from HHs is closed on the .mod file

Y_ss=1;
util_cap_ss=1;
pi_ss=1 + 3.2/400; % gross inflation target 

alpha=0.36;
delta0=0.03;
elast_depreciation=0.33; % elasticity of marginal depreciation wrt capital depreciation=1 as in Basu and Kimball 1997 and Baxter and Farr (2001)or =0.33 as in Comin (2006) 
ADI=3.5; %4 end growth; 5.54 exo growth
epsilon=11;
psi=0.81;
h_cons=0.8;

sigma=0.95;
psi_i=0.7;
psi_pi=1.5;
psi_y=0.5/4;
kbond=1-(40^(-1));
pK_ss=1;
Gy=0.20;
sp_f_ss=1 + 3/400;
sp_b_ss=1 + 1.5/400; %1.0125^(1/4);--> works to lower the spread! with rho=0.925
lev_ss=4;
zeta    = 0.63;         % Calvo probability of not changing prices 0.58%
% Labor market
UR_ss=0.05; %% SS unemployment rate
eta=0.5; %bargaining power
el_mat=0.5; %elasticity of matching wrt job seekers
j_f_ss=0.656; %job finding rate % match sep. rate=8.5% as in Furlanetto and Groshenny (2016)
j_v_ss=0.9; %job filling rate
hc_ss=0.01; %hiring costs as % of ss output
gamma=0;%degree of wage persistence

% FOR ESTIMATION
%g_ss=1; % SS growth 
%beta=0.996;

piconst=0.5;
gyest = 0.45317;
betaest = 0.42122;


%% Shocks
rhoA=0.95;
sdeA=0.695; %0.7 end growth; 0.83 exo growth

rho_theta=0.95;
sde_theta=3.75;

sG=0.5;
rhoG=0.9;

sdem=0.1;

rhoPiStar=0.95;%--> inflation shock
sdeP=0.5;
rhoPiAv=0;%--> inflation target
v_pi=0;

rho_liq=0.926; % --> liquidity shock; Anzoategui et al 
sde_liq= 0;%0.013; % --> Anzoategui et al 
liq_ss=0;

by=0.61; %%Government debt--> taken from FRED

%% MONEY
money_ss=0.05;
rho_money=0.5;

rho_money_shock=0.9;
sde_money_shock=0.01;
%% Implied parameters from model--> this would be the ones that go into the file to keep estimating
tight_ss=j_f_ss/j_v_ss; % COMPOSITE PARAMETER
L_ss=1-UR_ss; % COMPOSITE PARAMETER
sep=j_f_ss*UR_ss/(L_ss*(1-j_f_ss)); % job separation rate % COMPOSITE PARAMETER
U_ss=1-(1-sep)*L_ss; %job seekers % COMPOSITE PARAMETER
H_ss=sep*L_ss; %matches % COMPOSITE PARAMETER
m_eff=j_v_ss/(tight_ss^(-el_mat)); % matching efficiency % COMPOSITE PARAMETER
v_ss=H_ss/j_v_ss; %vacancies % COMPOSITE PARAMETER
v_ss2=tight_ss*U_ss; % COMPOSITE PARAMETER
vac_cost = hc_ss*Y_ss/v_ss; % COMPOSITE PARAMETER

M_ss                       =beta/g_ss; % COMPOSITE PARAMETER
Rd_ss                      =pi_ss/M_ss; % COMPOSITE PARAMETER
Rb_ss                      =sp_b_ss*Rd_ss; % COMPOSITE PARAMETER
Rf_ss                      =sp_f_ss*Rd_ss; % COMPOSITE PARAMETER
Qb_ss                      =(Rb_ss-kbond)^(-1); % COMPOSITE PARAMETER
Qf_ss                      =(Rf_ss-kbond)^(-1); % COMPOSITE PARAMETER

xi_ss             = (M_ss/pi_ss)*(Rf_ss-Rd_ss)/(1-(M_ss/pi_ss)*kbond); % COMPOSITE PARAMETER
exs_ss            = 1+psi*xi_ss;  % COMPOSITE PARAMETER

piestarss = ((1-zeta*(pi_ss^(epsilon-1)))/(1-zeta))^(1/(1-epsilon));
dispss = (1-zeta)*(piestarss^(-epsilon))/(1-zeta*(pi_ss^(epsilon))); % COMPOSITE PARAMETER
ps_ss        = ((epsilon-1)/epsilon)*piestarss*(1-M_ss*g_ss*zeta*(pi_ss^epsilon))/(1-M_ss*g_ss*zeta*(pi_ss^(epsilon-1))); % COMPOSITE PARAMETER
x1ss=ps_ss*Y_ss/(1-zeta*M_ss*(pi_ss^epsilon)*g_ss); % COMPOSITE PARAMETER
x2ss=Y_ss/(1-zeta*M_ss*(pi_ss^(epsilon-1))*g_ss); % COMPOSITE PARAMETER

rK_ss=exs_ss*(1-M_ss*(1-delta0))/(M_ss*util_cap_ss); % COMPOSITE PARAMETER
k_ss=alpha*ps_ss*Y_ss*dispss/(util_cap_ss*rK_ss); % COMPOSITE PARAMETER
A                          =Y_ss*dispss/(L_ss^(1-alpha)*(util_cap_ss*k_ss)^alpha); % COMPOSITE PARAMETER
inv_ss                     =k_ss*(g_ss-(1-delta0)); % COMPOSITE PARAMETER

delta1                     =rK_ss/exs_ss;% COMPOSITE PARAMETER
delta2                     =elast_depreciation*delta1;%0.01;%elast_depreciation*delta1; % COMPOSITE PARAMETER
J_ss                       =vac_cost/j_v_ss;
w_ss                       =ps_ss*(1-alpha)*Y_ss*dispss/L_ss - J_ss*(1-(1-sep)*M_ss*g_ss);
Ntil_ss                    =J_ss*eta/(1-eta);
b_ur                       =w_ss-Ntil_ss*(1-M_ss*g_ss*(1-j_f_ss)*(1-sep));

Gov_ss                       =Gy*Y_ss;
c_ss                       =Y_ss-inv_ss-Gov_ss-vac_cost*v_ss;
lambda_ss                  =(1/c_ss)*((1/(1-(h_cons/g_ss)))-beta*(h_cons/(g_ss-h_cons)));

fw_ss                   = psi*inv_ss/(Qf_ss*(g_ss-kbond/pi_ss));
bG_ss                   = by*4*Y_ss/Qb_ss;
fbar_h                  = f_h_F*fw_ss;
bbar_h                  = b_h_B*bG_ss;
fh_ss                   = fbar_h;%(fbar_h+(M_ss/pi_ss)*(Rf_ss-Rd_ss)/tau_F)/g_ss;
bh_ss                   = (bbar_h+(M_ss/pi_ss)*(Rb_ss-Rd_ss)/tau_B)/g_ss;

fbond_ss                = fw_ss - fh_ss; % private bond holding FI
bbond_ss                = bG_ss - bh_ss;% public bond holding FI

networth_ss                = (Qf_ss*fbond_ss+Qb_ss*bbond_ss)/lev_ss;
dep_ss                     = Qf_ss*fbond_ss+Qb_ss*bbond_ss-networth_ss;
small_o                    =(Rb_ss-Rd_ss)/(Rf_ss-Rd_ss);
phi_ss                     =(Qf_ss*fbond_ss+small_o*Qb_ss*bbond_ss)/networth_ss;
theta_ss                   =((1-sigma)+M_ss*phi_ss*(1-sigma)*(Rf_ss-Rd_ss)*(1/pi_ss))/(phi_ss*(1-sigma)-M_ss*sigma*(phi_ss^2)*(Rf_ss-Rd_ss)*(1/pi_ss));
BIG_O_ss                   =(1-sigma)+sigma*phi_ss*theta_ss;
Tx_ss                      = g_ss*networth_ss - (sigma/pi_ss)*((Rf_ss-Rd_ss)*Qf_ss*fbond_ss+(Rb_ss-Rd_ss)*Qb_ss*bbond_ss+Rd_ss*networth_ss);
mu_ss                      =((M_ss/pi_ss)*(Rf_ss-Rd_ss)*BIG_O_ss)/(theta_ss -(M_ss/pi_ss)*(Rf_ss-Rd_ss)*BIG_O_ss);

Qeh10_ss=1/(Rd_ss-kbond);
Reh10_ss=1/Qeh10_ss + kbond;
Ry_ss=1/Qb_ss+kbond;
TP_ss=Ry_ss/Reh10_ss;
spread_ss=Ry_ss/Rd_ss;
Ryf_ss=1/Qf_ss+kbond;
Cspread_ss=Ryf_ss/Ry_ss;

priv_debt_y=Qf_ss*fbond_ss/(4*Y_ss); % value of outstanding debt in proportion of output
mpl=ps_ss*(1-alpha)*Y_ss*dispss/L_ss;


% #tight=j_f/j_v;
% #L=1-UR;
% #sep=j_f*UR/(L*(1-j_f)); % job separation rate
% #U=1-(1-sep)*L; %job seekers
% #H=sep*L; %matches
% #m_eff=j_v/(tight^(-el_mat)); % matching efficiency
% #v=H/j_v; %vacancies
% #v2=tight*U;
% #vac_cost = hc*Y/v;
% 
% #M                          =beta/g;
% #Rd                      =pi/M;
% #Rb                      =sp_b*Rd;
% #Rf                      =sp_f*Rd;
% #Qb                      =(Rb-kbond)^(-1);
% #Qf                      =(Rf-kbond)^(-1);
% 
% #xi             = (M/pi)*(Rf-Rd)/(1-(M/pi)*kbond);
% #exs            = 1+psi*xi;  
% 
% #piestar = ((1-zeta*(pi^(epsilon-1)))/(1-zeta))^(1/(1-epsilon));
% #disp = (1-zeta)*(piestar^(-epsilon))/(1-zeta*(pi^(epsilon)));
% #ps        = ((epsilon-1)/epsilon)*piestar*(1-M*g*zeta*(pi^epsilon))/(1-M*g*zeta*(pi^(epsilon-1)));
% #x1=ps*Y/(1-zeta*M*(pi^epsilon)*g);
% #x2=Y/(1-zeta*M*(pi^(epsilon-1))*g);
% 
% #rK=exs*(1-M*(1-delta0))/(M*util_cap);
% #k=alpha*ps*Y*disp/(util_cap*rK);
% #A                          =Y*disp/(L^(1-alpha)*(util_cap*k)^alpha);
% #inv                     =k*(g-(1-delta0));
% 
% #delta1                     =rK/exs;
% #delta2                     =elast_depreciation*delta1;%0.01;%elast_depreciation*delta1;
% #J                       =vac_cost/j_v;
% #w                       =ps*(1-alpha)*Y*disp/L - J*(1-(1-sep)*M*g);
% #Ntil                    =J*eta/(1-eta);
% #b_ur                       =w-Ntil*(1-M*g*(1-j_f)*(1-sep));
% 
% #Gov                       =Gy*Y;
% #c                       =Y-inv-Gov-vac_cost*v;
% #lambda                  =(1/c)*((1/(1-(h_cons/g)))-beta*(h_cons/(g-h_cons)));
% 
% #fw                   = psi*inv/(Qf*(g-kbond/pi_ss));
% #bG                   = by*4*Y/Qb;
% #fbar_h                  = f_h_F*fw;
% #bbar_h                  = b_h_B*bG;
% #fh                   = fbar_h;%(fbar_h+(M/pi)*(Rf-Rd)/tau_F)/g;
% #bh                   = (bbar_h+(M/pi)*(Rb-Rd)/tau_B)/g;
% 
% #fbond                = fw - fh; % private bond holding FI
% #bbond                = bG - bh;% public bond holding FI
% 
% #networth_ss                = (Qf_ss*fbond_ss+Qb_ss*bbond_ss)/lev;
% #dep                     = Qf*fbond+Qb*bbond-networth;
% #small_o                    =(Rb-Rd)/(Rf-Rd);
% #phi                     =(Qf*fbond+small_o*Qb*bbond)/networth;
% #theta                   =((1-sigma)+M*phi*(1-sigma)*(Rf-Rd)*(1/pi))/(phi*(1-sigma)-M*sigma*(phi^2)*(Rf-Rd)*(1/pi));
% #BIG_O                   =(1-sigma)+sigma*phi*theta;
% #Tx                      = g*networth - (sigma/pi)*((Rf-Rd)*Qf*fbond+(Rb-Rd)*Qb*bbond+Rd*networth);
% #mu                      =((M/pi)*(Rf-Rd)*BIG_O)/(theta -(M/pi)*(Rf-Rd)*BIG_O);
% 
% #Qeh10=1/(Rd-kbond);
% #Reh10=1/Qeh10 + kbond;
% #Ry=1/Qb+kbond;
% #TP=Ry/Reh10;
% #spread=Ry/Rd;
% #Ryf=1/Qf+kbond;
% #Cspread=Ryf/Ry;
% 
% #priv_debt_y=Qf*fbond/(4*Y); % value of outstanding debt in proportion of output
% #mpl=ps*(1-alpha)*Y*dispss/L;