# Optimal QE policy

Hi,

I am trying to replicate Karadi and Nakov (2021 JME) . I am particularly interested in replicating how they solve the optimal policy with perfect-foresight, for example, Figure 3 in the paper.

I am attaching the two code for computing the steady-state and then for solving the Ramsey problem compute_ss.mod and compute_dynamic.mod with other auxiliary files. These are modified codes just for this exercise based on the sample codes available here. Dynare says it can’t find the solution. When you get a chance, would you mind taking a quick look to see if I am doing it correctly?

Thank you so much!
Min

declaration.mod (676 Bytes)
initval.mod (703 Bytes)
equations.mod (4.0 KB)
calibration.mod (1.8 KB)
compute_dynamic.mod (401 Bytes)
compute_ss.mod (239 Bytes)
constraints.mod (66 Bytes)
planner.mod (166 Bytes)
shocks.mod (70 Bytes)

What exactly did you change? Do the original codes run properly?

Hi @jpfeifer, thanks for your reply! The original code was also for policy rule for QE with nonnegativity constraints using immcp. This part works fine. In order to solve Ramsey problem, as I understand, one has to comment out those together with policy variables. That was all I did.

So you are trying Ramsey without a non-negativity constraint?

I am trying to solve it with nonnegativity constraints (more precisely, inequality constraints) imposed by ramsey_constraints block in constraints.mod, instead of having equations for policy variables (e.g., monetary rule) with a tag of mcp in the model block.

One thing is that when I set parameter \tau_{b2}=0 (no cost in QE case indicated as red dotted line in Figure 3), dynare finds the solution, although it displays a warning Warning: Matrix is singular to working precision. Why do I get these warnings by the way?

Dynare can’t solve the problem with a little bit of positive value for \tau_{b2}=1e-5 (black line in Figure 3) as in the files that I posted. Do you think having longer periods in perfect_foresight_setup would solve this problem?

It seems the constraint is too close to the steady state values. I tried the following sequence to move closer to the solution:

RAMSEY_CONSTRAINTS;
ir > (1-1e-3);
Gamma > (0-1e-3);
lambda > (0-1e-3);
END;

perfect_foresight_setup(periods=200);
perfect_foresight_solver(lmmcp);

rplot ir, Gamma, lambda ;

RAMSEY_CONSTRAINTS;
ir > (1-1e-4);
Gamma > (0-1e-4);
lambda > (0-1e-4);
END;

perfect_foresight_solver(lmmcp);

RAMSEY_CONSTRAINTS;
ir > (1-1e-5);
Gamma > (0-1e-5);
lambda > (0-1e-5);
END;

perfect_foresight_solver(lmmcp);


It fails in the last step.

Oh I see, that was the problem. Thank you so much for your kind help!!!