An observed series as a noisy view of a hidden state

Today let's understand state space models, using one long, real series as the running example throughout.

The series is Nile, one of R's own built-in datasets: the river's annual flow at Aswan, in Egypt, measured every year from 1871 to 1970, a hundred years in all. Each reading is in units of 10^8 cubic metres.

Here is the whole hundred years, plotted in the order the years actually happened.

Look at that line. For its first three decades it swings around a high band, then somewhere near 1898 it drops and spends the rest of the century swinging around a lower band instead.

A real shift in level, not just one bad year

That drop around 1898 could be two different things: a single unusually low year the eye is exaggerating, or a real, lasting change in how much water the Nile carried every year from then on. The only way to tell them apart is to compare the two periods properly, not just look at the line.

Nile still holds all hundred years. Split it at 1898 and average each half.

RInteractive R
# Compare the mean Nile flow before and after 1898 before_1898 <- window(Nile, end = 1898) after_1898 <- window(Nile, start = 1899) round(mean(before_1898), 2) #> [1] 1097.75 round(mean(after_1898), 2) #> [1] 849.97

  

The 28 years up to 1898 average 1097.75. The 72 years from 1899 average 849.97, a drop of about 248, close to 23 percent of the earlier level. And it is not one bad year dragging that second average down: the drop holds across all 72 of those years, which is what makes it a real shift and not noise.

This matches a changepoint researchers have already found in this exact series, right around 1898 (Cobb, 1978), noted on R's own help page for the Nile dataset.