Local level and local linear trend models

Today let's look at the two simplest state space models there are, the local level model and the local linear trend model, and see what changes the moment a real trend enters the picture.

The example is airmiles, a series that ships with R itself: US domestic airline revenue passenger miles, one number a year from 1937 to 1960. It opens at 412 million miles in 1937 and closes at 30,514 million in 1960, with no repeating seasonal pattern in it at all.

Here is the whole series, plotted exactly as it happened.

That is not a gentle drift. Airline travel grew more than seventy times over across those 24 years, and every model in this lesson has to fit a climb that steep.

The local level model and what a real trend does to it

Start with the simpler of the two models. A local level model says a series is one hidden state, called the level and written \(\mu_t\), plus noise.

The level itself is not fixed. It moves from one year to the next by a random walk:

\[\mu_t = \mu_{t-1} + \eta_t, \quad \eta_t \sim N(0, Q)\]

\(\eta_t\) is a small random nudge applied every year, and \(Q\) is its variance: how big that nudge typically is. Whatever the level was last year, it carries over to this year plus one of these nudges.

What you actually observe is never the level directly. It is the level plus a separate noise term on top:

\[y_t = \mu_t + \epsilon_t, \quad \epsilon_t \sim N(0, H)\]

\(\epsilon_t\) is the observation noise: the part of each year's number that is measurement error, not a real change in the level. \(H\) is its variance.

Fit this to airmiles and see what R finds for \(Q\) and \(H\).

RInteractive R
# Fit the local level model to airmiles and look at its two variances fit_level <- StructTS(airmiles, type = "level") fit_level$coef #> level epsilon #> 3128881 0

  

\(Q\), the level's own variance, comes out at 3,128,881: a big number, but airmiles itself ranges from 412 to 30,514, so a big number is expected. The real surprise is \(H\), the observation noise variance. It comes out at exactly 0.

Put the two together and you get what is called the signal-to-noise ratio, \(Q/H\): how much the hidden state itself moves, set against how noisy each single observation is. With \(H = 0\), that ratio is not just large, it is undefined, since nothing can be divided by zero.

An undefined, effectively infinite signal-to-noise ratio has one direct consequence for the fit. The Kalman filter's gain, the number that decides how much of each new observation gets folded into the updated level, locks at 1. A gain of 1 means every observation is folded in whole, with nothing held back. So the fitted level should equal the observed data exactly, year for year.

RInteractive R
# Check whether the fitted level really does equal the observed data cor(as.numeric(airmiles), as.numeric(fitted(fit_level))) #> [1] 1

  

Correlation of 1.000, not 0.999 or 0.99. Fit to a series with a trend this strong, the local level model does not smooth airmiles at all. It just copies it back.