Re: [Bayes++] S not PD in observe
Brought to you by:
mistevens
From: Michael S. <ma...@mi...> - 2008-10-16 16:14:38
|
Hi Jan, On Thursday 16 October 2008, Jan Ploski wrote: > Hi, > > I'm trying to use Bayes++ to implement a linear Kalman filter which > improves the coefficients of a linear multiple regression model (z(k) = > b0(k) + b1(k)*x1(k) + b2(k)*x2(k)) as new data (y) comes in incrementally. > The initial coefficients b0, b1, b2 which the filter's state represents > are computed based on a set of historical data. On input, I have as new > "observation" the actual measured scalar value z(k), and also the values > of the 2 independent variables (3 if you also count the constant term) > with which my regression model works. I suppose I should put these values > into Hx before each observe step. For my initial tests, I started with the > Simple example and parametrized it as follows: > > Linear_predict_model(3,3) with > // identity > Fx(0,0) = 1.; > Fx(0,1) = 1.; > Fx(0,2) = 1.; I suspect you want the identity matix here Fx(0,0) = 1.; Fx(1,1) = 1.; Fx(2,2) = 1.; The coefficients predicted value is there previous values. > // no noise in process step from k->k+1 > q[0] = q[1] = q[2] = 0; > G(0,0) = 1.; > G(1,1) = 1.; > G(2,2) = 1.; OK > Linear_uncorrelated_observe_model(3,1) with > Hx(0,0) = 1; // constant term > Hx(0,1) = 77; // value of independent variable x1 > Hx(0,2) = 92; // value of independent variable x2 > // no noise in observation > Zv[0] = 0.; Hmmm... but I suspect there really if noise in the observation and you should model this to get correct answers > My initial state (the coefficients) is > x_init[0] = 1.63684; > x_init[1] = 2.02357; > x_init[2] = -0.0381261; OK > with the covariance matrix X being 0. This is where things go really wrong. > What does it mean and how can I avoid it? The excpetion 'S not PD in observe' tells you that you have done something numerically and in this case mathematically wrong. You have setup a system where the state has no uncertainty: Fx. X. Fx' + G.q.G' = 0 and also the observation has no uncertainty: Z = 0 This is not possible! To get started you will need to place some initial uncertainty in X. After that you will also need to guess what the noise is in observed variable. You will then have a solvable problem. The better you guesses of these noises the better the solution will be! > Is my choice of the Simple > example as the basis for my model appropriate? Yep no problems. Hope that helps a bit. One thing I find useful is to write out the Kalman filter equation for s 1D problem so there a no maticies to confuse things. That way you can get some idea of how state uncertainty X, prediction noise Q, and observation noise Z effect the result. All the best, Michael -- ___________________________________ Michael Stevens Systems Engineering 34128 Kassel, Germany Phone/Fax: +49 561 5218038 Navigation Systems, Estimation and Bayesian Filtering http://bayesclasses.sf.net ___________________________________ |