clc; clear all; close all

%% This code computes the steady state of a NK model with banks à la GK11
%  Author: Valerio Nispi Landi
%  First version: 06/09/2018
%  This version: 04/04/2021

%% Structural Parameters (quarterly calibration)
beta=0.99;                    % discount factor
alpha=0.33;                   % elasticity of production wrt capital
epsilon=6;                    % elasticity of substitution btw differentiated goods
delta=0.025;                  % depreciation rate
sigma=2;                      % relative risk aversion
phi=1;                        % inverse of Frisch elasticity
g=0.2;                        % share of public spending in ss
chi=0.972;                    % survivial rate of bankers
QE=0.1;                       % share of public assets over total bonds
D=0.25;
eta=1.5; 
gamma=0.3;                    % trade openness
%% Steady State
pi=1;                        % inflation targeting (quarterly calibration)
yH=1;                       % domestic output
d=4*D;                       % foreign debt
h=1/3;                       % hours of work
sp=0.0025;                   % credit spread
lev=4;                       % leverage
rr=1/beta;                   % real interest rate
r=pi/beta;                   % nominal interest rate
q=1;                         % marginal value of investment (in terms of lambda)  
rb=rr+sp;                    % loan rate
rk=rb-(1-delta);             % rental rate of capital
mc=(epsilon-1)/epsilon;      % real marginal costs
k=alpha*mc*yH/rk;             % capital
w=(1-alpha)*mc*yH/h;          % real wage
i=delta*k;                   % investment
c=yH-i-g-d*(1/beta-1);       % consumption
lambda=c^(-sigma);           % marginal utlity of consumption
a=yH/(k^(alpha)*h^(1-alpha)); % tfp
kappaL=w/(h^(phi));          % labor preference parameter
bP=QE*k;                     % public assets
bF=k-bP;                     % bank assets
n=bF/lev;                    % net worth
dF=bF-n;                     % deposits
iota=n*(1-chi*(sp*lev+rr))/bF;  % tranfer to new bankers
nu=(1-chi)/(1-chi*beta*(sp*lev+rr)); %bank discount factor
theta=nu/lev+beta*nu*sp;     % fraction of divertable assets
pH=1;                       % domestic price
s=1;                        % real FX rate
gammaz=1-(1-gamma)*(c+i)-g; % foreign parameter

%% Steady-state values
gss=g;
ass=a;
piss=pi;
rss=r;
spss=sp;
bPss=bP;
dss=d;
%% Parameters not affecting the steady state
phipi=1.5;                % mp response to inflation
phiy=0.125;               % mp response to output
phiqe=0;                  % qe response to spread
kappaI=2.48;              % investment adjustment cost (as in CEE). If 0, q is constant
rhoa=0.9;                 % tfp persistence
rhog=0.9;                 % public spending persistence
rhop=0.9;                 % foreign mp shock persistence
rhom=0.8;                 % monetary policy inertia
rhoqe=0.9;                % qe inertia
rhos=0.66;                % capital shock persistence
calvo=0.66;               % price rigidity in calvo framework
% adjusment cost coefficient to have the same linear Phillips Curve of the Calvo framework
% complicated
kappaP=(epsilon-1)*calvo/(piss^2*(1-calvo)*(1-beta*calvo)); 
kappaD=0.001;             % usually calibrated at a small value. If 0, the model has a unit root
phie=0;  
rhoy=0.9;                 % foreign demand shock persistence persistence
%% Save parameters
save par_gk beta alpha delta sigma phi gss ass kappaL piss rss epsilon chi theta D...
     iota spss nu bPss phipi phiy phiqe kappaI rhoa rhog rhom rhoqe rhop rhos rhoy

