Lesson 3: Smoothing with moving means and medians
Moving mean or moving median when there is an outlier
SkillsMoving mediansMoving means
Worked example
Show attendance (thousands) for 2018 to 2022 was 46.4, 49.3, 18.2, 47.6 and 50.8. The 2020 value is an outlier.
a) Calculate the 3-point moving mean and the 3-point moving median for 2019, 2020 and 2021 (to two decimal places where needed).
b) Which smoother better shows the trend in attendance? Explain.
Step 1: Moving means
2019:
2020:
2021:
Step 2: Moving medians
2019: middle of 18.2, 46.4, 49.3 is 46.4
2020: middle of 18.2, 47.6, 49.3 is 47.6
2021: middle of 18.2, 47.6, 50.8 is 47.6
Sort each window first; the median is the middle value.
Step 3: Compare
The outlier is in all three windows, and it drags every moving mean down by about 10 thousand, making a three-year dip that never happened. The moving medians stay close to the values either side of 2020 (around 46 to 51 thousand).
Answer
Moving means: 37.97, 38.37, 38.87. Moving medians: 46.4, 47.6, 47.6. The moving median better shows the trend: the median is resistant to the 2020 outlier, while the mean is pulled down for three years.
Try a similar one
A fresh question of the same kind, checked as you answer, with hints and a full solution.
Method
Calculate both smoothers for every window that contains the outlier.
Compare them with the values on either side of the outlier.
Choose the median when an outlier is present; the mean otherwise.
Watch out for
Forgetting to sort a window before taking its median.
Thinking the outlier only affects the 2020 moving average. With a 3-point window it affects 2019, 2020 and 2021.