Page 1 of 1

Matrix must be positive definite.

PostPosted: Thu Oct 29, 2009 1:08 pm
by qibster
Hi,

I wanted to thank you for answering my post earlier his month. It worked perfectly once I followed your advice.

I am continuing to run Bayesian Estimation for my model and have run into another issue which I would appreciate some guidance on.

It seems that when I try an estimate one of the parameters in particular I generate the following error message:

"??? Error using ==> chol
Matrix must be positive definite.

Error in ==> metropolis_hastings_initialization at 52
d = chol(vv);

Error in ==> random_walk_metropolis_hastings at 43
[ ix2, ilogpo2, ModelName, MhDirectoryName, fblck, fline, npar, nblck, nruns, NewFile, MAX_nruns, d ]
= ...

Error in ==> dynare_estimation_1 at 940
feval(options_.posterior_sampling_method,'DsgeLikelihood',options_.proposal_distribution,xparam1,invhess,bounds,gend,data);

Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});

Error in ==> bank_model_2009_bayes_7 at 524
dynare_estimation(var_list_);

Error in ==> dynare at 102
evalin('base',fname) ;"

I was wondering if I could get some information on what this message is relating to. For instance which matrix is being referred to? Is it the var-cov matrix used for drawing parameters from the distributon during the MH iterations? Is this something that usually happens, i.e. even though the model solves with the given value of a parameter, once you try and estimate this parameter (using the same initial value as a prior) then the Bayesian estimation can break down?

I hope my questions make sense, and any guidance on what could be causing this error would be much appreciated.

Kind regards,

Aqib

Re: Matrix must be positive definite.

PostPosted: Sat Nov 28, 2009 8:27 pm
by pakocica
Dear Aquip,

you are almost right about the matrix vv. According to the source code, vv should be the posterior covariance matrix at the mode. I guess two possible sourced of this error:
1. Your priors are too narrow, so that during the random walk or during the maximum likehood searching there is a step which is relatively big. Consequently you can easily run out of the stable "area" (in the parameters space).
2. You might use old mode file with wrong values. Thus you calculate the parameters covariance at the wrong "place".

That is all I can help you without knowing your code. If you send me your code, I will try my best to help you. I am a student of mathematics, so you don't need to worry that I should abuse your model or data.

Best,

Pavel

Re: Matrix must be positive definite.

PostPosted: Sat Nov 28, 2009 10:45 pm
by pakocica
To be more exact, the matrix vv is the inverse matrix to the hessian matrix which composes of the second order partial derivatives. See the function hessian.m. The hessian is positively definite if and only if it's inverse matrix vv is so. The hessian can happen to be negative in the case that the estimated posterior variance of the parameter is 0. Check the tabular RESULTS FROM POSTERIOR MAXIMIZATION if there is not zero in the s.d. column. Ideally share this tabular with me.

Best,

Pavel