# Kalman filter parameter estimation

From what I've known about Kalman filter, it requires all the parameters of the underlying state space model. Say the state space model is: $$\xi_{t+1} = F\xi_t + v_{t+1}$$ $$y_t = H\xi_t + w_{t}$$ where $$v$$ and $$w$$ are disturbances. Kalman filter needs the $$F$$, $$H$$, $$Q$$ (the covariance matrix of $$v$$) and $$R$$ (the covariance matrix of $$w$$) as well as $$\xi_1$$ as the initial state and the corresponding $$P_1$$ (the mean squared error of $$\xi_1$$) to start the recursion. However, these parameters generally have to be estimated by numerical methods. Assume $$y_t$$ is Gaussian, how can the $$H$$ be estimated if we don't have any external knowledge about $$\xi_t$$? Alternatively, if we have some external knowledge of $$H$$, the estimation of all the parameters can be proceeded as well. What is the general rule to determine the initial parameter values or the state vector if we don't have any external knowledge?

• H is known/set/measured exactly/pre-specified, not estimated; it's part of your model. It's akin to the predictors in a regression model in that sense (and in some state space models, that's what it is). – Glen_b May 21 at 23:11
• @Glen_b Hello Glen_b, thank you for your reply. Do you mean that prior knowledge of H is a must for state space model formulation? – Seymour May 22 at 5:18
• In the usual state space model, the only things that are to be estimated are the state and its variance-covariance matrix (and, arguably, the error terms); perhaps missing y's if you have some of those. – Glen_b May 22 at 6:50
• @Glen_b Thank you very much for the answer! I started to learn the Kalman filter without any prior experience about the state space model. Maybe I have to go it through first. – Seymour May 22 at 7:03

Everything you will ever need regarding estimation of parameters in a state space model is in this document:

Kalman Filter/Smoother assumes that the parameters are known in advance so that the unobserved state can be estimated. The initial values for the state can be user supplied or a diffuse initialization approach can be used.

For this the standard reference is:

https://www.amazon.com/Time-Analysis-State-Space-Methods/dp/019964117X

For the matrix parameters and noise co-variance estimation the standard procedure is Expectation Maximization which is described in detail in the first reference, and also in

https://www.stat.pitt.edu/stoffer/tsa4/tsa4.pdf

chapter 6.

• Hi Cowboy Trader. Thank you for your info. I want to clarify my question a bit. I have read through the Kalman filter chapter of Hamilton (1994)'s textbook. He mentioned the estimation procedure with numerical methods (say Newton). One could firstly assign arbitrary parameter values and iterate the Kalman filter. With the obtained state vector, one then could in turn estimate the parameter values and check the corresponding likelihood. This process ends at the trivially changing parameter values. – Seymour May 22 at 15:35
• My questions are: Do you agree with the point that Hamilton's procedure is unrealistic or won't converge in a general sense? If you do, can you explain concisely how to determine the initial values in a general sense (without any external knowledge) if there're any. (Since it is general, I believe it doesn't require too much words to explain it.) Additionally, could you clarify the 'diffuse initialization approach'? – Seymour May 22 at 15:35
• Finally, I know EM is a fixed point finding algorithm although I don't fully understand the mathematics behind it. What is the advantage of EM compared with other numerical methods? Just without gradient if say Newton? I am curious because why didn't the classical time series textbooks, for example Hamilton's, Ender's and Lütkepohl's, introduce this particularly useful method? Besides, EM requires initial inputs as well which returns to the essential problem. $H$ and $\xi$, we have to have one of them to start the Kalman filter and estimation. Thank you very much! – Seymour May 22 at 15:36
• @Seymour Direct maximization of likelihood works, but on small scales. If your matrices are say 2x2, 3x3. It requires calculation of gradients. EM algorithm for Gaussian models have exact analytical solutions. Therefore iteration is more robust. All parameters can be estimated including starting value of $\xi$. Diffuse initialization is using a very large variance on prior distribution of $\xi$. – Cagdas Ozgenc May 22 at 15:55
• So the conclusion is, either I'm using EM or Newton, the initial parameter values have to be arbitrarily assigned or set with some belief right? – Seymour May 22 at 16:12

In the usual state space model, the only things that estimated is the state and its variance-covariance matrix (at each time point) - whether filtering or smoothing only changes what information you're conditioning on, but either way you end up with estimates of those things.

The $$H$$'s (and $$F$$, $$Q$$ and $$R$$ in your notation) are known/set/measured exactly/pre-specified, not estimated; it's part of your model for how observations are related to the state vector (and how state vectors evolve over time, etc).

$$H$$ is akin to the predictors in a regression model in that sense (i.e. that you don't estimate the $$X$$ matrix in regression)

• "The 𝐻's (and 𝐹, 𝑄 and 𝑅 in your notation) are known/set/measured exactly/pre-specified, not estimated" <- this isn't always true. – Taylor May 30 at 19:50
• It may be that we're interpreting "Kalman Filter" differently, but as I see it, if they're unspecified, you're not dealing with the Kalman Filter algorithm, because in that they are definitely being treated as known quantities. If they were estimated, there are terms (relating to that estimation error) missing from the variance updates. The unknowns are in the state. I have no doubt that you could write a valuable answer that expands on what exceptions specifically you mean (and - terminology aside - I expect that when we both talk about the same thing we won't substantively disagree). – Glen_b May 31 at 0:32

As mentioned in other answers, you need values for the parameters in all system matrices ($$F$$, $$H$$, $$Q$$) in order to run the Kalman filter. However, you may have a state-space model with unknown parameters that you need to estimate.

In order to do that, you may use the Kalman filter: running the Kalman filter with arbitrary values of the parameters will produce, as a byproduct, the likelihood. You can then embed the Kalman filter in an optimizing routine which tries different values so that the likelihood is maximized. Answering to other queries I have given detailed examples using package dlm in R. (Alternatives are packages MARSS and KFAS, among others.)

• @Cowboy Trader: I think it very much depends on the problem at hand (and the OM gives no details). I have used gradient-type algorithms many times with good results. EM is generally considered to be slower (and can get stuck in a local optimum, just as a surface climbing algorithm). – F. Tusell May 22 at 14:41
• @Cowboy Trader: If that means 4900 parameters unrestricted, I doubt anything will work well, unless you have oodles of data. The Kalman filter itself can cope well with missing data, whichever method you use to maximize the likelihood. – F. Tusell May 22 at 14:47
• Yes that's generally what I have learnt in Hamilton's book. However, is it really the case we can just assign arbitrary initial values given the non-robustness of multi-dimensional numerical search methods? I am looking for a general rule to determine the initial parameter values if there're any. – Seymour May 22 at 15:48
• @Seymour: I do not think you can go any further than making and educated guess. And of course the model may involve restrictions that you can exploit (like non-negativity constraints for variances, etc.). The initial values problem will exist with either gradient-climbing or EM algorithms. – F. Tusell May 22 at 17:00