Moving Averages
Objectives:
D Grade Interpret a Time Series Graph
B Grade Construct a Time Series Graph and Plot the
Moving Averages
Moving Averages
A line graph is a series of points joined with straight lines
e.g. a patient’s temperature was recorded every 2 hours
after receiving medication: Note the features:
Temperature over time Title
42 Axis Labels
What does this line
41
Temperature oC
represent?
40 The points are plotted
39 as coordinates
Normal body temperature
38
37 The points are joined
36 with straight lines
35
0 2 4 6 8 10 12 A second set (or more)
of data may be added to
Time after medication (hrs)
the graph.
Moving Averages
Because the line graph of temperature was plotted against time
it can also be called a ‘Time Series Graph’
Time Series Graphs are often used by people to identify trends over
a period of time where they may be natural fluctuations.
For example, after installing loft and cavity wall insulation a
householder wants to review his gas bills to see if he is saving money.
Moving Averages
A graph of gas bills plotted against time.
Cost of Gas Bill
300
250
200
Cost (£)
150
100
50
0
1st 2nd 3rd 4th 1st 2nd 3rd 4th
2006 2007
Year / Quarter
Why is there so much
the x axis fluctuation
labelled in the
with years 1st, 2–ndis
andgraph rd, 4th?
, 3there a pattern?
The 1st quarter
Utility is winterwater,
(gas, electric, whenetc.,)
you would
bills areexpect to use
sent out a lot
every of gas for
3 months heating,
(quarter of a year)
the 3 quarter is the summer when you don’t use the heating.
rd
Moving Averages
A different number of points for a moving average can be selected
depending upon the data being analysed. Different types of data
suit different moving averages
Which type of moving average which suit which data set?
Electricity Bill Three-point moving average
Gas Bill Four-point moving average
Half-term test results Five-point moving average
Phone Bill Six-point moving average
Daily Superstore Sales Seven-point moving average
Termly test results
Moving Averages
Time Series Graph
Year 2006 2007 2008
Quarter 1st 2nd 3rd 4th 1st 2nd 3rd 4th 1st 2nd 3rd 4th
Ice Cream Sales (£) 340 525 965 470 355 510 1100 375 410 555 1150 485
Plot the data as a time series graph:
This is essentially a line graph. The time is always plotted on the x-axis
1200
Ice Cream Sales (£)
x x
1000 x
800
600 x
x x x x
400
x x x x
200
2006 2007 2008
Moving Averages Representing Data
Moving Averages are a way of looking at a trend over a period of time.
For a four-point the mean is calculated from the first four pieces of data, then the next point is
calculated by moving the selection one place across to calculate the mean of 4 points again
Year 2006 2007 2008
Quarter 1st 2nd 3rd 4th 1st 2nd 3rd 4th Calculate the mean of the
1st 2nd 3rd 4th
first 4 points
second i.e.i.e.
4 points
1 Ice Cream Sales (£) 340 525 965 470 355 510 1100 375 410 555 1150 485 525+965+470
340+525+965+470 +355= = 575
579
Moving Average 575 4
2 Ice Cream Sales (£) 340 525 965 470 355 510 1100 375 410 555 1150 485
Moving Average 575 579 575 609 585 599 610 623
1200 The moving average point is
Ice Cream Sales (£)
x x plotted in the middle of the 4
1000 points the average is taken
x from
800
600 x x x x You can see there is a general
xx x x x x x x increase in sales over time
x x
400 x
x x For a 3 point moving average
200 take the mean over 3 points,
for a 5 point moving average
take the mean over 5 points,
etc.
2006 2007 2008
Moving Averages
P20 Q 5
Year 2006 2006 2006 2006 2007 2007 2007 2007
Quarter 1st 2nd 3rd 4th 1st 2nd 3rd 4th
Cost £230 £120 £50 £80 £215 £120 £25 £55
Four-point moving
£120 £116
average
P21 Q 6
Day Mon Mon Tue Tue Wed Wed Thu Thu Fri Fri
Session a.m. p.m. a.m. p.m. a.m. p.m. a.m. p.m. a.m. p.m.
Number 220 210 243 215 254 218 251 201 185 152
Two point 215 226.5 229 234.5
moving average
Moving Averages
P21 Q 7
Year 2005 2006 2006 2006 2007 2007 2007
Session Autumn Spring Summer Autumn Spring Summer Autumn
Exam Result (%) 86 93 70 83 93 67 77
P21 Q 8
Quarter Jul-04 Oct-04 Jan-05 Apr-05 Jul-05 Oct-05 Jan-05 Apr-06
Shop Sales
120
x
100 x
Sales (£ thousands)
x
80 x
60
x
40 x
20
x x
0
Moving Averages
P20 Q 5
Year 2006 2006 2006 2006 2007 2007 2007 2007
Quarter 1st 2nd 3rd 4th 1st 2nd 3rd 4th
Cost £230 £120 £50 £80 £215 £120 £25 £55
Four-point moving
£120 £116 £116.25 £110 £103.75
average
250
x
200
x
150
Cost (£)
x x x x x x
100
x
50 x x
x
0
1st 2nd 3rd 4th 1st 2nd 3rd 4th
2006 2007
Time (year, quarter)
The trend is moving downwards which means that the electricity costs are falling
Moving Averages
P21 Q 6
Day Mon Mon Tue Tue Wed Wed Thu Thu Fri Fri
Session a.m. p.m. a.m. p.m. a.m. p.m. a.m. p.m. a.m. p.m.
Number 220 210 243 215 254 218 251 201 185 152
Two point 215 226.5 229 234.5 236 234.5 226 193 168.5
moving average
270
250 x x
x
Number Present
x x x
230 x
x x x x x
x
210 x
x
190 x
x
170 x
150 x
The trend is downwards – starting low on Monday, then rising to Wednesday, but
Falling sharply towards Friday.
Moving Averages
P21 Q 7
100
Year 2005 2006 2006 2006 2007 2007 2007
x x
Session Autumn Spring Summer Autumn Spring Summer Autumn 90
Exam Result (%) 86 93 70 83 93 67 77 x
x x x x
83 82 82 81 79 80 x x
70 x
x
60
P21 Q 8
Quarter Jul-04 Oct-04 Jan-05 Apr-05 Jul-05 Oct-05 Jan-05 Apr-06
Shop Sales 100 40 10 80 110 50 12 86
57.5 60 62.5 63 64.5 120
x
c. The trend is slightly upwards 100 x
Sales (£ thousands)
x
d. The next point would probably lie at 67 80 x
67= 50+12+86 +x x x x x
60 x x
4
67 × 4 = 50 + 10 + 86 + x x
40 x
268 = 146 + x
20
x = 122
x x
So the next quarter sales would be about £122 000 0
Key Performance Indicator (KPI)
Key Performance Indicator (KPI)
Computing the Forecast Error
The error during one period (et) as the difference
between the forecast (ft) and the demand (dt).
et = ft − dt
Key Performance Indicator (KPI)
Bias
Key Performance Indicator (KPI)
MAPE
Key Performance Indicator (KPI)
MAE
Key Performance Indicator (KPI)
RMSE
Exponential Smoothing
For a moving average, the basic idea of this model is to assume that
the future will be more or less the same as the (recent) past. The
only pattern that this model will be able to learn from demand
history is its level.
Exponential Smoothing
The simple exponential smoothing model will have some advantages
compared to a naïve or a moving average model:
1
– The weight that is put on each observation decreases
exponentially over time.
2
In other words, in order to determine the forecast, the historical,
most recent period has the highest importance; then each
subsequent (older) period has less and less importance.
This is often better than moving average models, where the same
importance (weight) is given to a handful of historical periods.
– Outliers and noise have less impact than with a naïve forecast.
Exponential Smoothing
Model
Exponential Smoothing
Exponential Smoothing
Exponential Smoothing