Kalman Gain

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.

Kalman Gain

Postby bigbigben » Fri Oct 08, 2010 11:59 am

Hi, guy:

I am a novice in using Bayesian or MLE to estimate DSGE models. There is a very practical question: when using Kalman filter to compute the log likelihood, is it better to keep the Kalman gain fixed or keep updating with new observations when doing estimation. I wrote the code myself, but the computed likelihood is really small, i.e, a huge functional value when using csminwel to find the minimizer. I attached my code to use Kalman filter computing the log likelihood here. Any suggestion or comments is highly appreciated. The code is written following Ferandez-Villaverde et al (2007 AER, the ABCD paper). My Q,U, W,Z are corresponding to their A, B, C and D.
Attachments
kalman_quwz.m
(1.89 KiB) Downloaded 88 times
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Kalman Gain

Postby jpfeifer » Mon Nov 08, 2010 10:03 pm

Given that the Kalman-Filter in its formulation with the gain matrix being updated each period is optimal for the class of problems considered (linear and normal error terms), there is no reason for not updating it. Not doing so would omit valuable information for the state prediction.
------------
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: Kalman Gain

Postby bigbigben » Tue Nov 09, 2010 12:20 am

Dear jpfeifer:

Thank you for the clarification. My thought is the same, but I am not sure. In the version of code I attached, I have the check of semi-positive definiteness, i.e, I check if eiven eigenvalue of the forecast error variance matrix is a positive real number or not. If not, I reset the value of the matrix to be an identity matrix. If I remove this check, the Kalman filter code can give me log-likelihood function at a similar magnitude as Dynare gives after dozens of iteration. I don't know if this move is legitimate, since a new problem pops out: the search algorithm occasionally give me complex parameter values or NaN etc. I don't know how to control this issue.

Thanks for your help again.

Best
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Kalman Gain

Postby jpfeifer » Tue Nov 09, 2010 7:08 am

Having a non-positive definite forecast error variance may be a numerical problem or might indicate a problem with your code. We sometimes encountered the same problem if the matrix is badly conditioned. However, in this case, we do not reset the matrix but discard the draw because the results will be wrong in any case. Hence, we added check

Code: Select all
if det(sigma)<0
            loglik=Inf;
            return
end

to the Kalman-Filter before the matrix is inverted.
------------
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


Return to Dynare help

Who is online

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