State-Space Models
A satellite streaks overhead. What you actually want — its true position and velocity right now — you
never see directly. What you do see is a stream of noisy range readings from ground stations,
each off by a few metres. Two things are going on at once: a hidden truth that evolves
under its own dynamics, and a noisy measurement that only glimpses it. Almost every
real forecasting problem has this shape. A central bank cares about the "output gap" — how far the
economy is from its potential — but that gap is never observed; only noisy GDP prints are. A biologist
wants a population's true size, but only a rough survey each year. A phone wants your true location, but
only a jittery GPS fix.
The state-space model is the framework built exactly for this: separate the
hidden state that follows a clean dynamical rule from the observations that see it
through a veil of noise. It is one of the great unifying ideas of the subject — because, as we will see,
ARMA models,
trends, and seasonal patterns all turn out to be special cases of it, and a single recursive algorithm
fits every one of them.
The two equations
A (linear, Gaussian) state-space model is written as a pair. Let the hidden state at time
t be a vector \alpha_t. The
state equation (or transition equation) says how the hidden truth marches
forward:
\alpha_t = T\,\alpha_{t-1} + \eta_t, \qquad \eta_t \sim N(0, Q),
and the observation equation (or measurement equation) says what we get to
see — a linear function of the state, blurred by fresh measurement noise:
y_t = Z\,\alpha_t + \varepsilon_t, \qquad \varepsilon_t \sim N(0, H).
Here T is the transition matrix (the system dynamics),
Z the observation matrix (which combination of state
components we measure), and \eta_t, \varepsilon_t are two independent
white-noise
streams — the process noise that jostles the state and the measurement noise that
corrupts the sensor. Because both are
multivariate Gaussian
and everything is linear, the whole model is completely described by the matrices
(T, Z, Q, H) and a starting distribution for
\alpha_0.
The picture to hold in your head: a state that walks its own path, and observations that
rain down noisily around that path.
Seeing the hidden path
Below, the smooth line is the true hidden state \alpha_t as it drifts along.
We never observe it. Every dot is an observation y_t = \alpha_t + \varepsilon_t
— the truth plus a random measurement error. The entire task of the next few lessons is to run the movie
backwards: given only the dots, reconstruct the line.
Notice that the dots alone look ragged, but they clearly cluster around something smooth. Exploiting the
state's dynamics — the fact that \alpha_t can't jump far from
\alpha_{t-1} — is what lets us average out the noise far better than looking
at each observation in isolation.
The simplest example: the local-level model
Strip the framework to a single scalar state and you get the local-level model, the
"hello world" of state space. The hidden state is just a slowly wandering level
\mu_t:
\mu_t = \mu_{t-1} + \eta_t, \qquad y_t = \mu_t + \varepsilon_t.
In our general notation this is \alpha_t = \mu_t with
T = 1 and Z = 1. The state equation is a
random walk:
the underlying level has no fixed mean, it just drifts, with the process variance
Q = \sigma_\eta^2 setting how briskly it moves. The observation equation adds
independent sensor noise of variance H = \sigma_\varepsilon^2 on top. This one
tiny model already captures a huge class of real series — a noisy sensor watching a quantity with no
trend but a level that slowly shifts — and it is exactly the model behind
simple
exponential smoothing.
The ratio \sigma_\eta^2 / \sigma_\varepsilon^2, called the
signal-to-noise ratio, is the whole personality of the model. Large: the level moves
fast and the observations are trustworthy, so estimates track closely. Small: the level barely moves and
the noise dominates, so we heavily smooth many observations together.
Everything is a state-space model
The reason this framework matters so much is its reach. Trend models, seasonal models,
and the entire ARMA family can all be rewritten in state-space form — a change of clothes, not a change
of model. Once written this way, they are all handled by the same recursive algorithm.
-
AR(1). The model
x_t = \phi x_{t-1} + \varepsilon_t is state-space with a scalar state
\alpha_t = x_t, transition T = \phi, process
noise \eta_t = \varepsilon_t, observation Z = 1,
and no measurement noise (H = 0) — we observe the state exactly.
-
AR(p) and ARMA. Stack the last few values (and shocks) into the state vector; the
transition matrix T becomes a companion matrix that shifts them
along and applies the coefficients.
-
Local linear trend. Put a level and a slope in the state vector so the
series can drift with a slowly changing trend.
-
Seasonal. Carry the last s-1 seasonal effects in the
state so a repeating pattern can itself evolve over time.
We build several of these deliberately in
structural
time series models. The payoff is the same in every case: one representation, one algorithm.
Worked example: writing AR(1) in state-space form
Take the concrete AR(1) x_t = 0.6\,x_{t-1} + \varepsilon_t with shock variance
\sigma^2 = 1. To cast it into the two equations, choose the state to be
the series:
\alpha_t = x_t.
Then the state equation is literally the AR(1) recursion,
\alpha_t = 0.6\,\alpha_{t-1} + \eta_t, \qquad \eta_t = \varepsilon_t,\; Q = 1,
so T = 0.6. And since we observe the series with no extra error,
y_t = \alpha_t, \qquad Z = 1,\; H = 0.
That's the entire translation: (T, Z, Q, H) = (0.6,\,1,\,1,\,0). A pure AR
model is the corner case where the observation is noiseless — all the randomness lives in the
state equation. A pure measurement problem (a fixed constant seen through a noisy sensor) is the opposite
corner: T = 1,\, Q = 0, all the randomness in the observation. Real models sit
between the two, with noise in both equations at once.
Why bother? Two big wins
-
One algorithm fits them all. Whatever the model, once it is in state-space form the
Kalman
filter recursively computes the optimal estimate of the hidden state and the likelihood of
the data. You never rewrite the estimation code — only the matrices (T, Z, Q, H).
-
Missing data is free. If an observation y_t is missing, you
simply skip the update at that time and let the state equation carry the estimate forward. No
interpolation, no special cases — a gap is handled as naturally as a present value. This is one of the
framework's most beloved practical properties, and it is nearly impossible to match in a raw ARMA
setup.
A classic trap: students believe there is one "correct" state vector for a given model. There isn't. The
same observable process can be written in infinitely many state-space forms. Take any invertible
matrix M and define a new state
\tilde\alpha_t = M\alpha_t; with
\tilde T = M T M^{-1} and \tilde Z = Z M^{-1} you
get an entirely different-looking model that produces the identical distribution for the
observations y_t. An ARMA model has several standard state-space
representations (Harvey's, Akaike's, the "companion" form), all equally valid.
The lesson: don't over-interpret the raw numbers in T or the state components
unless the model was built to make them meaningful. What is pinned down by the data is the behaviour of
the observations — not the particular coordinates you chose for the hidden state. (Structural
models are built precisely so that the state components do carry interpretation — level, trend,
season — but that is a modelling choice, not something forced by the maths.)
The state-space idea crossed into time series from control engineering. In 1960 Rudolf
Kálmán published his recursive filter for estimating the state of a linear dynamical system driven by
noise, and it flew almost immediately — literally, on the Apollo guidance computer. Statisticians spent
the following decades realising that this engineer's toolkit was a gift: it gave a single computational
engine for the whole ARMA family, painless missing-data handling, and time-varying parameters for free.
By the 1980s, thanks to work by Harvey, Durbin, Koopman and others, the state-space representation had
become the standard computational backbone of the field — the way ARMA and structural models are
actually estimated inside your software, even when you never see it. The same equation now steers
spacecraft and forecasts inflation; see the control-theory companion,
the Kalman filter
for dynamical systems.