0% found this document useful (0 votes)
42 views13 pages

Seasonality and Trend

Uploaded by

kipropnathan15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views13 pages

Seasonality and Trend

Uploaded by

kipropnathan15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CS2-14: Time series 2 Page 3

1 Compensating for trend and seasonality


All the methods which we shall investigate in Sections 3 and 4 apply only to a time series
which gives the appearance of stationarity. In this section, therefore, we deal with possible
sources of non-stationarity and how to compensate for them.

A simple time series plot in R can be generated as:

ts.plot(x)

where x is some (vector) time series data.

Lack of stationarity may be caused by the presence of deterministic effects in the quantity
being observed. Monthly sales figures for a company which is expanding rapidly would be
expected to show a steady underlying increase, possibly linear or perhaps even
exponential. A company which sells greetings cards will find that the sales in some months
of the year will be much higher than in others. In both cases there is an underlying
deterministic pattern and some (possibly stationary) random variation on top of that. In
order to predict sales figures in future months it is necessary to extrapolate the
deterministic trends as well as to analyse the stationary random variation.

A further cause of non-stationarity may be that the process observed is the integrated
version of a more fundamental process; in these cases, differencing the observed time
series may produce a series which is more likely to be a realisation of some stationary
process.

In summary, we have identified three possible causes of non-stationarity:

1. a deterministic trend (eg exponential or linear growth)

2. a deterministic cycle (eg seasonal effect)

3. the time series is integrated.

It is worth pointing out that this list is not exhaustive. For example, the first two causes are just
specific cases of general deterministic behaviour. In theory, this could take many different forms,
but trends and cycles are the most likely to be met in practice.

The items on the list are not mutually exclusive either. Consider a simple random walk with
probability 0.6 of stepping up, and 0.4 of stepping down. This can be represented by the
equation:

X n  X n1  Z n

where:

1 with probability 0.6


Zn  
1 with probability 0.4

together with the condition that X 0  0 .

This process is I(1) since the first difference is stationary, but the process itself is not.

The Actuarial Education Company © IFE: 2019 Examinations


Page 4 CS2-14: Time series 2

On the other hand, the process also has a increasing deterministic trend:

E[ X n ]  E[ Z1  Z2    Z n ]  E[ Z1 ]  E[ Z2 ]    E[ Z n ]  0.2n

We consider in the following sections how to detect and remove such causes of non-stationarity.

1.1 Detecting non-stationary series


The most useful tools in identifying non-stationarity are the simplest: a plot of the series
against t , and the sample ACF.

The sample ACF is an estimate of the ACF based on sample data. It is defined in Section 2.1.

Plotting the series will highlight any obvious trends in the mean and will show up any cyclic
variation which could also form evidence of non-stationarity. This should always be the
first step in any practical time series analysis.

The R code below uses the ts.plot function.

(It also assumes we have a list of FTSE100 data values.)

ts.plot(log(FTSE100$Close))
points(log(FTSE100$Close),cex=.4)

generates Figure 14.1, which shows the time series of the logs of 300 successive closing
values of FTSE100 index.

Figure 14.1: 300 successive closing values of the FTSE100 index, Jan 2017 – Mar 2018;
log-transformed

© IFE: 2019 Examinations The Actuarial Education Company


CS2-14: Time series 2 Page 5

The corresponding sample ACF and sample PACF are produced using:

par(mfrow=c(1,2))
acf(log(FTSE100$Close))
pacf(log(FTSE100$Close))

These are shown in Figure 14.2 below.

Figure 14.2: Sample ACF and sample PACF of the log(FTSE100) data; dotted lines indicate
cut-offs for significance if data came from some white noise process.

The sample ACF should, in the case of a stationary time series, ultimately converge towards
zero exponentially fast, as for AR (1) where  s   s .

The function  s   s , s  0,1,2,... has exponential decay if | | 1 as this is a power function


whose values are:

