A school library lends more books in autumn than in summer, every year. Is it lending more books year by year? A time series graph shows the ups and downs. A moving average smooths them away, so that the long-term direction can be seen.
about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
plot a time series graph and describe its trend, its seasonal variation and its random variation;
explain why we find moving averages, and choose how many points to use;
calculate a moving average with an odd number of points, and plot it at the right time.
Books borrowed, term by term
A school year has three terms: autumn, spring and summer. A made-up school library counts the books borrowed in each term for three years.
Year 1: 420, 350, 280.
Year 2: 480, 380, 340.
Year 3: 510, 440, 370.
A set of values recorded at regular intervals of time is a time series.
The time series graph
To plot a time series graph:
Put time on the horizontal axis, in order, at equal steps. Here the terms are numbered 1 to 9.
Put the value on the vertical axis.
Plot each value, then join the points with straight lines in order. The lines help the eye. They do not mean that a value between two terms is known.
Time series graph of books borrowed from a school library in nine terms over three years: 420, 350, 280, 480, 380, 340, 510, 440 and 370, joined by straight lines. Square markers joined by a dashed line show the 3-point moving averages 350, 370, 380, 400, 410, 430 and 440, plotted at terms 2 to 8.
Three things a time series can show
Trend: the general direction over a long time. Here the loans go up from year to year.
Seasonal variation: a pattern that repeats over a fixed period. Here autumn is always the highest term and summer the lowest. "Seasonal" does not need weather. Any repeating cycle counts: terms, days of the week, quarters, months.
Random variation: the irregular bits that follow no pattern, such as a week of illness or a fire drill.
Why moving averages?
The seasonal swing hides the trend. Is spring of year 2 higher than autumn of year 1? No, but that tells us nothing. We should compare whole years, not one term with another.
A moving average takes the mean of a run of values, then moves on by one value and takes the mean again. If each run holds one full cycle, every average contains each season once. The seasonal ups and downs cancel out, and random bits are smoothed too. What is left shows the trend.
The number of points is the length of one cycle.
Three terms a year: a 3-point moving average.
Days of the week, open every day: a 7-point moving average.
Quarters of a year: a 4-point moving average.
Months of a year: a 12-point moving average.
Calculating a 3-point moving average
The first run. Terms 1, 2 and 3: 3420+350+280=350.
Move on one term. Terms 2, 3 and 4: 3350+280+480=370.
Keep going to the end of the data.
The seven moving averages are 350, 370, 380, 400, 410, 430 and 440.
Each average is plotted at the middle of its run. The first belongs to term 2, the second to term 3, and so on. Nine values give only seven averages: there is no average for the first or the last term.
The averages rise steadily, from 350 to 440. The library really is lending more books.
Practise with new numbers
Try it in Python
The program works out the 3-point moving averages of the library loans and draws them on the time series graph.
Your turn.
The usual mistakes
Using the wrong number of points. The run must cover exactly one cycle. A 2-point average of termly data still swings.
Plotting an average at the end of its run. It belongs to the middle.
Joining the moving averages to the first data point. There is no average for the first term.
Reading the trend from two single values. Compare the moving averages, not one term with another.
Remember these
A time series is a set of values at regular times, plotted against time.
Trend, seasonal variation and random variation are the three parts to look for.
A moving average over one full cycle removes the seasonal swing and shows the trend.
An odd-point moving average is plotted at the middle value of its run.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Name the three kinds of movement a time series can show.
A shop is open every day of the week and records its takings each day. How many points should its moving average use?
Find the 3-point moving average of 64, 52 and 46.
Twelve monthly values are given. How many 3-point moving averages can be found?
Why does a 3-point moving average remove the seasonal swing from termly data?
Enroll free in Time Series and Moving Averages
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.