# Trend of Time Series

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 English Português Français ‎Español Italiano Nederlands

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. : ${\displaystyle T(t)=\sum \limits _{i=-a}^{b}\lambda _{i}x_{t+i}\,,}$ with ${\displaystyle \sum \limits _{i=-a}^{b}\lambda _{i}=1}$ The set of weights ${\displaystyle \lambda _{i}}$ is called the filter. The selection of the filter depends on periodic/seasonal variations and the desired smoothness. We will usually employ symmetric filters (${\displaystyle a=b}$). They include future as well as past periods. If the weights ${\displaystyle \lambda _{i}}$ of a filter are equal for all ${\displaystyle i}$, 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 ${\displaystyle a}$ and ${\displaystyle b}$ 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 ${\displaystyle a=b=0}$). 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 (${\displaystyle a=b}$) are often specified so that the ${\displaystyle 2a+1}$ 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/4,\ 1/2,\ 1/4]\quad (a=1)}$ ${\displaystyle \lbrack 1/8,\ 1/4,\ 1/4,\ 1/4,\ 1/8]\quad (a=2)}$
• quarterly data ${\displaystyle \lbrack 1/8,\ 1/4,\ 1/4,\ 1/4,\ 1/8]\quad (a=2)}$ ${\displaystyle \lbrack 1/16,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/8,\ 1/16]\quad (a=4)}$
• 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)}$

Example (quarterly data): Number of newly registered cars in Berlin 1977:1 - 1989:4Filter: ${\displaystyle [1/8,\ 1/4,\ 1/4,\ 1/4,\ 1/8]}$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 ${\displaystyle t}$ and estimate the parameters of these functions. These parameter values minimize the sum of squared variations of the trend from the original data. ${\displaystyle \sum \limits _{t=1}^{T}(x_{t}-{\widehat {x}}_{t})^{2}\rightarrow \ {\text{min.}}}$ 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 ${\displaystyle X}$ depends linearly on time ${\displaystyle t}$ ${\displaystyle {\widehat {x}}_{t}=a+b\cdot t}$ The sum of the squared residuals clearly depends on the parameters ${\displaystyle a}$ and ${\displaystyle b}$ as ${\displaystyle S(a,b)=\sum \limits _{t=1}^{T}(x_{t}-{\widehat {x}}_{t})^{2}=\sum \limits _{t=1}^{T}(x_{t}-a-b\cdot t)^{2}\rightarrow \ {\text{min.}}}$ Minimization results in the following estimators of the parameters. ${\displaystyle a={\frac {\sum \limits _{t=1}^{T}x_{t}\sum \limits _{t=1}^{T}t^{2}-\sum \limits _{t=1}^{T}t\sum \limits _{t=1}^{T}x_{t}t}{T\sum \limits _{t=1}^{T}t^{2}-\left(\sum \limits _{t=1}^{T}t\right)^{2}}}}$ ${\displaystyle b={\frac {T\sum \limits _{t=1}^{T}x_{t}t-\sum \limits _{t=1}^{T}x_{t}\sum \limits _{t=1}^{T}t}{T\sum \limits _{t=1}^{T}t^{2}-\left(\sum \limits _{t=1}^{T}t\right)^{2}}}}$ Example: Price index for foreign services in Berlin, 1977:1 - 1989:4 ${\displaystyle {\widehat {x}}_{t}=99.12+1.701\cdot t\qquad R^{2}=0.9923}$ where ${\displaystyle t=0}$ corresponds to 1976:4.

### Exponential trend

Suppose that the variable ${\displaystyle X}$ exhibits an exponential dependence on time ${\displaystyle t}$ of the form ${\displaystyle {\widehat {x}}_{t}=ab^{t}\,,}$ or, similarly, in logarithmic form ${\displaystyle \log {\widehat {x}}_{t}=(\log a)t\log b}$ Least squares minimization results in the following estimators of the parameters. ${\displaystyle \log a={\frac {\sum \limits _{t=1}^{T}\log x_{t}\sum \limits _{t=1}^{T}t^{2}-\sum \limits _{t=1}^{T}t\sum \limits _{t=1}^{T}t\log x_{t}}{T\sum \limits _{t=1}^{T}t^{2}-\left(\sum \limits _{t=1}^{T}t\right)^{2}}}}$ ${\displaystyle \log b={\frac {T\sum \limits _{t=1}^{T}t\log x_{t}-\sum \limits _{t=1}^{T}\log x_{t}\sum \limits _{t=1}^{T}t}{T\sum \limits _{t=1}^{T}t^{2}-\left(\sum \limits _{t=1}^{T}t\right)^{2}}}}$ Example: Number of phones in the US (measured in ${\displaystyle 1,000s}$) 1900 - 1970 ${\displaystyle \log {\widehat {x}}_{t}=3.553645+0.021448\cdot t}$ ${\displaystyle R^{2}=0.9923}$ where ${\displaystyle t=0}$ corresponds to the year 1899. ${\displaystyle {\widehat {x}}_{t}=3,578.04\cdot (1.051)^{t}}$

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 ${\displaystyle T(t)=\sum _{i=-a}^{b}\lambda _{i}x_{t+i}\,,\ {\text{with}}\sum _{i=-a}^{b}\lambda _{i}=1\,.}$ Since past and future values should have equal weight for the trend estimation in ${\displaystyle t}$, we choose ${\displaystyle a=b}$. 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: ${\displaystyle \lambda _{i}={\frac {1}{2a+1}}\quad \forall i\,.}$ In the following table the moving average T(t) was calculated for ${\displaystyle a=1}$, ${\displaystyle a=2}$ and ${\displaystyle a=3}$.

 year ${\displaystyle t}$ balance of payments ${\displaystyle T(t)}$ ${\displaystyle T(t)}$ ${\displaystyle T(t)}$ ${\displaystyle a=1}$ ${\displaystyle a=2}$ ${\displaystyle a=3}$ 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 ${\displaystyle a=1}$, one cannot estimate a trend for the period ${\displaystyle t=1}$, because the value of the time series is unknown in ${\displaystyle t=0}$. For ${\displaystyle t=2}$ the estimated trend is ${\displaystyle (9,478)/3+(18,003)/3+(-11,031)/3=5,483.3}$. 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 (${\displaystyle k=a=b}$) of past observations used for the calculation of the average.

