Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Moving Averages: A Statistical Technique for Time Series Analysis, Study notes of Fourier Transform and Series

The concept of moving averages, a statistical technique used in time series analysis. Moving averages involve calculating the average of a set of sequential data points to identify trends and patterns in a time series. different types of moving averages, including two-sided, one-sided, and weighted moving averages, as well as their applications in smoothing and forecasting. It also discusses variations of moving averages, such as cumulative averages and double moving averages.

What you will learn

  • What is a moving average in time series analysis?
  • How are two-sided and one-sided moving averages different?
  • What are the advantages of using weighted moving averages?

Typology: Study notes

2021/2022

Uploaded on 09/27/2022

leyllin
leyllin 🇬🇧

4.3

(15)

242 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Moving averages
Rob J Hyndman
November 8, 2009
A moving average is a time series constructed by taking averages of several sequential values
of another time series. It is a type of mathematical convolution. If we represent the original
time series by y1,...,yn, then a two-sided moving average of the time series is given by
zt=1
2k+ 1
k
X
j=k
yt+j, t =k+ 1,k + 2,...,nk.
Thus
zk+1,...,znk
forms a new time series which is based on averages of the original time series,
{yt}. Similarly, a one-sided moving average of {yt}is given by
zt=1
k+ 1
k
X
j=0
ytj, t =k+ 1,k + 2,...,n.
More generally, weighted averages may also be used. Moving averages are also called running
means or rolling averages. They are a special case of “filtering”, which is a general process that
takes one time series and transforms it into another time series.
The term “moving average” is used to describe this procedure because each average is
computed by dropping the oldest observation and including the next observation. The averaging
“moves” through the time series until
zt
is computed at each observation for which all elements
of the average are available.
Note that in the above examples, the number of data points in each average remains constant.
Variations on moving averages allow the number of points in each average to change. For
example, in a cumulative average, each value of the new series is equal to the sum of all previous
values.
Moving averages are used in two main ways: Two-sided (weighted) moving averages are
used to “smooth” a time series in order to estimate or highlight the underlying trend; one-sided
(weighted) moving averages are used as simple forecasting methods for time series. While
moving averages are very simple methods, they are often building blocks for more complicated
methods of time series smoothing, decomposition and forecasting.
1 Smoothing using two-sided moving averages
It is common for a time series to consist of a smooth underlying trend observed with error:
yt=f(t) + εt,
where
f
(
t
) is a smooth and continuous function of
t
and
{εt}
is a zero-mean error series. The
estimation of
f
(
t
) is known as smoothing, and a two-sided moving average is one way of doing
so:
ˆ
f(t) = 1
2k+ 1
k
X
j=k
yt+j, t =k+ 1,k + 2,...,nk.
1
pf3
pf4
pf5

Partial preview of the text

Download Moving Averages: A Statistical Technique for Time Series Analysis and more Study notes Fourier Transform and Series in PDF only on Docsity!

Moving averages

Rob J Hyndman

November 8, 2009

A moving average is a time series constructed by taking averages of several sequential values of another time series. It is a type of mathematical convolution. If we represent the original time series by y 1 ,... , yn , then a two-sided moving average of the time series is given by

zt =

2 k + 1

∑^ k

j =− k

yt + j , t = k + 1 , k + 2 ,... , nk.

Thus zk +1 ,... , znk forms a new time series which is based on averages of the original time series, { yt }. Similarly, a one-sided moving average of { yt } is given by

zt =

k + 1

∑^ k

j =

ytj , t = k + 1 , k + 2 ,... , n.

More generally, weighted averages may also be used. Moving averages are also called running means or rolling averages. They are a special case of “filtering”, which is a general process that takes one time series and transforms it into another time series. The term “moving average” is used to describe this procedure because each average is computed by dropping the oldest observation and including the next observation. The averaging “moves” through the time series until zt is computed at each observation for which all elements of the average are available. Note that in the above examples, the number of data points in each average remains constant. Variations on moving averages allow the number of points in each average to change. For example, in a cumulative average, each value of the new series is equal to the sum of all previous values. Moving averages are used in two main ways: Two-sided (weighted) moving averages are used to “smooth” a time series in order to estimate or highlight the underlying trend; one-sided (weighted) moving averages are used as simple forecasting methods for time series. While moving averages are very simple methods, they are often building blocks for more complicated methods of time series smoothing, decomposition and forecasting.

1 Smoothing using two-sided moving averages

It is common for a time series to consist of a smooth underlying trend observed with error: yt = f ( t ) + εt, where f ( t ) is a smooth and continuous function of t and { εt } is a zero-mean error series. The estimation of f ( t ) is known as smoothing, and a two-sided moving average is one way of doing so: f ˆ ( t ) = 1 2 k + 1

∑^ k

j =− k

yt + j , t = k + 1 , k + 2 ,... , nk.

