State Models and Kalman Filters
Developing Models for Kalman Filters
This installment will be relatively short on mathematics but relatively long on fundamental importance. Don't lose faith, though. The first step to overcoming a challenge is to identify it.
The models we have discussed so far unfortunately are not suitable for service in a Kalman Filter. They produce estimates for the dependent output variables as some kind of linear function of a set of independent input variables. That kind of model is an inputoutput or direct functional model. Such models can be very useful, but they just don't provide (exactly) what Kalman Filtering requires of them.
A sorry state of affairs
For a Kalman Filter, you need to set up a somewhat different and more specialized kind of model.

A Kalman Filter requires a dynamic model. The inputs determine updated values for variables that change dynamically.

A Kalman Filter is applied in many discrete steps representing the advance of time. (In concept, it could be some other independent variable, but in practice, it is almost always time, and this will be assumed. Historically, there was a continuoustime theory of Kalman filters that arose first, with models having the form of linear differential equations. But that was a different century, and we will limit attention to the discrete time case.)

Besides the input and output variables, Kalman Filters use an additional set of hidden internal variables called state variables where dynamic effects collect.

The state dynamics portion of the Kalman Filter produces no outputs. It only calculates adjustments to the state variables. (This is an tough challenge. How are you going to produce a model for variables that can't be seen?)

Outputs of the Kalman Filter model are produced separately from the dynamic model, using an observation process that derives observable output values from the current internal values of the states. (This doesn't sound much more promising — how is the model supposed to figure out how to generate output values from internal variables that are already problematic?)

The dynamic model and the observation model are both strictly linear, consequently, observations are obtained as a linear combination of the values of the internal states.

Kalman Filters involve separate random noise models. Input noise arises primarily from interference such as signal noise, encompassing any effects that displace the subsequent state. Output noise arises from sensing and measurement errors when attempting to observe outputs.
That's a lot of gotchas. Faced with all of this, little wonder a lot of people give up before getting fully started.
What is state really?
State... In the context of Kalman Filters in particular, what does that mean? We use that state word a lot, informally, to mean something like status or region or setting. Those meanings do not apply.
Let's consider the case of a automobile, which is a kind of dynamic system that moves from place to place over time (you have been keeping up with regular maintenance, haven't you?). You apply the brakes. Suppose that it is known how much braking action this causes. What is the vehicle's new speed of travel?
You should be thinking, "Wait just a second, you didn't tell me anything about how fast the vehicle was moving before the brakes were applied. If the vehicle was parked, the speed wouldn't change at all." Quite so. Even though you have full knowledge of the relevant inputs, in this case braking activity, this is not sufficient to determine travel velocity.
The additional information that you must have before you can determine the system outputs, given the system inputs, is called state. For the case of Kalman Filters, the state information is collected and represented as a numerical vector of state variables. In addition to velocity, the state vector for an automobile system might include the elevation above sea level, engine temperature, the amount of fuel in the tank, charge on the batteries, and various other conditions, depending on what your model is intended to represent (or ignore).
In many cases, certainly not all, states are associated with the storage of energy. Nonlinear states can represent such information as whether a switch is in an open or closed position.
Hazards of discrete state dynamics
Digital systems have an additional ugly hazard. Inputs are captured at a discrete instant of time. Once these are captured, that instant in time has passed, and it is no longer possible to generate outputs for that instant of time. The best you can do is to respond a short time later when the next timing cycle is triggered by the digital timing oscillator.
This is a partial explanation for why state variables are so important. Since any opportunity to produce outputs right now is immediately lost to history, some kind of variables — the state — must maintain the information about what the inputs did previously so that this input information is available to affect the next outputs. This forces the model into a twolayer affair, the state equations part to prepare and retain future values resulting from current input data, and the output observation part to determine what system outputs will be at the next timing instant based on the recorded state information.
If that wasn't enough to keep things interesting, the linear state models are not unique. That has advantages and disadvantages. It is not necessary to find the one true model — it is not a needle in a haystack problem. However, there is an infinite number of satisfactory and equivalent needles, and an infinite number of candidate haystacks to search. The profusion of possible models makes it harder to distinguish a good proposed model from a bad one, or to settle consistently to a single model. What happens in general when linear problems have more than one solution? The matrix equations become singular. When this happens, numerical solution methods are indeterminate and do not have a single "true solution" to report. Part of the modeling challenge it to impose reasonable restrictions so that solutions can settle somewhere.
Next time, we'll get more formal about the exact mathematical form the Kalman Filter state transition models, and begin the explorations for a process to determine model parameters with Linear Least Squares as one of the tools.