1,  ,  2 ,  3 , …

and this sequence tends to 0 as the power s tends to  .

If the sample ACF decreases slowly but steadily from a value near 1, we would conclude
that the data need to be differenced before fitting the model. If the sample ACF exhibits a
periodic oscillation, however, it would be reasonable to conclude that there is some
underlying cause of the variation.

The Actuarial Education Company © IFE: 2019 Examinations


Page 6 CS2-14: Time series 2

Figure 14.2 shows the sample ACF of a time series which is clearly non-stationary as the
values decrease in some linear fashion; differencing is therefore required before fitting a
stationary model.

See, for example, the change of ACF and PACF for the differenced data:

Figure 14.3: Data plot, sample ACF and sample PACF of ln(FTSE100).

The ACF for a stationary ARMA(p, q) process decays fairly rapidly. For example, we have seen
that the ACF of a moving average process cuts off sharply, and the ACF of an AR(1) process has
exponential decay:   k    . In theory, this could still actually lead to a slow decay if the
k

values of p and/or q were high, (eg the autocorrelation of an MA(100) process wouldn’t cut off
until lag 100), but in practice the parameter values will be fairly small. If many parameters are
used then the resulting model may give a good fit to the sample data, but it is unlikely to be useful
for forecasting. A fairly slow decay of the sample autocorrelation function is therefore more likely
to be interpreted as an indication that the time series needs to be differenced before being
modelled.

If the sample autocorrelation function oscillates without decaying rapidly, as we will see in the
hotel example in Section 1.4, then we might conclude that there is an underlying deterministic
cycle. This would have to be removed before fitting a model to the residuals.

We now look at two methods for removing a linear trend.

© IFE: 2019 Examinations The Actuarial Education Company


CS2-14: Time series 2 Page 7

1.2 Least squares trend removal


The simplest way to remove a linear trend is by ordinary least squares. This is equivalent to
fitting the model:

xt  a  bt  y t

where a and b are constants and y is a zero-mean stationary process. The parameters a
and b can be estimated by linear regression prior to fitting a stationary model to the
residuals y t .

The formulae for estimating a and b are given on page 24 of the Tables.

1.3 Differencing
Differencing may well be beneficial if the sample ACF decreases slowly from a value near 1,
but has useful effects in other instances as well. If, for instance, xt  a  bt  y t , then:

x t  b   y t

so that the differencing has removed the trend in the mean.

Differencing a series d times will make an I(d) series stationary. In addition however,
differencing once will also remove any linear trend, as above.

On the other hand, we could remove the linear trend by using linear regression, as in Section 1.2.
However, if the series is actually I(1) with a trend, then least squares regression will only remove
the trend. We will still be left with an I(1) process that is non-stationary.

For example, consider the simple random walk discussed earlier, which has probability 0.6 of
stepping up, and 0.4 of stepping down:

X n  X n1  Z n

where:

1 0.6
Zn  
1 0.4

We have seen that this process has an increasing trend and that E[ X n ]  0.2n . If we let
Yn  X n  0.2n , then E[Yn ]  0 . So we have removed the trend. However, since:

Yn  Yn 1  Z n  0.2

we are still left with an I(1) process that needs to be differenced in order to be stationary.

We now look at three methods for removing cycles (seasonal variation).

The Actuarial Education Company © IFE: 2019 Examinations


Page 8 CS2-14: Time series 2

1.4 Seasonal differencing


Where seasonal variation is present in the data, one way of removing it is to take a seasonal
difference.

Example 1
Suppose that the time series x records the monthly average temperature in London. A
model of the form:

xt    t  y t (14.1)

might be applied, where  is a periodic function with period 12 and y is a stationary series.
Then the seasonal difference of x is defined as   12 x t  x t  x t 12 and we see that:

(12 x )t  xt  xt 12  (   t  y t )  (   t 12  y t 12 )  y t  y t 12

is a stationary process.

