Solved – Kalman filter transition matrix

forecastingkalman filtertime series

Hi guys I am trying to writ e a code on python to correct forecast data using Kalman Filter.
I am following the equations and recommendations in this link : http://www.swarthmore.edu/NatSci/echeeve1/Ref/Kalman/ScalarKalman.html.
At some point, I have written a function which satisfies me since I don't know whatsoever how to use the pykalman module to correct estimations.
I am using just one parameter (unidimensional and univariate time series), so my matrices form will be a numerical value.
My main problem is what is the transition matrix? In many paper they just use a transition matrix of 1 but I think this is not rigorous since it would mean that:
forecast(t) = A * forecast(t-1)
We do not have a constant value of forecast so what would be my transition matrix?

Hypothesis 1:
Can I just try to see a correlation coefficient between two estimated values then take the mean of those coefficients for my first day of forecast.By the way this transition matrix will be just an initialization and will change for each forecast following

Best Answer

The transition matrix relates state t and state t-1.

If we write the temporal coherence equation like this

$$ x_t = \Psi x_{t-1} + \epsilon_p $$

This is the temporal model. This model tells you what is the tendency of your system. When no measurement is found, the system will follow this tendency. When it is found, there is a trade-off between where the measurement says the track should go and where the temporal model says it should go.

$\Psi$ is the transition matrix then.

You can have different types of transition matrix, for instance, temporal brownian motion, where $\Psi = I $, meaning that the next state is the last one plus some noise.

Another possibility would be constant velocity.

Imagine an easy example in 1d. We are tracking the position of an object and its velocity. It is just the same equation as above, in this particular case.

$$ \begin{bmatrix} x_t\\ vel_t \end{bmatrix} = \begin{bmatrix} 1 & 1\\ 0 & 1 \end{bmatrix} \begin{bmatrix} x_t\\ vel_{t-1} \end{bmatrix} + \epsilon_p $$

Then, if you multiply terms, you get

$$ x_t = x_t + vel_t + \epsilon_{p,x}$$ $$ vel_t = vel_{t-1} + \epsilon_{p,vel}$$

This example would be, as the second equation tells us, a constant velocity model.

If you still have doubts, there is a nice explanation of Kalman Filter here: http://web4.cs.ucl.ac.uk/staff/s.prince/book/book.pdf Chapter 19.

Related Question