The analysis of time series starts with the extraction of the long-run behavior or trend from the observed values. There are a variety of different methods, leading to different trend lines for one and the same series. The choice of a particular method requires a comparison of advantages and disadvantages.
In this section we will be present the moving average and least squares methods.
Method of moving average
In this method the estimated trend at every point in time is a weighted average of the original observed data. :
with
The set of weights
is called the filter.
The selection of the filter depends on periodic/seasonal variations and the desired smoothness. We will usually employ symmetric filters (
). They include future as well as past periods.
If the weights
of a filter are equal for all
, the filter is called a simple moving average, if not, we call it a weighted moving average.
Support area: The weighted average will be calculated in an window (area) of the original data. The choice of
and
determine the length of the window of data that are used for the the support area. As a matter of principle the series of estimated trends can only be as long as the original series (equality, if
). The longer the support area selected, the smaller the number of trend values that can be calculated and the smoother is the resulting trend series.
Frequently used filters for time series with seasonal variations:
Symmetric filters (
) are often specified so that the
weights are in square brackets. For the smoothing of seasonal time series the following filter can be applied. The reason is, that they filter (smooth) out the periodic variations from original data for the trend calculation.
- six-month data
![{\displaystyle \lbrack 1/8,\ 1/4,\ 1/4,\ 1/4,\ 1/8]\quad (a=2)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/8caafde40ab7c8dd417c3a68ae399bcac713d0d2)
- quarterly data
![{\displaystyle \lbrack 1/16,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/16]\quad (a=4)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/4055633bbf7df6c0c04aa5a6d5a57aeda609b4b5)
- monthly data
![{\displaystyle \lbrack 1/24,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/12,\ 1/24]\quad (a=6)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/4822f0ba21f373b62e5ff4cf190a92046bca8c60)
Example (quarterly data): Number of newly registered cars in Berlin 1977:1 - 1989:4Filter:
red: original seriesblack: smoothed series (trend)
Least-squares method
The Least-squares method is a second approach to estimate the trend component of a time series. The method was presented in the regression analysis chapter. We select a set of functions, which describe the trend as a function of time
and estimate the parameters of these functions. These parameter values minimize the sum of squared variations of the trend from the original data.
In the following we derive expressions for the least squares estimates of a simple linear trend and exponential trend functions.
Linear trend function
Suppose that the variable
depends linearly on time
The sum of the squared residuals clearly depends on the parameters
and
as
Minimization results in the following estimators of the parameters.
Example:
Price index for foreign services in Berlin, 1977:1 - 1989:4
where
corresponds to 1976:4.
Exponential trend
Suppose that the variable
exhibits an exponential dependence on time
of the form
or, similarly, in logarithmic form
Least squares minimization results in the following estimators of the parameters.
Example: Number of phones in the US (measured in
) 1900 - 1970
where
corresponds to the year 1899.
Explanation Select a time series which will be smoothed by XploRe. You can edit the XploRe code directly.
Explanation
You can now select a time series, which will be separated into trend and residuals.
The trend is estimated by the method of moving average. In addition several filters are available.
Suggestion
Select successively different filters and observe the effects of your selection on the estimated trend. You should also pay attention to the residuals. For example, are there outliers? Do the fluctuations of the residuals change over time?
Data
The following data are available.
- DAX stock market indexYearly percentage changes of the DAX observed at December 31.Time period: December 1960 – December 1997 Periodicity (frequency): Yearly data Note: until 1987 the index of the Deutsche Börsenzeitung is reported
- Public incomePercentage change in the incomes of all public households in GermanyTime period: 1951 – 1991 Periodicity (frequency): Yearly data
- Balance of paymentsBalance of payments of Germany Time period: 1977 – 1995 Periodicity (frequency): Yearly data
- National debtIndebtedness of all public households in Germany (yearly change in %) Time period: 1967:4 – 1997:4Periodicity (frequency): Quarterly data
The following time series describes the development of the balance of payments (in Millions of DM) of Germany in the years 1977 - 1995.
The trend of these time series is estimated by the moving average method. Recall, this approach uses the formula
Since past and future values should have equal weight for the trend estimation in
, we choose
. For the smoothing of yearly data a simple moving average is applied, where all weights are identical. The weights must add to 1 over the entire supporting area, that means:
In the following table the moving average T(t) was calculated for
,
and
.
year
|
|
balance of payments
|
|
|
|
|
|
|
|
|
|
|
|
1977
|
1
|
9478
|
|
|
|
|
1978
|
2
|
18003
|
5483,3
|
|
|
|
1979
|
3
|
-11031
|
-7169,3
|
-4754,2
|
|
|
1980
|
4
|
-28480
|
-17084
|
-4676,6
|
-476
|
|
1981
|
5
|
-11741
|
-10118,3
|
-6162,6
|
2161,4
|
|
1982
|
6
|
9866
|
2899,3
|
1631,6
|
6493,4
|
|
1983
|
7
|
10573
|
16126,3
|
16993
|
20325,4
|
|
1984
|
8
|
27940
|
28946,7
|
36499,8
|
36122,1
|
|
1985
|
9
|
48327
|
54020
|
50946
|
50418,9
|
|
1986
|
10
|
85793
|
72072,3
|
66498,6
|
63874,7
|
|
1987
|
11
|
82097
|
85408,7
|
81722
|
64551,3
|
|
1988
|
12
|
88336
|
91496,7
|
75118,4
|
56000,4
|
|
1989
|
13
|
104057
|
69234
|
51576,6
|
44779,3
|
|
1990
|
14
|
15309
|
29150
|
29113
|
29186
|
|
1991
|
15
|
-31916
|
-15609,3
|
6774,4
|
12573,9
|
|
1992
|
16
|
-30221
|
-28498
|
-20875,2
|
-4876,7
|
|
1993
|
17
|
-23357
|
-29256,3
|
-30700,6
|
|
|
1994
|
18
|
-34191
|
-30455,3
|
|
|
|
1995
|
19
|
-33818
|
|
|
|
|
If
, one cannot estimate a trend for the period
, because the value of the time series is unknown in
. For
the estimated trend is
.
In the following diagram the three alternative estimations of the long-run trend and the original series are compared.
One detects two important characteristics of the procedure:
- The larger the supporting area, over which the trend is estimated, the fewer the number of values of the trend that can be estimated.
- The estimated trend becomes smoother with increased supporting area (i.e. the larger is b+a).
order of moving average domain: number (
) of past observations used for the calculation of the average.
odd order
:
Example:
|
|
|
order
|
|
|
|
n.a.
|
n.a.
|
|
|
n.a.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n.a.
|
|
n.a.
|
n.a.
|
Where n.a., in the table, means that it is not feasible to estimate the trend for this particular point in time given our data and weighting structure.
even order
:
![{\displaystyle X_{t}^{\star }={\frac {1}{2k}}\left[{\frac {1}{2}}X_{t-k}+{\frac {1}{2}}X_{t+k}+\sum _{i=t-(k-1)}^{t+(k-1)}X_{i}\right]\qquad t=k+1,\dots ,T-k}](https://wikimedia.org/api/rest_v1/media/math/render/svg/ae535ed77f622898d160a8a4de624b976e392a78)
Example:
|
|
|
order
|
|
|
|
n.a.
|
n.a.
|
|
|
n.a.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n.a.
|
|
n.a.
|
n.a.
|