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.;
// 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.;
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.;
My initial state (the coefficients) is
x_init[0] = 1.63684;
x_init[1] = 2.02357;
x_init[2] = -0.0381261;
with the covariance matrix X being 0.
Now, when I run the first predict-update-observe sequence, feeding it the
observed value 285.35 (the multiple regression model would at this point
quite inaccurately predict 153.944), I get the exception:
Initial [3](1.6368,2.0236,-0.0381) ***
[3,3]((0.0000,0.0000,0.0000),(0.0000,0.0000,0.0000),(0.0000,0.0000,0.0000))
Predict [3](3.6223,0.0000,0.0000) ***
[3,3]((0.0000,0.0000,0.0000),(0.0000,0.0000,0.0000),(0.0000,0.0000,0.0000))
terminate called after throwing an instance of
'Bayesian_filter::Numeric_exception'
what(): S not PD in observe
What does it mean and how can I avoid it? Is my choice of the Simple
example as the basis for my model appropriate?
Regards,
Jan Ploski
|