SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
gillws
Topic Author
Posts: 3
Joined: July 2nd, 2012, 6:17 pm

Kalman Gain

July 3rd, 2012, 2:07 pm

Hi,I am working on a simple kalman filter. To know how good the filtering is done, I look at the innovations and Kalman gain. The question is : even when the Gain converges it does not converge to zero (which indicates less adjustments in the model) rather goes negative which is strange. Is this is a good thing ? Can a Kalman gain have a negative value & why ?gillws
Last edited by gillws on July 2nd, 2012, 10:00 pm, edited 1 time in total.
 
User avatar
OOglesby
Posts: 42
Joined: August 26th, 2011, 5:34 am

Kalman Gain

July 4th, 2012, 4:52 am

For a simple linear Kalman filter, I do not think the magnitude of the Kalman gain should ever be < 0. For reference the Kalman filter uses the following equations:The Kalman gain is the ratio of two positive quantities. A negative gain can result if two conditions are met:1. The correction equation yields a negative covariance (i.e. )2. If your filter uses only scalars, then you probably want to increase the value of Q given in the prediction equations. If your filter works with vectors and matrices, then you might have numerical issues due to round off error, truncation error, or numerical instabilities when calculating the Kalman gain. Other possibilities include an incorrect system model, measurement model, or bugs in the Kalman filter implementation.Hope this helps.
 
User avatar
gillws
Topic Author
Posts: 3
Joined: July 2nd, 2012, 6:17 pm

Kalman Gain

July 4th, 2012, 8:58 am

Many thx ! I work with matrices (state vector dimensions 2x1 and measurement matrix D: 40x(7:22)) and the model is built with Kalman smoothing with random initialising. Also the model does not work so well with high dimensions (22) but better with lower dimensions (7) and best with more samples (>>40). As the state matrix (\Phi ) has complex eigenvalues, is it possible that this leads to instability and hence the negative gain? Adding a small quantity of Q here solves the problem but the Gain converges to a much higher value.
Last edited by gillws on July 3rd, 2012, 10:00 pm, edited 1 time in total.
 
User avatar
Amin
Posts: 2515
Joined: July 14th, 2002, 3:00 am

Kalman Gain

July 4th, 2012, 2:01 pm

The fundamental principle behind Kalman Filter is that if we have two gaussians (or two sets of gaussians), we can easily find conditional mean and variance of one given the observation of the other gaussian if we know their variances and covariances. This is a very simple concept but extremely powerful in some applications. I will like to remind that Brownian Bridge also is derived from the same conditional Gaussian lemma. Once you know the original idea, you can easily construct Brownian Bridging in as many dimensions as you like. Linear least squares regression also follows the same lemma.Kalman gain is ratio between covariance of two gaussians and the variance of the gaussian observed. As OOglesby pointed out, both are positive quantities so their ratio has to be positive. In higher dimensions the scalar values of variances and covariances are replaced by respective matrix counterparts.
Last edited by Amin on July 3rd, 2012, 10:00 pm, edited 1 time in total.
 
User avatar
OOglesby
Posts: 42
Joined: August 26th, 2011, 5:34 am

Kalman Gain

July 4th, 2012, 6:43 pm

Q effectively sets a floor and the covariance is not allowed to shrink smaller than that floor. Q is also a trade-off between the smallest allowable covariance and the amount of smoothing that occurs. Therefore, a large Q will give a larger covariance at convergence, but will perform less smoothing. Less smoothing means the measurements effect the state more; hence, a larger Kalman gain.Quoteyou can easily construct Brownian Bridging in as many dimensions as you like[\Q]Amin, would you please elaborate more on this? I know the filter can be derived using statistics and probability theory, but I have never used/understood that viewpoint.
 
User avatar
OOglesby
Posts: 42
Joined: August 26th, 2011, 5:34 am

Kalman Gain

July 4th, 2012, 9:09 pm

Quotestate matrix (\Phi ) has complex eigenvaluesAll my experience with physics-based models. I am sure the eigenvalues related to the stability of the system, but I do not know how.QuoteAlso the model does not work so well with high dimensions (22) but better with lower dimensions (7)In my experience, Kalman filters converge more slowly with higher dimensions. A statistically correct initialization can speed convergence, but unless all the state variables are observable, convergence will be slowed.Another important question: Is system model (Phi) and measurement model (H) linear? If one or both are non-linear, then the filter is no longer guaranteed to converge, and you can experience instabilities. Inflating Q can help combat this, but these types of filters may need more sophisticated equations (such as an Unscented Kalman filter or an Iterated Extended Kalman filter).Since you are working with matrices, there are some numerical methods that will help with stability.The first "trick is to use the Joseph form for updating the corrected covariance. This method ensures that the corrected covariance retains its symmetric positive-definite properties. The equations are:The next item is to use the Cholesky decomposition to factorize . Then use a linear system solver to compute the gain. This method should be more numerically stable than using the inverse and more computationally efficient.
 
User avatar
gillws
Topic Author
Posts: 3
Joined: July 2nd, 2012, 6:17 pm

Kalman Gain

July 5th, 2012, 8:20 pm

Fantastic ooglesby! That answers everything! I think the system might not be that linear as I formerly thought and I might need to try an extended Kalman filter.Many thanks again
 
User avatar
chocolatemoney
Posts: 322
Joined: October 8th, 2008, 6:50 am

Kalman Gain

July 5th, 2013, 4:54 am

Hi, I'd like to revive this great thread with a question:Andrew Burgess in his PhD thesis (A Computational methodology for modelling the dynamics of Statistical Arbitrage, http://www.wilmott.com/attachments/Burg ... Thesis.zip) describes on page 134 how to set-up a KF for adaptive regression. It is not clear to me how to configure the process and measurement noise. I don't fully understand how he does the trick. How would you set up the process and measurement noise? Could you point me to the right direction? Thanks!
 
User avatar
chocolatemoney
Posts: 322
Joined: October 8th, 2008, 6:50 am

Kalman Gain

July 12th, 2013, 2:52 pm

I wanted to share this PhD dissertation: Yalcin Bulut, "Applied Kalman Filter Theory" (http://iris.lib.neu.edu/cgi/viewcontent ... l_eng_diss)I found it interesting and easy to follow.
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On