%  This .mod file solves in Dynare the model from my paper ''Welfare gains from unvonventional monetary policy at the zero lower bound''
%  Linear Quadratic Approach 
%  (c) Nikolas Kontogiannis, Department of Economics, University of Leicester

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Necessary Notation:

% For any generic variable X_t:
% X_t denotes the level of variable X at time t.
% X_flext denotes the level of variable X at time t, when prices are
% flexible and output is at its natural level.
% X_ss denotes the steady state.
% X_hat = logX_t - logX_ss,
% X_flex = logX_flext - logX_ss,
% X_tilde = X_hat - X_flex, is the log-deviation from the flexible price
% equilibrium
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%% Declaration of Variables %%%%%%%%%%%%%%%%%%%%%%%%%

var
%%%%%%%%%%%%%% HATS (log-deviations from the steady-state) %%%%%%%%%%%%%%%%

R_hat % real interest rate
QNOM_hat % nominal interest rate
Pi % inflation, given in absolute deviaton from its steady-state (See Walsh chapter 2)
Phi_hat % real marginal cost
A_hat % productivity
Psi_hat % quality of capital
Spread_hat % the spread or the difference between the real interest of lending and borrowing (natural or Wicksellian rates)

%%%%%%%%% TILDES (log-deviations from flexible price equilibrium) %%%%%%%%%

Y_tilde % output
I_tilde % investment (new capital)
K_tilde % capital stock
R_tilde % real interest rate log-deviation from the Wicksellian interest
Z_tilde % gross profit per unit of capital use
Q_tilde % capital (asset) price
D_tilde % households' deposits
S_tilde % total securities issued
NW_tilde % banks' net worth (capital)
RK_tilde % real interest of banks' lending
Theta_tilde % leverage ratio, private intermediation
VD_tilde % banks' marginal value from lending
Mu_tilde % banks' excess value of lending (marginal benefit from lending - marginal cost from borrowing)
Omega_tilde % stochastic marginal value of net worth
SP_tilde % securities issued privately
SG_tilde % securities issued by government
Varrho_tilde % unconventional policy instrument
ThetaC_tilde % leverage ratio from total intermediation (private and governmental)
Spread_tilde % the spread or the difference between the real interest of lending and borrowing
KAUXLAG_tilde % auxiliary variable for capital to substitute K (-1) in the welfare criterion

% FLEXIS (flexible price equilibrium log-deviation from the steady-state)%%

Y_flex % flexible price equilibrium level of output. This is the natural level of output since the steady-state is efficient
I_flex % natural level of investment
K_flex % natural level of capital
R_flex % Wicksellian real interest rate (See Walsh chapter 8)
Z_flex % gross profits per unit of capital use
Q_flex % capital (asset) price associated with investment' natural level
D_flex % households' deposits
S_flex % total securities issued
NW_flex % banks' net worth (capital)
RK_flex % real interest of banks' lending
Theta_flex % leverage ratio, private intermediation
VD_flex % banks' marginal value from lending
Mu_flex % banks' excess value of lending (marginal benefit from lending - marginal cost from borrowing)
Omega_flex % stochastic marginal value of net worth
SP_flex % securities issued privately
SG_flex % securities issued by government
Varrho_flex % unconventional policy instrument
ThetaC_flex % leverage ratio from total intermediation (private and governmental)
Spread_flex % the spread or the difference between the real interest of lending and borrowing (natural or Wicksellian rates)
YAUXLEAD_flex
IAUXLEAD_flex;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%% Declaration of the Shocks %%%%%%%%%%%%%%%%%%%%%%%%

varexo

E_A % productivity shock
E_Psi; % capital quality shock

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%% Declaration of the Parameters %%%%%%%%%%%%%%%%%%%%

parameters

%%%% Because the model is linearised by hand, the steady-state of
%%%% the level of variables is declared as parameter. %%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%% Steady-State of levels, expressed as parameters %%%%%%%%%%%%

