[R] unexpected result from KalmanRun (KalmanLike, StructTS)

charles loboz charles_loboz at yahoo.com
Wed Nov 30 23:12:05 CET 2005

(re-formulate, re-send, without html) 

  for vector y = c(1,2,3,4,5), H = 0.66 manual
  using the equations below give a =
  KalmanRun with these parameters gives res$states =

for Kalman Filter Durbin/Koopman give at p67 eqs 
     v = y - Z a,  F = Z P Z' + H,  K = T P Z' / F +
     a[t+1] = T a + K v,  P[t+1] = T P L' + R Q R'
  for P1 = 0, Q=0,  T=Z=R=1 that reduces to:
     v = y - a,  F = H,  K = H,  a[t+1] = a + K v, 
P[t+1] = 0
     (also equivalent to exponential moving average,
Durbin/Koopman p49)
  So I am getting a serious discrepancy between manual
and KalmanRun computations. To make things more
interesting, looking into the code of arima.c we have
at line 109 an equivalent of
      a[t+1] = anew + Pnew * resid0 / gain
  where gain = mod$h = H (by line 97), resid0 = y-a =
v (by lines 94-96)
  Since Pnew = 0, then a[t+1] = a, which explains why
the computation
  returns res$states = c(1,1,1,1,1).
  The help file says "'states', the contemporaneous
state estimates",
  which I assumed to mean 'a' in the equations above.
But that
  assumption does not agree with the numerical
results. It also
  does not agree with the coding(?) as  a[t+1] = a + K
v  differs
  substantially from   a[t+1] = anew + Pnew * resid0 /
gain. (all the previous lines of coding follow the
kalman filter equations, but this one does not seem to
- do we have some strong reformulation of the
equations in the basic form?).
  So, what does 'states' contain?

More information about the R-help mailing list