% Mimir, Y. (2016), Financial Intermediaries, Credit Shocks and Business Cycles
% Oxford Bulletin of Economics and Statistics, 78: 42-74. https://doi.org/10.1111/obes.12099
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 0. HOUSEKEEPING
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
tic;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1. MODEL PARAMETERIZATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global alpha beta sigma h Fri delta b zetta gamma Lstar epsilon lambda;
alpha = 0.36; %capital share in production function
beta = 0.9942; %quarterly discount factor
sigma = 1; %risk aversion parameter
h = 0.815; %habit formation parameter
Fri = 0.276;
delta = 0.0212; %quarterly depreciation rate of capital
b = 0.03078; %capacity utilization parameter
zetta = 7.2; %elasticity of marginal depreciation w.r.t utilization rate
gamma = 0.9685; %survival probability of bankers (0.955)
Lstar = 0.3333; %labor hours
lambda = 0.1548; %fraction of diverted funds by bankers (0.1047)
epsilon = 0.001; %amount of startup funds as a percentage of net worth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 2. DETERMINISTIC STEADY-STATE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global x0;
x0 = [0.85 2.4027 10 0.26 2.10 0.0198 0.0101 10 4 1.2 0.002 0.76 1 0.025];
options=optimset('Display', 'iter','MaxIter',1e8, 'MaxFunEvals', 1e8,'FunValCheck','on','TolFun', 1e-15);
[x,fval,exitflag] = fsolve(@baseline_ss,x0,options); % Call optimizer
c_ss = x(1);
nu = x(2);
k_ss = x(3);
i_ss = x(4);
w_ss = x(5);
rk_ss = x(6);
r_ss = x(7);
s_ss = x(8);
n_ss = x(9);
y_ss = x(10);
nu_ss = x(11);
eta_ss = x(12);
d_ss = s_ss - n_ss;
lev_ss = d_ss/n_ss;
car_ss = n_ss/s_ss;
u_ss = x(13);
delta_ss = x(14);
SS_RBC_realrigidities = [c_ss Lstar k_ss i_ss w_ss rk_ss r_ss s_ss n_ss y_ss nu_ss eta_ss d_ss lev_ss car_ss u_ss delta_ss]';
save('SS_values','SS_RBC_realrigidities');