We can then model the seasonal difference of x as a stationary process and reconstruct the
original process x itself afterwards.

We can use R to plot the time series data and to remove seasonal variation.

© IFE: 2019 Examinations The Actuarial Education Company


CS2-14: Time series 2 Page 9

Figure 14.4 below is generated from the following lines in R, where functions ts.plot, acf
and pacf are used:

layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))


ts.plot(manston1$tmax,ylab="", main="Max temperatures observed at
each month (2010-2017), Manston, UK")
points(manston1$tmax,cex=0.4)
acf(manston1$tmax,main="")
pacf(manston1$tmax,main="")

This code assumes that there is a list of data stored as ‘manston1’.

Figure 14.4: Data plot, sample ACF and PACF of temperature data.

The Actuarial Education Company © IFE: 2019 Examinations


Page 10 CS2-14: Time series 2

Seasonal differencing 12 seems to have removed the seasonal behaviour of the data. See
Figure 14.5 generated from:

layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))


ts.plot(diff(manston1$tmax,lag=12),ylab="", main="Seasonal
differenced temperature data")
points(diff(manston1$tmax,lag=12),cex=0.4)
acf(diff(manston1$tmax,lag=12),main="")
pacf(diff(manston1$tmax,lag=12),,main="")

Figure 14.5: Temperature data after appropriate differencing

Example 2
The monthly inflation figures are obtained by seasonal differencing of the Retail Prices
Index. If x t is the value of the RPI in month t , the annual inflation figure reported is:

xt  xt 12
 100%
xt 12

© IFE: 2019 Examinations The Actuarial Education Company


CS2-14: Time series 2 Page 11

1.5 Method of moving averages


The method of moving averages makes use of a simple linear filter to eliminate the effects
of periodic variation.

A linear filter is a transformation of a time series x (the input series) to create an output series y
that satisfies:


yt   ak xt k
k 

The collection of weights ak : k  Z forms a complete description of the filter. The objective of
the filtering is to modify the input series to meet particular objectives, or to display specific
features of the data. For example, an important problem in analysis of economic time series is
detection, isolation, and removal of deterministic trends.

In practice a filter ak : k  Z normally contains only a relatively small number of non-zero
components.

A very simple example of a linear filter is the difference operator   1  B . Using this filter
produces:

yt  (1  B) xt  xt  xt 1

So, in this case, we have a0  1 , a1  1 and ak  0 for all other values of k .

As a second example, suppose that the input series is a white noise process e , and the filter takes
the form:

a0  1, a1  1 , , aq  q and ak  0 for all other values of k

Then the output series is MA(q) , since we have:

q
yt   k et k
k 0

Conversely, applying a filter of the form:

a0  1, a1  1 , , ap   p and ak  0 for all other values of k

to an input series x that is AR(p) recovers the original white noise series:

p
yt  xt    k xt k  et
k 1

The Actuarial Education Company © IFE: 2019 Examinations


Page 12 CS2-14: Time series 2

If x is a time series with seasonal effects with even period d  2h , then we define a
smoothed process y by:

yt 
1 1
2h 2  1
x t  h  x t  h  1    x t 1  x t    x t  h 1  x t  h
2 
This ensures that each period makes an equal contribution to y t .

For example, with quarterly data a yearly period will have d  4  2h , so h  2 and we have:

11 1 
yt   xt 2  xt 1  xt  xt 1  xt 2 
42 2 

In this case the filter has weights:

1 for k  2,2
8

ak   14 for k  1,0,1

0 otherwise

This is a centred moving average since the average is taken symmetrically around the time t .
Such a centred moving average introduces the practical problem that the average can only be
calculated in retrospect, ie there will be a natural delay.

The same can be done with odd periods d  2h  1 , but the end terms xt  h and xt  h do not
need to be halved.

For example, with data every 4 months, a yearly period will have d  3  2h  1 , so h  1 and we
have:

1
yt   xt 1  xt  xt 1 
3

In this case the filter has weights:


1 for k  1,0,1
ak   3
0 otherwise

As with most filtering techniques, care must be taken lest the smoothing of the data
obscure the very effects which the procedure is intended to uncover.

The method of taking moving averages is one example of a series of approaches known as filtering
techniques. We lose some of our knowledge about the variation in the data in exchange for
(hopefully) a clearer picture of the underlying process.

© IFE: 2019 Examinations The Actuarial Education Company


CS2-14: Time series 2 Page 13

1.6 Method of seasonal means


The simplest method for removing seasonal variation is to subtract from each observation
the estimated mean for that period, obtained by simply averaging the corresponding
observations in the sample.

Recall that the model in Equation 14.1 has the form:

xt    t  yt

where  is a periodic function with period 12 and y is a stationary series. The term t contains
the deviation of the model at time t due to the seasonal effect. So:

yt  xt    t

When fitting the model in Equation 14.1 to a monthly time series x extending over 10 years
from January 1990 the estimate for  is x and the estimate for  January is:

1
ˆJanuary  (x  x13  x 25    x109 )  ˆ
10 1

So, in this case, we can remove the seasonal variation by deducting the January average,
1
x January  (x  x13  x25    x109 ) , from all the January values, deducting the February
10 1
1
average, xFebruary  (x  x14  x26    x110 ) , from all the February values, etc.
10 2
Alternatively, we could deduct ˆJanuary from all the January values, ˆFebruary from all the
February values, etc.

In R the function decompose can be used to obtain both the moving average and seasonal
means described in Sections 1.5 and 1.6.

ts.plot(manston1$tmax,ylab="", main="Max temperatures")


points(manston1$tmax,cex=0.4)

The time series data is plotted as in Figure 14.6 below.

decomp=decompose(ts(manston1$tmax,frequency = 12),type="additive")

The decomposition is saved as decomp.

The moving average can be added (in red) using the code:

lines(as.vector(decomp$trend),col="red")

The sum of seasonal and moving average trends can be added (in blue) as follows:

lines(as.vector(decomp$seasonal+decomp$trend),col="blue")

The resulting graph is shown below. A colour version is also available online in the tuition
materials for the R part of CS2.

The Actuarial Education Company © IFE: 2019 Examinations


Page 14 CS2-14: Time series 2

Figure 14.6: Temperature data and its decomposition into moving average (in red) and
seasonal trend (in blue) added.

1.7 Transformation of the data


Diagnostic procedures such as an inspection of a plot of the residuals may suggest that
even the best-fitting standard linear time series model is failing to provide an adequate fit to
the data. Before attempting to use more advanced non-linear models it is often worth
attempting to transform the data in some straightforward way in an attempt to find a data
set on which the linear theory will work properly.

An example of a simple transformation would be Yt  log Xt , which would be used to remove an


exponential growth effect.

Variance-stabilising transformations
Transformations are most commonly used when a dependence is suspected between the
variance of the residuals and the size of the fitted values. If, for example, the standard
deviation of X t 1  X t appears to be proportional to X t , then it would be appropriate to use
the logarithmic transformation, to work on the time series Y  ln X .

© IFE: 2019 Examinations The Actuarial Education Company


CS2-14: Time series 2 Page 15

Transformations to increase normality


In certain applications it may be found that most residuals are small and negative, with a
few large positive values to offset them. This may be taken to indicate that the distribution
of the error terms is non-normal, leading to doubts as to whether the standard time series
procedures, designed for normal errors, are applicable. It may be possible to find a
transformation which will improve the normality of the error terms of the transformed
process, but care should be taken that this does not lead to instability in the variance. A
further caution when using transformed data involves the final step of turning forecasts for
the transformed process into forecasts for the original process, as some transformations
introduce a systematic bias.

The Actuarial Education Company © IFE: 2019 Examinations

You might also like