Excellent descriptions of the history and basic concepts related to Exponentially Weighted Moving
Average (EWMA) are available in text books, journal articles, and numerous web pages on the Internet,
some of which are listed in the references section.
This page will therefore provide only a brief summary and description, suffice to quickly orientate
the user, and in support of the calculations in the Exponentially Weighted Moving Average Program Page
.
Only the simplest model, as described by the NIST manual (see references) is provided. A paper by Lucas and the Seccicci
described further improvements, but they are not available in by StatTools.
Conceptually, EWMA is the same as averaging a number of consecutive observations, and by so doing it smooths out
short term variations. This prevents outlying values from distorting the long term trend of a set of observations.
The advantages of EWMA over averaging a set number of observations are firstly the values are weighted,
so that the more recent observations have greater influence on the averaging, and secondly, there is no need to
maintain a database of all the numbers and no need to define the number of observations needed for the averaging.
The Exponentially Weighted Average and coefficient λ
A weighting coefficient lambda (λ) is used to assign the weight to the current observation (Yt),
in relationship to the immediately previous EWMA value (EWMAt-1), and combine them to produce the current EWMA
value (EWMAt), so that
EWMAt = λYt + (1 - λ)EWMAt-1
λ is a value between 0 and 1, and governs the amount of weight the current observation has in relationship
to all previous observations. A λ close to 1 means a strong dominance by the current observation,
with very little averaging. A λ close to 0 means a greater level of averaging, produces a smoother trend line,
but the trend is less responsive to immediate changes in the observations.
The Reference Mean and Standard Deviation
These are provided by the user, either as the standards by which the new data are to be plotted against, or values
obtained by previous studies.
The Standard Error of EWMA
With weighted average, outlying values are brought closer to the mean, so that the original Standard Deviation is reduced.
If SD is the original Standard Deviation, and λ is the weighting coefficient, the Standard Error
of the resulting EWMA is SEEWMA = sqrt((λ/(2.0 - λ))SD2)
With smoothing by weighted average, and a reduced SEEWMA, a trend in the measurements that departs from
the mean can be more easily identified. In quality control, an EWMA that is 3SE from the mean triggers an alert that values are drifting away from the mean
The algorithm used in the Exponentially Weighted Moving Average Program Page
Plots the original values as dots, and the EWMA as lines. It also draws horizontal lines at 1 SE intervals from the mean so that departure from the mean can be identified.
Options for users : There are 4 buttons for the user to choose, representing options in two dimensions
- Scaling : User may scale the vertical axis (Y) according to values or standard errors. Scaling by values will have greater meaning to the clinical users, but standard errors will be more familiar to statisticians. Standard error scaling will also be more useful when comparing different EWMAs, as standard error is measurement free so have the same scaling across all measurements.
- Full output : This translates and displays each data point into its standard error values so that the user can examine in detail what the data is all about. This however becomes cumbersome if the sample size is large, as a huge table is produced. This therefore should be avoided unless the user has a need to examine each data point.
Sample | Value | EWMA | z=(EWMA-100)/3.78 |
0 | 100 | 100 | 0 |
1 | 96.1 | 99.025 | -0.258 |
2 | 99.3 | 99.0938 | -0.2398 |
3 | 98.8 | 99.0203 | -0.2592 |
4 | 107.9 | 101.2402 | 0.3281 |
5 | 102.3 | 101.5052 | 0.3982 |
6 | 108.1 | 103.1539 | 0.8344 |
7 | 95.2 | 101.1654 | 0.3083 |
8 | 110.3 | 103.4491 | 0.9125 |
9 | 97.2 | 101.8868 | 0.4992 |
10 | 107.7 | 103.3401 | 0.8837 |
11 | 107.3 | 104.3301 | 1.1456 |
12 | 109.5 | 105.6226 | 1.4876 |
13 | 105.3 | 105.5419 | 1.4663 |
14 | 110.9 | 106.8814 | 1.8207 |
15 | 105.9 | 106.6361 | 1.7557 |
16 | 99.8 | 104.9271 | 1.3036 |
17 | 99.5 | 103.5703 | 0.9446 |
18 | 91.4 | 100.5277 | 0.1396 |
19 | 105.4 | 101.7458 | 0.4619 |
20 | 97.6 | 100.7093 | 0.1877 |
21 | 94.9 | 99.257 | -0.1966 |
22 | 111.2 | 102.2428 | 0.5934 |
23 | 98.5 | 101.3071 | 0.3458 |
24 | 81.5 | 96.3553 | -0.9643 |
25 | 101.1 | 97.5415 | -0.6505 |
26 | 93.5 | 96.5311 | -0.9178 |
27 | 82.1 | 92.9233 | -1.8723 |
28 | 100.4 | 94.7925 | -1.3778 |
29 | 103.1 | 96.8694 | -0.8283 |
30 | 131.5 | 105.527 | 1.4623 |
31 | 96.9 | 103.3703 | 0.8917 |
32 | 90.2 | 100.0777 | 0.0206 |
33 | 108 | 102.0583 | 0.5446 |
34 | 108.7 | 103.7187 | 0.9839 |
35 | 101.4 | 103.139 | 0.8305 |
36 | 108.3 | 104.4293 | 1.1719 |
37 | 103.7 | 104.247 | 1.1236 |
38 | 114.7 | 106.8602 | 1.815 |
39 | 110.2 | 107.6952 | 2.0359 |
40 | 113 | 109.0214 | 2.3868 |
41 | 100.8 | 106.966 | 1.843 |
42 | 100.2 | 105.2745 | 1.3955 |
43 | 126 | 110.4559 | 2.7664 |
44 | 103 | 108.5919 | 2.2732 |
45 | 120.2 | 111.4939 | 3.041 |
46 | 105 | 109.8705 | 2.6115 |
47 | 118.5 | 112.0278 | 3.1823 |
48 | 116.5 | 113.1459 | 3.4781 |
49 | 105.2 | 111.1594 | 2.9525 |
50 | 102.3 | 108.9446 | 2.3665 |
We will use the default example in the
Exponentially Weighted Moving Average Program Page
. The data is computer generated to demonstrate
the methodology and is not real.
We are investment advisors, and have created our own stock market index. Over the last month or so,
we know that this index runs with a mean of 100 and Standard Deviation of 10. We keep a close eye on this index
as we expect a boom to occur in the near future, and will want to advise our clients to invest heavily when it starts.
We obtained the data and calculated EWMA using λ=0.25. The results of the calculations are shown in the table to the right.
The plot including the values, EWMA, and standard errors is shown to the left. It can be seen that the daily value of the index (circular dots) is highly variable and uninterpretable. The EWMA, roughly the average of 4 days, smoothed out the short term variations, and we can conclude that there is a continuous increase in the daily index when EWMA reaches 3 standard errors on day 46
If the user does not want to be distracted by the daily values, the dot size can be set to 0. The plot is rescaled, but the interpretation of EWMA remains the same, as shown in the figure to the right.
This example therefore demonstrate the general principles of EWMA. The Standard error of EWMA is a function of the standard deviation of the individual measurements, and λ, and in this example
SEEWMA = sqrt((λ/(2.0 - λ))SD2) = sqrt(0.25 / 1.75 x 100) = 3.78
Interpretation varies, either when EWMA crosses the 2 standard error line twice consecutively, or when EWMA crosses the 3 standard error