1

I am trying to use a Kalman Filter to estimate parameters, using PyKalman, I am having a problem with the transition matrix estimate. It always returns 1.0. See this trivial example:

from pykalman import KalmanFilter

N = 1000
a = 0.05
sims = []

v = 1

for t in range(N):
    v *= a
    sims.append(v)

kf = KalmanFilter(n_dim_obs=1, n_dim_state=1,
                  em_vars=['transition_matrices'],
                  initial_state_mean=[1],
                  transition_covariance=[0.0],
                  transition_offsets=[0],
                  initial_state_covariance=[0.0],
                  observation_matrices=[1],
                  observation_covariance=[0],
                  observation_offsets=[0])

emres = kf.em(sims, n_iter=10)

print "alpha: {}".format(emres.transition_matrices[0, 0])


>>> alpha: 1.0

The observations are identical to the latent state variable, as indicated with the observation matrix, and the noise covariances are all 0. Likewise, the state variable is simply mulplied by alpha each iteration, yet the model fits 1.0 for alpha. What could be going on here? I was able to fit the covariances in other examples, only the transition matrix cannot be fit.

The Dude
  • 330
  • 6
  • 16
  • Looking at the code, it looks like it first filters and then smooths the data, so it will use whatever transition matrix you give it (1 if unspecified, as in this case). Then it applies the EM algorithm to the smoothed data. Then the EM algorithm must fit this transition matrix because your data uses the default transition matrix. Seems like the code isn't correct. – The Dude Aug 22 '17 at 18:13
  • So it looks like some amount of noise is required to estimate this parameter, working now. – The Dude Aug 23 '17 at 12:17

0 Answers0