C_ss % consumption
R_ss % real interest rate
N_ss % labour or measure of participation to work 
QNOM_ss % nominal interest rate
Phi_ss % real marginal cost
Y_ss % output of final goods
A_ss % productivity
K_ss % capital stock
I_ss % investment (new capital)
Psi_ss % quality of capital
Z_ss % gross profits per unit of capital use 
Q_ss % capital (asset) price
D_ss % households' deposits
S_ss % total securities issued
NW_ss % banks' net worth (capital)
RK_ss % real interest of banks' lending
Theta_ss % leverage ratio, private intermediation
VD_ss % banks' marginal value from lending
Mu_ss % banks' excess value of lending (marginal benefit from lending - marginal cost from borrowing)
Omega_ss % stochastic marginal value of net worth
SP_ss % securities issued privately
SG_ss % securities issued by government
Varrho_ss % unconventional policy instrument
Spread_ss % the spread or the difference between the real interest of lending and borrowing
NWK_ss % the steady state of the ratio NW/K (useful to find the steady-state)
DK_ss % the steady state of the ratio D/K (useful to find the steady-state)
YK_ss % the steady state of the ratio Y/K (useful to find the steady-state) 
CK_ss % the steady state of the ratio C/K (useful to find the steady-state)

%%%%%%%%%%%%%%%%%%%%%%%%% Structural Parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%

beta % static discount factor
alpha % capital share
varphi % Frisch inverse elasticity of labour
delta % depreciation of capital
gamma % elasticity of substitution among the differentiated goods
delta_p % elasticity of inflation wrt the real marginal cost
M % markup
chi % parameter in convex adjustment cost function
omega % degree of nominal price rigidity, to match quarterly data
rho_a % degree of autocorrelation, productivity shock
rho_psi %d egree of autocorrelation, capital quality shock
sigma %survival rate of bankers
xi % transfer to entering bankers, perfect interbank
lambda % fraction of divertable assets

%%%%%%%%%%%%%%%%%%%%%%%%%%% Monetary Policy Parameters %%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%% Conventional Monetary Policy %%%%%%%%%%%%%%%%%%%%%%%

kappa_y % elasticity of nominal interest rate w.r.t. output 
kappa_pi % elasticity of nominal interest rate w.r.t. inflation
rho_q
%%%%%%%%%%%%%%%%%%%% Unconventional Monetary Policy %%%%%%%%%%%%%%%%%%%%%%%

%kappa_varrhoH % strength of unconventional monetary policy, the goal is the spread_hat
kappa_varrhoF % strength of unconventional monetary policy, the goal is the spread_flex
kappa_varrhoT % strength of unconventional monetary policy, the goal is the spread_tilde

%%%%%%%%%%%%%%%%%%%% Weights of the central bank's welfare criterion
%%%%%%%%%%%%%%%%%%%% (objective function) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

delta_1
delta_2
delta_3
delta_4
delta_5
delta_6
delta_7
delta_8;

%%% Declaration of the parameter and the steady-state (levels) values %%%%%
%%% Notice that the steady-state has been solved with the use of Fsolve
%%% (matlab) for another model. Since I have not changed the value of
%%% lambda, here I copy these values. IF someone wants to change lambda
%%% manually, then the Fsolve must be used to calculate the new
%%% steady-state, since the value of mu will change. Here, I choose lambda
%%% to hit a steady state of spread equal to 0.0025 (quarterly) %%%%%%%%%%%

%%%%%%%%%%%%%%%%%%% Standard NK model parameters calibration %%%%%%%%%%%%%%

beta=0.99; % static discount factor
alpha=0.33; %capital share
varphi=0; %Frisch inverse elasticity of labour
delta=0.025; %depreciation of capital
gamma=6; %elasticity of substitution among the differentiated goods (to match the markup)
M=gamma/(gamma-1); %markup
omega=0.75; %degree of nominal price rigidity, to match quarterly data
delta_p=((1-omega*beta)*(1-omega)/(omega)); %elasticity of inflation wrt the real marginal cost
chi=1; % parameter in convex adjustment cost function


%%%%%%%%%%%% Financial intermediation model parameters calibration %%%%%%%%

sigma=0.97; %survival rate of bankers
xi=0.003; %transfer to entering bankers, perfect interbank lending
lambda=0.383; %fraction of divertable assets (to hit the spread of 100 basis points)

