# Bayesian Estimation Help

Dear Johannes,

I am trying to learn how to do Bayesian estimation and to replicatie a prototypical NK model as found in Lubic and Schorfeide (2004) for the determinate version of their model. I have been able to successfully replicate the estimation for the determinate model in DYNARE. Now I am trying to do the same thing by writing up the codes in MATLAB and do the estimation manually myself in MATLAB without using DYNARE.

I have got stuck at some point while doing the posterior kernel optimization for finding the mode.

Will you be willing to have a look at my codes and perhaps suggest me what I am doing wrong? If you agree to have a look at my MATLAB codes at your convenience, I will post them.

Thanks.

Regards,
Qazi.

I cannot guarantee that I will find the time to look at this. Could you please provide more details on the problem you encounter?

Hi Johannes,

When I try to do the log posterior kernel minimization by running the file ‘candidate.m’ by using csminwel, I get stuck since the log(prior) turn out to be (-ve) infinity and so the log(posterior kernel) becomes (-ve) infinity and the posterior mode ends up being weird and the hessian not being positive definite at the mode. My best guess is that the trouble is arising from incorrect re-parametrization, however, I couldn’t still fix it after trying different forms of re-parametrization. I have attached a zip file named ‘Bayesian LS’ containing the matlab codes used. Much of these codes are borrowed from Schorfeide’s webpage.

The starting values I use for the csminwel are the modes obtained from running the estimation in DYNARE. The mode values from DYNARE using mode_compute = 4, ie, csminwel, for the Lubic and Schorfeide (2004) parameters are as follows:

psi1 = 2.1700
psi2 = 0.2208
rhoR = 0.8467
piestar = 3.4212
rstar = 3.0202
kappa = 0.5262
Tau = 1.7690
rhoG = 0.8283
rhoZ = 0.8593
rhoGZ = 0.3355
sigmaR = 0.1667
sigmaG = 0.1711
sigmaZ = 0.6030.

Please download the zip file and run the m file ‘candidate.m’ at your leisure. Then you will perhaps realize the problem I am encountering. I believe there is some subtle issue in the coding that’s creating the problem which I am not being able to figure out.

Any help in fixing the problem would be much highly appreciated.

Thanks a bunch.

Sincerely,
Qazi.

P.S. Sorry for the lengthy post. I had to describe what’s going on for the purpose of clarification of my issues.
Bayesian LS.zip (36.9 KB)

Hi Johannes,

I was wondering whether you have any clue of what I am doing wrong as stated in my previous post.

Thanks.

I will try to have a look at it. But this will require more time than I have in the next days. Have you checked whether your code and Dynare provide the same likelihood for the same data and parameter values for determinacy?

Well, this is still actually the problem I am encountering while trying to estimate the determinate model, so these codes are trying to estimate the determinate version of Lubic and Schorfeide (2004). Since I got stuck into this, I haven’t been able to proceed and write up the LRE solution for indeterminacy.