Bayesian Estimation Help

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Bayesian Estimation Help

Postby qazi.haque » Thu Mar 05, 2015 5:16 pm

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.

Looking forward to your reply.

Thanks.

Regards,
Qazi.
qazi.haque
 
Posts: 18
Joined: Thu Nov 06, 2014 11:37 am

Re: Bayesian Estimation Help

Postby jpfeifer » Sun Mar 08, 2015 8:05 am

I cannot guarantee that I will find the time to look at this. Could you please provide more details on the problem you encounter?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Bayesian Estimation Help

Postby qazi.haque » Thu Mar 12, 2015 10:56 am

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.
Attachments
Bayesian LS.zip
Description of the MATLAB files:

There are 2 main files in the folder.

1) Candidate.m : It computes the candidate density for Metropolis-Hastings algorith,
The output (MH_candidate.mat) is saved in the folder ``Datafiles".

2) MetropolisHastings.m : It runs the Metropolis-Hastings algorithm. It save the posterior draws
and logposterior density (mhdraws.mat) in the folder "Datafiles".

These files use a number of procedures collected in the folder "Matlabfiles". The most relevant files are

a) model_solution.m : Takes as inputs the vector of structural parameters. Returns the coefficient
matrices of the log-linear approximate solution of the DSGE model. Please,
refer to Sims (2002) and Lubic and Schorfeide (2003) for details on the procedure.

b) sysmat.m : Takes as inputs the solution of the DSGE model and the vector of structural parameters.
Returns the matrices for the state space representation.

c) kalman.m : Takes as inputs the state space matrices. Returns the likelihood function and the
filtered states.

d) dsgeliki.m : Takes as inputs the vector of structural parameters. Returns the value of the
log-likelihood function.

e) prior.m : Takes as inputs the vector of structural parameters. Returns the value of the
log-prior. Modify this file in case you need to change the prior distribution.


The folder contains two additional subfolders: "Rational Expectations Solution" and "Minimization Routines". These two folders collect files
to solve the linear rational expectation model and to find the posterior mode (using csminwel).
(36.86 KiB) Downloaded 54 times
qazi.haque
 
Posts: 18
Joined: Thu Nov 06, 2014 11:37 am

Re: Bayesian Estimation Help

Postby qazi.haque » Tue Mar 17, 2015 8:52 am

Hi Johannes,

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

Thanks.
qazi.haque
 
Posts: 18
Joined: Thu Nov 06, 2014 11:37 am

Re: Bayesian Estimation Help

Postby jpfeifer » Wed Mar 18, 2015 8:54 pm

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?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Bayesian Estimation Help

Postby qazi.haque » Fri Mar 20, 2015 12:30 am

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.

Thanks for your consideration. Looking forward to your response at your favorable time.

Cheers.
qazi.haque
 
Posts: 18
Joined: Thu Nov 06, 2014 11:37 am

Re: Bayesian Estimation Help

Postby qazi.haque » Mon Apr 20, 2015 4:10 am

Dear Johannes,

Just to let you know, I have figured out where I was doing wrong and I can now successfully do Bayesian estimation on my own in MATLAB.

Thanks for you consideration.

Cheers,
Qazi .
qazi.haque
 
Posts: 18
Joined: Thu Nov 06, 2014 11:37 am


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 8 guests