Statistics From Zero · Lesson 31 of 31
Time Series: Trends, Seasons and Fake Correlations
In one sentence: Data collected over time come with trends, seasons and memory, so you compare like with like (this January with last January) and never correlate two trending series without first looking at their changes.
The idea
Most of this course has treated data as a bag of separate observations. A time series is different: the same thing measured again and again over time, such as monthly sales, daily temperatures or a share price. Time series have three habits that break the usual rules:
- Trend: a slow drift up or down over months or years.
- Seasonality: a pattern that repeats every year, week or day.
- Memory: today's value is close to yesterday's, so the observations aren't independent (Lesson 4).
Aunt Linda's ice-cream kiosk
Aunt Linda runs an ice-cream kiosk by the lake. In January of her third year she sold 50 ice creams, down from 55 in December. Uncle Gary, her self-appointed financial adviser, calls it "a 9% collapse" and suggests closing.
Linda points out that it's January.
Here are her monthly sales in year three, from a simple model of her kiosk: a seasonal pattern plus steady growth of 1% a month.
| Comparison | Change |
|---|---|
| January vs the December before | 9.1% down |
| September vs August | 26.9% down |
| January vs January a year earlier | 11.1% up |
| July vs July a year earlier | 10.0% up |
| Whole year vs the year before | 10.2% up (1,448 vs 1,314) |
Month-to-month comparisons are dominated by the season. Every autumn looks like a crash and every spring like a boom. The fix is to compare like with like: this January with last January (year-on-year), or a full year with a full year. Professional statistics offices publish "seasonally adjusted" figures for the same reason.
Ice creams sold per month, year three
Memory: autocorrelation
Today's share price is almost exactly yesterday's plus a small change. Correlate a price series with itself shifted by one day and you get about 0.98 in our simulation: an extremely strong link called autocorrelation. Correlate the daily changes instead and you get about 0.00. That's the whole difference between a level, which remembers everything, and the change in it, which may remember nothing.
It matters because most tests assume independent observations. A year of daily prices isn't 250 independent pieces of information. It's closer to one wandering line.
The fake correlation trap
Here's the most expensive mistake in the subject. We generated 2,000 pairs of completely unrelated random walks, 250 steps each (think of two imaginary share prices with nothing to do with each other), and correlated each pair:
| What we correlated | Pairs with a correlation above 0.5 (either sign) |
|---|---|
| The levels (the "prices") | 41% |
| The daily changes | 0% |
Two series that both wander will often wander in the same direction for a while, and their correlation looks strong by pure chance. The typical pair had a correlation of 0.42. This is called a spurious correlation (or spurious regression), and it's why "these two charts move together" proves nothing on its own. Correlate the changes, which removes the shared wandering, and the fake link disappears.
Three habits for any data over time
- Plot it first. A line chart shows trend and season at a glance.
- Compare like with like. Year-on-year, or seasonally adjusted figures, not this month against last month.
- Work with changes. Before correlating two series or testing a link between them, look at their changes (returns, growth rates), not their levels.
Try it yourself
A blog shows two lines rising together from 2000 to 2020: the number of streaming subscriptions and the national average house price. The correlation is 0.95. The author suggests streaming makes houses more expensive.
1. Why is 0.95 not impressive here? 2. What would you check instead?
Show the answer
1. Both series have strong upward trends, and almost any two trending series correlate highly. In our simulation even unrelated random walks exceed 0.5 in 41% of cases; two series that both grow steadily will do better still.
2. Correlate the year-to-year changes: did house prices rise faster in the years when subscriptions rose faster? Then ask about common causes, such as rising incomes and low interest rates, which push both up (Lesson 7).
The words your lecturer uses
| Lecturer says | It means |
|---|---|
| Time series | The same quantity measured repeatedly over time |
| Trend | The long-run drift up or down |
| Seasonality | A pattern that repeats at a fixed interval |
| Seasonal adjustment | Removing the typical seasonal pattern so months can be compared |
| Autocorrelation | The correlation of a series with its own past values |
| Random walk | A series where each value is the last one plus a random step |
| Stationary | A series whose average and spread don't drift over time; changes often are, levels often aren't |
| Spurious correlation (regression) | A strong but meaningless link between two trending series |
| Differencing | Working with changes from one period to the next instead of levels |
Three things to remember
- Data over time have trend, season and memory. Plot them before calculating anything.
- Compare like with like: this January with last January, not with December.
- Never trust a correlation between two trending lines. Correlate their changes.
Part 3 so far
Lessons 20 to 31 add tools you'll meet in almost every course and every research report: the binomial and Poisson distributions for counting, ANOVA for comparing more than two groups, effect size for deciding whether a significant result matters, regression to the mean for spotting changes that need no cause, and the difference between watching and experimenting for deciding what causes what. Then the practical kit: histograms for seeing the shape of data, multiple regression for holding other factors fixed, the bootstrap for intervals without formulas, odds ratios for reading health headlines, rank tests for data that won't behave, and time series for anything measured over time.
Part of Statistics From Zero, a free beginner course by WrongStat. Not a substitute for your lecturer, but hopefully a good translator.