%  Thesis Calibration and Steady State

% Clear variables
clear 
% Clear the command window
clc
% Define global variables
global nu kappa deltan deltak deltaz eta phiy phil thetak thetaz xi phip epsilonp bbeta zeta q lfp v psi Asteady chi;

%--------------------------------------------------------------------------
% Parameterization

% Standard structural parameters
nu        = 13.8;     % participation disutility parameter
kappa     = 5.56;  % elasticity of participation with respect to real wage
deltan    = 0.039; % 0.0373;  % quarterly job separation rate
deltak    = 0.025; % capital depreciation rate
deltaz    = 0.025; % capital depreciation rate
eta       = 0.5;  % Nash bargaining power of workers
phiy      = 0.5;  % Elasticity of substitution between labor-complement capital and labor services
phil      = 2.5;  % Elasticity of substitution between labor-substitute capital and labor 
thetak    = 0.36;   % CES distribution parameter for labor-complement capital or 0.25
thetaz    = 0.045;   % CES distribution parameter for labor-substitute capital
xi        = 0.4;  % Elasticity of aggregate matches with respect to search unemployment 0.40
phip      = 0.66;  % Probability of no price revision
epsilonp  = 10;    % Elasticity of substitution between intermediate goods
bbeta     = 0.99;  % Households’ quarterly subjective discount factor
zeta      = 0.24;  % price indexation parameter
psi       = 0.765;  % matching parameter 0.765 to match 
q         = 0.9; % vacancy filling probability
lfp       = 0.63; % labor force participation rate
%gamma     = .03; % cost of posting a vacancy
v         = 0.02668;
%f         = 0.6;
Asteady   = 1;
chi       = 0.6; 
%--------------------------------------------------------------------------
% Calibrated Parameters

% Initial values to solve the system of equations in calibration.m
feed = [    
0.5; % R
0.5; % c
0.5; % pit
0.5; % w
0.5; % rK 
0.5; % rZ 
0.5; % K 
0.5; % Ik
0.5; % Z 
0.5; % Iz 
0.5; % mc
0.5; % Y 
0.5; % L 
0.5; % x1 
0.5; % x2 
0.5; % vartheta 
0.5; % pistar 
0.5; % s
0.5; % n
0.5; % m
0.5; % deltan
0.5; % gamma
];    

% Set the options for fsolve for our system of equations
options_fsolve_silent = optimset('display','iter','maxfunevals',100000,'maxiter',100000','tolfun',10e-25,'tolx',10e-25);

% Call the function calibration_2_4.m 
[outc,fval,eflag] = fsolve(@calibration4,feed,options_fsolve_silent);

% Store the outputs of our function into steady-state variables
Rss = outc(1);
css = outc(2);
pitss = outc(3);
wss = outc(4);
rKss = outc(5);
rZss = outc(6);
Kss = outc(7);
Ikss = outc(8);
Zss = outc(9);
Izss = outc(10);
mcss = outc(11);
Yss = outc(12);
Lss = outc(13);
mss = outc(14); 
x1ss = outc(15);
x2ss = outc(16);
varthetass = outc(17);
pistarss = outc(18);
sss = outc(19);
nss = outc(20);
fss = outc(21);
gammass = outc(22);


%gammass = 0.03*wss; %new, % gammass = 0.03*wss; %original
%chiss = 0.6;
%Asteady = 1;
%mss = 0.036;
%mss = psi*sss^(xi)*vss^(1-xi);
%fss = 0.6;
%fss = mss/sss;
%qss = mss/vss;
%lfpss = nss + (1-fss)*sss;
%nss = lfpss-(1-fss)*sss;
