Bayesian Estimation of NK Model from Herbst and Schorfheide Ch 1 & 2


#1

Dear All,

I’m a novice at Bayesian estimation in Dynare, and I thought as a simple first step I would try to replicate the model from Chapter 1 of the Herbst and Schorfheide book, “Bayesian Estimation of DSGE Models”. I wrote up the mod file of the linearized model, and the impulse response functions seem to match very well the IRFs in the book. This is just a simple 3 equation model, with an Euler equation, Phillips curve, and monetary policy rule.

The problem starts when it comes to the estimation. As a simple first step, before trying to estimate the model on actual data, I generate simulations from the solved model and do a Bayesian estimation of the simulated data.

Unfortunately, the estimation does not seem to run – or when I make changes to get it to run, the results look weird. In my initial estimation attempt, I get the following error message:

“Error using chol Matrix must be positive definite.”

Searching the forum, people suggested using the option “mode_compute=6,prior_trunc=0”. When I used this option the simulation did run, but the posteriors looked way off.

My questions are thus as follows:

(1) Can anyone see if there is an error in the way I have set up the model or estimation? Because the IRFs seem to match the book it would seem that the model is set up correctly. Perhaps the error is with the way the observation equations are set up? Or with the priors?

(2) Can anyone point me to some code for a simple estimation of the NK model? In this way I could work from this to try and find my error.

I have attached the mod file that performs the estimation here. Please let me know if you have any questions, and thank you.

Jake

nk_loglin.mod (4.2 KB)


#2

Don’t substitute AR process into Dynamic IS equation and NKPC.
In addition, I can’t understand your observation equations.

The modified code in attachment worked well.

Best wishes!

HS_nk_loglin.mod (4.4 KB)


#3

Dear Wenddy,

Thank you so much for your help. The code that you added works well.

My question remains, however, why the original code did not run. It turns out the code runs fine with my original IS equation. The crux of the matter is the code breaks down once I insert the measurement equations. These are the exact equations seen on page 19 of the Herbst and Schorheide book. Does anyone know why these measurement equations make the code break down? See attached the non-working code.

All the best,

Jake

[name=‘Output observed’]

y_obs = gammaq + (y - y(-1) + z);

[name=‘Inflation observed’]

infl_obs = pia + 4*infl;

[name=‘Interest observed’]

R_obs = pia + ra + 4gammaq + 4R;

HS_nk_loglin.mod (4.4 KB)


#4

What do you mean with “breaks down”. First of all, there is an identification problem in the model:

Testing prior mean
  
WARNING !!!
The rank of H (model) is deficient!


    [psi2,psi1] are PAIRWISE collinear (with tol = 1.e-10) !


WARNING !!!
The rank of J (moments) is deficient!


    [psi2,psi1] are PAIRWISE collinear (with tol = 1.e-10) !

Moreover, the prior may be problematic, because it is quite tight for the mean, pushing the model to have a unit root to explain the different mean in the observables.


#5

By “breaks down” I should have said “gives strange results”. In particular, the code as written gives very strange posterior results, which are not similar to the results from the original book.

Ah, yes, there is an identification problem! It seems that the model in the book is the same as the one in An and Schorfheide (2007), and there has been discussion previously that this model is not identified. See for example, the thread Identification problem of Taylor rule coefficients! , and there is also a discussion about this by An and Schorfheide (https://cpb-us-w2.wpmucdn.com/web.sas.upenn.edu/dist/e/242/files/2017/04/er-rejoinder-final-15j9hdj.pdf), as well as Mutschler (2015) (https://www.sciencedirect.com/science/article/pii/S0165188915000731).

This is a little frustrating, as I would think a model used to introduced Bayesian methods in a textbook wouldn’t have this problem.

I think I will probably move on from this model for now.