• odd order ${\displaystyle 2k+1}$:${\displaystyle X_{t}^{\star }={\frac {1}{2k+1}}\sum _{i=t-k}^{t+k}X_{i}\qquad t=k+1,\dots ,T-k}$

Example:

 ${\displaystyle k}$ ${\displaystyle 1}$ ${\displaystyle 2}$ order ${\displaystyle 2k+1=3}$ ${\displaystyle 2k+1=5}$ ${\displaystyle x_{1}}$ ${\displaystyle x_{1}^{\star }}$  n.a. ${\displaystyle x_{1}^{\star }}$  n.a. ${\displaystyle x_{2}}$ ${\displaystyle x_{2}^{\star }={\frac {1}{3}}\cdot \sum _{i=1}^{3}x_{i}}$ ${\displaystyle x_{2}^{\star }}$  n.a. ${\displaystyle x_{3}}$ ${\displaystyle x_{3}^{\star }={\frac {1}{3}}\cdot \sum _{i=2}^{4}x_{i}}$ ${\displaystyle x_{3}^{\star }={\frac {1}{5}}\cdot \sum _{i=1}^{5}x_{i}}$ ${\displaystyle x_{4}}$ ${\displaystyle x_{4}^{\star }={\frac {1}{3}}\cdot \sum _{i=3}^{5}x_{i}}$ ${\displaystyle x_{4}^{\star }={\frac {1}{5}}\cdot \sum _{i=2}^{6}x_{i}}$ ${\displaystyle \vdots }$ ${\displaystyle \vdots }$ ${\displaystyle \vdots }$ ${\displaystyle x_{T-2}}$ ${\displaystyle x_{T-2}^{\star }={\frac {1}{3}}\cdot \sum _{i=T-3}^{T-1}x_{i}}$ ${\displaystyle x_{T-2}^{\star }={\frac {1}{5}}\cdot \sum _{i=T-4}^{T}x_{i}}$ ${\displaystyle x_{T-1}}$ ${\displaystyle x_{T-1}^{\star }={\frac {1}{3}}\cdot \sum _{i=T-2}^{T}x_{i}}$ ${\displaystyle x_{4}^{\star }}$  n.a. ${\displaystyle x_{T}}$ ${\displaystyle x_{T}^{\star }}$  n.a. ${\displaystyle x_{T}^{\star }}$  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 2k}$:

${\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}$

Example:

 ${\displaystyle k}$ ${\displaystyle 1}$ ${\displaystyle 2}$ order ${\displaystyle 2k=2}$ ${\displaystyle 2k=4}$ ${\displaystyle x_{1}}$ ${\displaystyle x_{1}^{\star }}$  n.a. ${\displaystyle x_{1}^{\star }}$  n.a. ${\displaystyle x_{2}}$ ${\displaystyle x_{2}^{\star }={\frac {1}{2}}\left[{\frac {1}{2}}x_{1}+{\frac {1}{2}}x_{3}+x_{2}\right]}$ ${\displaystyle x_{2}^{\star }}$  n.a. ${\displaystyle x_{3}}$ ${\displaystyle x_{3}^{\star }={\frac {1}{2}}\left[{\frac {1}{2}}x_{2}+{\frac {1}{2}}x_{4}+x_{3}\right]}$ ${\displaystyle x_{3}^{\star }={\frac {1}{4}}\left[{\frac {1}{2}}x_{1}+{\frac {1}{2}}x_{5}+\sum _{i=2}^{4}x_{i}\right]}$ ${\displaystyle x_{4}}$ ${\displaystyle x_{4}^{\star }={\frac {1}{2}}\left[{\frac {1}{2}}x_{3}+{\frac {1}{2}}x_{5}+x_{4}\right]}$ ${\displaystyle x_{3}^{\star }={\frac {1}{4}}\left[{\frac {1}{2}}x_{2}+{\frac {1}{2}}x_{6}+\sum _{i=3}^{5}x_{i}\right]}$ ${\displaystyle \vdots }$ ${\displaystyle \vdots }$ ${\displaystyle \vdots }$ ${\displaystyle x_{T-2}}$ ${\displaystyle x_{T-2}^{\star }={\frac {1}{2}}\left[{\frac {1}{2}}x_{T-3}+{\frac {1}{2}}x_{T-1}+x_{T-2}\right]}$ ${\displaystyle x_{T-2}^{\star }={\frac {1}{4}}\left[{\frac {1}{2}}x_{T-4}+{\frac {1}{2}}x_{T}+\sum _{i=T-3}^{T-1}x_{i}\right]}$ ${\displaystyle x_{T-1}}$ ${\displaystyle x_{T-1}^{\star }={\frac {1}{2}}\left[{\frac {1}{2}}x_{T-2}+{\frac {1}{2}}x_{T}+x_{T-1}\right]}$ ${\displaystyle x_{T-1}^{\star }}$ n.a. ${\displaystyle x_{T}}$ ${\displaystyle x_{T}^{\star }}$  n.a. ${\displaystyle x_{T}^{\star }}$   n.a.