The idea behind using moving averages for smoothing is that observations which are nearby in time are also likely to be close in value. So taking an average of the points near an observation will provide a reasonable estimate of the trend at that observation. The average eliminates some of the randomness in the data, leaving a smooth trend component. Moving averages do not allow estimates of f ( t ) near the ends of the time series (in the first k and last k periods). This can cause difficulties when the trend estimate is used for forecasting or analysing the most recent data. Each average consists of 2 k + 1 observations. Sometimes this is known as a (2 k + 1) MA smoother. The larger the value of k , the flatter and smoother the estimate of f ( t ) will be. A smooth estimate is usually desirable, but a flat estimate is biased, especially near the peaks and troughs in f ( t ). When { εt } is a white noise series (i.e., independent and identically distributed with zero mean and variance σ^2 ), the bias is given by E [ f ˆ ( x )] − f ( x ) ≈ 16 f ′′( x ) k ( k + 1) and the variance by V [ f ˆ ( x )] ≈ σ^2 / (2 k + 1). So there is a trade-off between increasing bias (with large k ) and increasing variance (with small k ).

2 Centered moving averages

The simple moving average described above requires an odd number of observations to be included in each average. This ensures that the average is centered at the middle of the data values being averaged. But suppose we wish to calculate a moving average with an even number of observations. For example, to calculate a 4-term moving average, the trend at time t could be calculated as

f ˆ ( t − 0_._ 5) = ( yt − 2 + yt − 1 + yt + yt +1) / 4 or f ˆ ( t + 0_._ 5) = ( yt − 1 + yt + yt +1 + yt +2) / 4_._

That is, we could include two terms on the left and one on the right of the observation, or one term on the left and two terms on the right, and neither of these is centered on t. If we now take the average of these two moving averages, we obtain something centered at time t :

f ˆ ( t ) = 12 [( yt − 2 + yt − 1 + yt + yt +1) / 4] + 12 [( yt − 1 + yt + yt +1 + yt +2) / 4] = 18 yt − 2 + 14 yt − 1 + 14 yt + 14 yt +1 18 yt +.

So a 4 MA followed by a 2 MA gives a centered moving average, sometimes written as 2 × 4 MA. This is also a weighted moving average of order 5, where the weights for each period are unequal. In general, a 2 × m MA smoother is equivalent to a weighted MA of order m + 1 with weights 1 /m for all observations except for the first and last observations in the average, which have weights 1 / (2 m ). Centered moving averages are examples of how a moving average can itself be smoothed by another moving average. Together, the smoother is known as a double moving average. In fact, any combination of moving averages can be used together to form a double moving average. For example, a 3 × 3 moving average is a 3 MA of a 3 MA.

3 Moving averages with seasonal data

If the centered 4 MA was used with quarterly data, each quarter would be given equal weight. The weight for the quarter at the ends of the moving average is split between the two years. It is this property that makes 2 × 4 MA very useful for estimating a trend in the presence of quarterly seasonality. The seasonal variation will be averaged out exactly when the moving average is computed. A slightly longer or a slightly shorter moving average will still retain some seasonal

Weighted moving averages are equivalent to kernel regression when the weights are obtained from a kernel function. For example, we may choose weights using the quartic function

Q ( j, k ) =

1 − [ j/ ( k + 1)]^2

for − kjk ; 0 otherwise.

Then aj is set to Q ( j, k ) and scaled so the weights sum to one. That is,

aj =

Q ( j, k ) ∑^ k

i =− k

Q ( i, k )

5 Forecasting using one-sided moving averages

A simple forecasting method is to simply average the last few observed values of a time series. Thus

y ˆ t + h | t =

k + 1

∑^ k

j =

ytj

provides a forecast of yt + h given the data up to time t. As with smoothing, the more observations included in the moving average, the greater the smoothing effect. A forecaster must choose the number of periods ( k + 1) in a moving average. When k = 0, the forecast is simply equal to the value of the last observation. This is sometimes known as a “na¨ıve” forecast. An extremely common variation on the one-sided moving average is the exponentially weighted moving average. This is a weighted average where the weights decrease exponentially. It can be written as y ˆ t + h | t =

∑^ t −^1

j =

aj ytj ,

where aj = λ (1 − λ ) j^. Then, for large t , the weights will approximately sum to one. An exponen- tially weighted moving average is the basis of simple exponential smoothing. It is also used in some process control methods.

6 Moving average processes

A related idea is the moving average process, which is a time series model that can be written as

yt = etθ 1 et − 1 − θ 2 et − 2 − · · · − θqetq,

where { et } is a white noise series. Thus, the observed series { yt }, is a weighted moving average of the unobserved { et } series. This is a special case of an Autoregressive Moving Average (or ARMA) model and is discussed in more detail on page ??. An important difference between this moving average and those considered previously is that here the moving average series is directly observed, and the coefficients θ 1 ,... , θq must be estimated from the data.

References

Kendall, M. G., Stuart, A. & Ord, J. K. (1983), Kendall’s advanced theory of statistics. Vol. 3 , Hodder Arnold, London.

Ladiray, D. & Quenneville, B. (2001), Seasonal adjustment with the X-11 method , Vol. 158 of Lecture notes in statistics , Springer-Verlag.

Makridakis, S., Wheelwright, S. C. & Hyndman, R. J. (1998), Forecasting: methods and applications , 3rd edn, John Wiley & Sons, New York.

Spencer, J. (1904), ‘On the graduation of the rates of sickness and mortality’, Journal of the Institute of Actuaries 38 , 334–343.