%%%%%%%%%%% Steady-state (levels) calibration. Given as parameters as the model is log-linearised by hand %%%%%%% 

R_ss=1/beta; % the SS from euler equation. Useful to find the R_ss
NWK_ss=0.2683; % from Fsovle. See above
Omega_ss=1.4146; % from Fsolve. See above.
RK_ss=1.0126; % from Fsolve. lambda was chosen to hit the spread_ss =0.0025 quarterly
Theta_ss=3.7269; % from Fsolve;
Mu_ss= 0.0034; % from Fsolve. Notice that the expression for mu_ss is quadratic. But mu=max[>0, 0] so chose the positive value
DK_ss=1-NWK_ss; % from the ss equations of the financial intermediation
Spread_ss=RK_ss-R_ss; % chosen to hit a target of 0.0025
QNOM_ss=R_ss-1; % Fisher equation
Psi_ss=1; % steady-state of quality of capital shock
A_ss=1; % steady-state of productivity shock
Q_ss=1; % price of new-capital good (tobin's q) steady-state, calculated from capital good producers optimal decision
Phi_ss=1/M; % price flexibility value of real marginal cost (inverse of mark-up)
VD_ss=Omega_ss; % at the steady state VD = Omega
Z_ss=(RK_ss - (1-delta))*Q_ss;
YK_ss=(1/(alpha*Phi_ss))*Z_ss;
CK_ss=YK_ss - delta;
N_ss=(Phi_ss*(1-alpha)*YK_ss*(CK_ss)^(-1))^(1/(1+varphi));
K_ss=(N_ss)*(YK_ss)^((-1/(1-alpha)));
I_ss=delta*K_ss;
C_ss=CK_ss*K_ss;
Y_ss=YK_ss*K_ss;
S_ss=K_ss;
NW_ss=NWK_ss*K_ss;
D_ss=DK_ss*K_ss;
Varrho_ss=0.1;
SP_ss=(1-Varrho_ss)*S_ss;
SG_ss=S_ss-SP_ss;

%%%%%%%%%%%%%%%%%%%% Policy parameters calibration %%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%% Conventional policy calibration %%%%%%%%%%%%%%%%%%%%

kappa_pi=1.5;
kappa_y=0.5/4;
rho_q=0.2;

%%%%%%%%%%%%%%%%%%%% Unconventional policy calibration %%%%%%%%%%%%%%%%%%%%

kappa_varrhoT=100;
%kappa_varrhoH=0;
kappa_varrhoF=100;

%%%%%%%%%%%%%%%%%%%%%  autocorrelation of the shocks %%%%%%%%%%%%%%%%%%%%%%
rho_a=0.95;
rho_psi=0.66;


%%%%%%%%%%%%%%%%%%%% Calculation of the weights of the central bank's welfare criterion 
%%%%%%%%%%%%%%%%%%%%(objective function). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


delta_1 = (gamma/2)*((delta_p)/(1-delta_p));
delta_2 = (1/2)*(Y_ss/C_ss)*(((alpha+varphi)/(1-alpha)));
delta_3 = (1/2)*(I_ss*Y_ss)/(C_ss^2);
delta_4 = ((alpha^2)*(1+varphi)*Y_ss)/(2*(1-alpha)*C_ss);
delta_5 = (alpha*Y_ss/C_ss)*((1+varphi)/(1-alpha));
delta_6 = 2*delta_3;
delta_7 = (K_ss*Y_ss)/(C_ss^2);
delta_8 = (alpha*Y_ss)/C_ss;

model (linear);

%%%%%%%%%%%%%%%% Standard New Keynesian model with capital %%%%%%%%%%%%%%%%

Y_tilde = Y_tilde(+1) - (I_ss/Y_ss)*(I_tilde(+1) - I_tilde) - R_tilde; % Dynamic IS expressed in tilde

R_tilde = R_hat - R_flex;

R_flex = Y_flex(+1) - Y_flex - (I_ss/Y_ss)*(I_flex(+1) - I_flex); % Expression for Wicksellian interest rate

R_hat = QNOM_hat - Pi(+1); % Fisher equation

(((alpha+varphi)/(1-alpha)) + (Y_ss/C_ss))*Y_flex = (I_ss/C_ss)*I_flex + ((alpha*(1+varphi))/(1-alpha))*K_flex(-1) + ((1+varphi)/(1-alpha))*A_hat; % Flexible price equilibrium

Pi = beta*Pi(+1) + delta_p*Phi_hat; % New Keynesian Phillips Curve

Phi_hat = (((alpha+varphi)/(1-alpha)) + (Y_ss/C_ss))*Y_tilde - (I_ss/C_ss)*I_tilde - ((alpha*(1+varphi))/(1-alpha))*K_tilde(-1); % Link of real marginal cost with flexi price equil  

K_tilde = delta*I_tilde + (1 - delta)*K_tilde(-1); % Law of motion of capital tilde

K_flex = Psi_hat(+1) + delta*I_flex + (1 - delta)*K_flex(-1); % Law of motion of capital flexi

Z_tilde = Phi_hat + Y_tilde - K_tilde(-1);

Z_flex = Y_flex - K_flex(-1);

Q_tilde = chi*(I_tilde - I_tilde(-1)) - chi*beta*(I_tilde(+1) - I_tilde) - Q_flex + chi*(I_flex - I_flex(-1)) - chi*beta*(I_flex(+1) - I_flex) ; % Profit maximising for capital producers price

Q_flex = chi*(I_flex - I_flex(-1)) - chi*beta*(I_flex(+1) - I_flex); % Profit maximising for capital producers price

KAUXLAG_tilde = K_tilde(-1);

YAUXLEAD_flex = Y_flex(+1);

IAUXLEAD_flex = I_flex(+1);

A_hat = rho_a*A_hat(-1) - E_A; % AR(1) productivity. Notice the declaration of a negative shock

Psi_hat = rho_psi*Psi_hat(-1) - E_Psi; % AR(1) capital quality. Notice the declaration of a negative shock 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Monetary Policy %%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Conventional %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Taylor rule should be removed when calculate ramsey/discretion policy%

%QNOM_hat = rho_q*QNOM_hat(-1) + (1-rho_q)*(kappa_pi*Pi + kappa_y*Y_tilde); % Taylor rule
 
%%%%%%%%%%%%%%%%%%%%%%%%%%% FLEX Financial Intermediation %%%%%%%%%%%%%%%%%

D_flex = (Q_ss*SP_ss/D_ss)*Q_flex + (Q_ss*SP_ss/D_ss)*SP_flex - (NW_ss/D_ss)*NW_flex; % Deposits 

NW_flex = ((sigma+xi)*(RK_ss*Q_ss*SP_ss)/NW_ss)*(RK_flex + Q_flex(-1) + SP_flex(-1)) - (R_ss*D_ss/NW_ss)*(R_flex + D_flex(-1)); % Balance sheet

Theta_flex = VD_flex + (Mu_ss/(lambda - Mu_ss))*Mu_flex; % Leverage ratio (private)

VD_flex =  Omega_flex (+1);

Mu_flex = ((beta*Omega_ss*RK_ss)/Mu_ss)*(RK_flex(+1) - R_flex(+1)) + Omega_flex(+1);

Omega_flex = ((sigma*VD_ss)/Omega_ss)*VD_flex + ((sigma*Theta_ss*Mu_ss)/Omega_ss)*(Theta_flex + Mu_flex); 

S_flex = K_flex; % Equilibrium in security market 

S_flex = ThetaC_flex + NW_flex - Q_flex; 

RK_flex = Psi_hat - Q_flex(-1) + (Psi_ss*Z_ss/RK_ss*Q_ss)*Z_flex + ((1-delta)*Psi_ss/RK_ss)*Q_flex;

S_flex = (SP_ss/S_ss)*SP_flex + (SG_ss/S_ss)*SG_flex;

SG_flex = Varrho_flex + S_flex;

Spread_flex = RK_flex(+1) - R_flex(+1);

ThetaC_flex = Theta_flex + (Varrho_ss/(1-Varrho_ss))*Varrho_flex; % Leverage (Total intermediation)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Monetary Policy %%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Unconventional %%%%%%%%%%%%%%%%%%%%%%%%%%

Varrho_flex = kappa_varrhoF*(RK_flex(+1) - R_flex(+1));

%%%%%%%%%%%%%%%%%%%%%%%%%%% TILDE Financial Intermediation %%%%%%%%%%%%%%%%%

D_tilde = (Q_ss*SP_ss/D_ss)*Q_tilde + (Q_ss*SP_ss/D_ss)*SP_tilde - (NW_ss/D_ss)*NW_tilde; % Deposits 

NW_tilde = ((sigma+xi)*(RK_ss*Q_ss*SP_ss)/NW_ss)*(RK_tilde + Q_tilde(-1) + SP_tilde(-1)) - (R_ss*D_ss/NW_ss)*(R_tilde + D_tilde(-1)); % Balance sheet

Theta_tilde = VD_tilde + (Mu_ss/(lambda - Mu_ss))*Mu_tilde; % Leverage ratio (private)

VD_tilde =  Omega_tilde (+1);

Mu_tilde = ((beta*Omega_ss*RK_ss)/Mu_ss)*(RK_tilde(+1) - R_tilde(+1)) + Omega_tilde(+1);

Omega_tilde = ((sigma*VD_ss)/Omega_ss)*VD_tilde + ((sigma*Theta_ss*Mu_ss)/Omega_ss)*(Theta_tilde + Mu_tilde); 

S_tilde = K_tilde; % Equilibrium in security market 

S_tilde = ThetaC_tilde + NW_tilde - Q_tilde; 

RK_tilde = - Q_tilde(-1) + (Psi_ss*Z_ss/RK_ss*Q_ss)*Z_tilde + ((1-delta)*Psi_ss/RK_ss)*Q_tilde;

S_tilde = (SP_ss/S_ss)*SP_tilde + (SG_ss/S_ss)*SG_tilde;

SG_tilde = Varrho_tilde + S_tilde;

Spread_tilde = RK_tilde(+1) - R_tilde(+1);

Spread_hat = Spread_tilde + Spread_flex;

ThetaC_tilde = Theta_tilde + (Varrho_ss/(1-Varrho_ss))*Varrho_tilde; % Leverage (Total intermediation)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Monetary Policy %%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Unconventional %%%%%%%%%%%%%%%%%%%%%%%%%%

Varrho_tilde = kappa_varrhoT*(RK_tilde(+1) - R_tilde(+1));

end;

/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STEADY STATE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

initval;

R_hat=0; % real interest rate
QNOM_hat=0; % nominal interest rate
Pi=0; % inflation, given in absolute deviaton from its steady-state (See Walsh chapter 2)
Phi_hat=0; % real marginal cost
A_hat=0; % productivity
Psi_hat=0; % quality of capital
Spread_hat=0; % the spread or the difference between the real interest of lending and borrowing


%%%%%%%%% TILDES (log-deviations from flexible price equilibrium) %%%%%%%%%

Y_tilde=0; % output
I_tilde=0; % investment (new capital)
K_tilde=0; % capital stock
R_tilde=0; % real interest rate log-deviation from the Wicksellian interest
Z_tilde=0; % gross profit per unit of capital use
Q_tilde=0; % capital (asset) price
D_tilde=0; % households' deposits
S_tilde=0; % total securities issued
NW_tilde=0; % banks' net worth (capital)
RK_tilde=0; % real interest of banks' lending
Theta_tilde=0; % leverage ratio, private intermediation
VD_tilde=0; % banks' marginal value from lending
Mu_tilde=0; % banks' excess value of lending (marginal benefit from lending - marginal cost from borrowing)
Omega_tilde=0; % stochastic marginal value of net worth
SP_tilde=0; % securities issued privately
SG_tilde=0; % securities issued by government
Varrho_tilde=0; % unconventional policy instrument
ThetaC_tilde=0; % leverage ratio from total intermediation (private and governmental)
Spread_tilde=0; % the spread or the difference between the real interest of lending and borrowing
KAUXLAG_tilde=0; % auxiliary variable for capital to substitute K (-1) in the welfare criterion



% FLEXIS (flexible price equilibrium log-deviation from the steady-state)%%

Y_flex=0; % flexible price equilibrium level of output. This is the natural level of output since the steady-state is efficient
I_flex=0; % natural level of investment
K_flex=0; % natural level of capital
R_flex=0; % Wicksellian real interest rate (See Walsh chapter 8)
Z_flex=0; % gross profits per unit of capital use
Q_flex=0; % capital (asset) price associated with investment' natural level
D_flex=0; % households' deposits
S_flex=0; % total securities issued
NW_flex=0; % banks' net worth (capital)
RK_flex=0; % real interest of banks' lending
Theta_flex=0; % leverage ratio, private intermediation
VD_flex=0; % banks' marginal value from lending
Mu_flex=0; % banks' excess value of lending (marginal benefit from lending - marginal cost from borrowing)
Omega_flex=0; % stochastic marginal value of net worth
SP_flex=0; % securities issued privately
SG_flex=0; % securities issued by government
Varrho_flex=0; % unconventional policy instrument
ThetaC_flex=0; % leverage ratio from total intermediation (private and governmental)
Spread_flex=0; % the spread or the difference between the real interest of lending and borrowing (natural or Wicksellian rates)
YAUXLEAD_flex=0;
IAUXLEAD_flex=0;

end;

*/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SHOCKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

shocks;

var E_Psi;
stderr 0.05;

/*
var E_A;
stderr 0.00624;

var E_Psi, E_A = 1*0.05*0.00624;
*/


end;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SOLUTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OPTIMAL MONETARY POLICY %%%%%%%%%%%%%%%%%%%%%

planner_objective (delta_1*(Pi^2) + delta_2*(Y_tilde^2) + delta_3*(I_tilde^2) + delta_4*(KAUXLAG_tilde^2) - delta_5*Y_tilde*KAUXLAG_tilde - delta_6*Y_tilde*I_tilde - delta_7*K_tilde*Y_flex + delta_7*K_tilde*I_flex + delta_7*K_tilde*YAUXLEAD_flex - delta_7*K_tilde*IAUXLEAD_flex - delta_8*KAUXLAG_tilde*Y_flex + delta_8*KAUXLAG_tilde*I_flex);
                                                                                                                                                                                                                                                                                                                         
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Optimal Commitment %%%%%%%%%%%%%%%%%%%%%%%%%%%
ramsey_policy(planner_discount=0.99)Y_tilde Pi I_tilde K_tilde;
oo_.planner_objective_value
*/


%%%%%%%%%%%%%%%%%%%%%%%%%%%% Optimal Discretion %%%%%%%%%%%%%%%%%%%%%%%%%%%
discretionary_policy(planner_discount=0.99, instruments=(QNOM_hat));
oo_.planner_objective_value


/*
%%%%%%%%%%%%%%%%%%%%%%%%%% Optimal simple rule %%%%%%%%%%%%%%%%%%%%%%%%%%%%
check;
optim_weights;
Pi delta_1;
Y_tilde delta_2;
I_tilde delta_3;
KAUXLAG_tilde delta_4;
Y_tilde, KAUXLAG_tilde -delta_5;
Y_tilde, I_tilde -delta_6;
K_tilde, Y_flex -delta_7;
K_tilde ,I_flex delta_7;
K_tilde, YAUXLEAD_flex delta_7;
K_tilde, IAUXLEAD_flex -delta_7;
KAUXLAG_tilde, Y_flex -delta_8;
KAUXLAG_tilde, I_flex delta_8;
end;

osr_params kappa_pi kappa_y;
check;
osr Pi; 
oo_.osr.objective_function
%oo_.var

*/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPULSE RESPONSES %%%%%%%%%%%%%%%%%%%%%%%%
/*
check;
stoch_simul(order=1,nomoments,periods=3000,irf=40)Spread_hat Spread_tilde Spread_flex Y_tilde Pi K_tilde I_tilde SG_tilde SP_tilde S_tilde NW_tilde NW_flex D_tilde D_flex QNOM_hat Varrho_tilde Varrho_flex;
*/









