I am trying to plot/replicate the figure 1 (see the attached PDF file) based on the Gali(2008)'s New Keynesian Model. Unfortunately, I am unable to get the graph that “Output stays at this higher level for 20 quarters before falling back to steady state in quarter 21”. I have uploaded the code, can you help with it?

I modified the monetary policy rule in your Gali (2008) code . In Mckay et al (2016)’ s paper, they applied an exogenous rule ‘real interest rate = natural rate +future monetary shock’. I replaced Taylor rule in Gali (2008) by ‘r_real=r_nat+ eps_nu(-20)’ in dynare, and got the error ‘blanchard kahn conditions are not satisfied: indeterminacy dynare’. Then, I used ‘r_real=r_nat+phi_pi*pi+eps_nu(-20)’ instead. The model is solved, but I can’t get the IRF of output to a 1 quarter drop in the real interest rate 20 quarters in the future as same as the Figure 1 In Mckay et al (2016)’ s paper. More specifically, I can’t plot the IRF figure that “real interest rate does not change until 20 quarters later, output jumps up by a full 1 percent immediately. Output then stays at this higher level for 20 quarters before falling back to steady state in quarter 21”.

You should work in a perfect foresight context. Only there you can implement the interest peg without worrying about indeterminacy. If you want to use stochastic simulations, you need to use the Taylor rule mentioned in the paper. But the problem is figuring out the sequence of \tilde \epsilon_{t,t-j}, which is different from \varepsilon_{t,t-j}. See footnote 5.