Time Series
Time Series
COURSE OUTLINE
REFERENCE BOOKS
1
1. Fundamental of Applied Statistics by Gupta and Kapor.
INTRODUCTION
Denition
A time series is a collection of observations met sequentially in time.i.e
its an arrangement of statistical data in accordance with time.
EXAMPLES
Economic time series
They include series such as shared prices in successive days,average in-
comes in successive months,export sales totals in successive months etc.
• Physical Time Series The many types of time series occur in physical
scenes particularly in marine science,meteorology and geophysics eg
successive hours,days and months.
1. Descriptive Purpose
2
When presented with time series,the rst step in the analysis is usually
to plot the data and obtain descriptive measures of the main properties
of the series.Features such as trends and seasonal eects can sometime
be easily seen from such a plot.
The plot will also enable one to look for unusual observation s and
outliers which don't appear to be consistent with the rest of the data.
2. EXPLANATION PURPOSE
When observations are taken on two or more variables ,it may be pos-
sible to use variation in the other variable to explain variation in the
other variable.This may lead to deeper understanding of the mecha-
nism which generated the given series.i.e We develop a structural model
which governs the generation of such a series.
3. PREDICTION PURPOSE
Given an observed time series future values of the time series may
be predicted.This is important task in shares forecasting and in the
analysis of economic and industrial time series.
4. CONTROL PURPOSE:
Using the structural model in (2) above,one may seek to control the
system by either generating warning signals of future events or by ex-
amining what would happen if the inputs of the system are altered
3
Several jointly dependent variables are considered to come up with a
statistical model.
Terminologies used
• Stochastic Time Series:Most time series are stochastic in the sense that
future is only partly determined by past values so that exact prediction
is impossible and must be replaced by the idea that future values have a
probability distribution which is conditioned by the knowledge of past
values.
1. Trend/secular trend.
4
2. Seasonal variation.
3. Cyclic variation
4. Irregular/random movement.
Trend/Secular trend:
Trend is the general tendency of data to increase or decrease over a long
period of time.
5
Diagram
6
Remarks:
• Trend is the result of loose forces which are either constant or change
very gradually over a long period of time.
• The term long period of time cannot be dened precisely .In some
cases,a period as long as 1 week may be long while in some other cases
2 years may not be termed as long period.
• Apart from upward and downward tendency,we may also have some
time series whose values uctuate round a constant reading which
doesn't change with time.E.g time series of temperature reading of a
particular place.
diagram
7
8
Seasonal variations
These are periodic and regular movements in a time series with a period
of less than one year.
E.g sales and prots in a store.
Seasonal variations may be attributed to 2 causes.
E.g sales and prots of some goods during festivities are related
9
to man-made forces
Cyclic variations
These are oscillatory movements in time series with a period of oscillation
which is more than one year.
Cyclic variations exhibit variations at a xed period greater than one
year.An important example are the so called business cycles representing
intervals of prosperity,recession,depression and recovery.
Random/irregular movements
These are not accounted for by secular trend ,seasonal or cyclic trend
variations.They are purely random,unpredictable and beyond human control.
They include drought,war,oods,earth quakes,epidemics,university strike
etc.
ANALYSIS OF TIME SERIES:
The main problem in time series analysis are:
(a) Statistical techniques for analysis of time series range from simple
descriptive methods to sophisticated inferential techniques.
10
• Analysis of time series in time domain(classical)
1. Additive model:
Xt = Tt + St + Ct + et
where
11
Ct :cyclic value at time t
2. Multiplicative model
• Measure/estimate trend
Measurement of trend
Trend can be studied/measured by the following methods:
1. Graphical method
2. Method of semi-squares.
12
4. Method of removing averages.
Graphical Method
The time series Xt can be plotted against the time t to obtain a free hand
smooth curve.This enables us to have an idea about the general trend of the
series i.e it could be upward,downward ,or constant trend.
Smoothing of the curve eliminates both regular St and irregularet uctu-
ations.
Merits
Demerits:
2. The method does not measure trend,it just gives directions of the trend.
METHOD OF SEMI-SQUARES
The procedure is as follows
• Compute the arithmetic mean for each part and plot these averages
against the mid values of the respective periods covered by each part.
13
• Join the two points to obtain the required trend line,which can be used
to estimate the intermediate /future values.
Merits
1. The method is objective i.e everyone who applies the method gets the
same result.
Demerits:
It assumes linear relationship between the plotted points which may not
exist.
Method of curve tting
The method aims at coming up with a curve/line that minimizes deviation
from the data points to the line of best t.
The various types of curves that are commonly used in practice are as
follows
1. A straight line
Xt = a + bt + et
Xt = a + bt + ct2 + et
14
3. Exponential Curves
Xt = abt + et
Xt = a + bct + et .
Xt − Xt−1 = constant.
Xt = constant
15
implies
Xt
= constant.
Xt−1
(d) diagram
where a =intercept
b=gradient
et =random/error term
To t this in straight line we use the least square method.i.e
et = Xt − a − bt
X n
X
e2t = (Xt − a − bt )2
t=1
16
Let
n
X
z= (xt − a − bt)2
t=1
dz
= 0
da
Pn
t=1 (Xt − a − bt) = 0
(1)
P X
na + b t = Xt
again
dt
= 0
db
P
t(Xt − a − bt) = 0
(2)
X
a t + b t2 =
P P
tXt
17
X X
na = Xt − b t
P P
Xt b t
â = −
n n
= X t − b̂t
P P P
n tXt − t Xt
b̂ = P P
n t2 − ( t)2
Xt = â + b̂t
Xt = abt + et
Yt = A + Bt + Et (3)
18
get the estimates
Let
X
Z= (Yt − A − Bt)2
X X
Yt = nA + B t
X X X
tYt = a t+B t2
 = Y t − B̂t
P P P
n tYt − t Yt
B̂ = P P
n t2 − ( t)2
â = eÂ
b̂ = eB̂
Example 1
The table below shows the gures of production in 1000 turns of sugar
factory
Year 1963 1965 1966 1967 1968 1969 1972
production 67 88 94 85 91 98 90
nd
19
• Fit a straight line using the method of least squares and tabulate the
trend values.
solution
Let the trend in question be
Xt = a + bt + et
X X
Xt = na + b t
X X X
tXt = a t+b t2
Since n=7 is odd,we select the time t such that the middle time t=0.
NB:
If the sample size n is even,we select either of the two points to be zero.
We use the following table in the estimation of the constants a and b in
normal equations.
20
Year t productionXt t2 tXt trend values:Xt = â + b̂t
1963 -4 67 16 -268 78.5
1965 -2 88 4 -171 82.88
1966 -1 94 1 -94 85.07
1967 0 85 0 0 87.26
1968 1 91 1 91 89.45
1969 2 98 4 196 91.66
1972 5 90 25 450 98.21
t2 = 51
P P P P
t=1 Xt = 613 tXt = 199
7a + b = 613
a + 51b = 199
356b = 780
780
b̂ = = 2.19
356
613 − 2.19
â = = 87.26
7
Xt = â + b̂t
= 87.26 + 2.19t
21
Assuming the additive model of time series we eliminate the trend values
by subtracting the trend from the given values as shown in the following
tabe:
Year Xt − trend value
1963 -11.5
1965 5.12
1966 8.93
1967 -2.26
1968 1.55
1969 6.36
1972 -8.21
The resulting values shows uctuations which change with a period of
more than one year.
NB
After eliminating the trend values one should be able to identify the
variation left.i.e whether seasonal,cyclic or random.
iii) b̂ increments,NB:We use the gradient which is the estimate of monthly
b̂
=
12
2.19
=
12
= 0.1825
iv)Estimate of 1970
22
solution
t=3
Then substitute in
Xt = â + b̂t
Xt = 93.83
EXAMPLE 2
The table below shows the population in millions of a certain country:
Year(X) 1929 1939 1949 1959 1969 1979 1989
pop(Y) 25 25 27.9 31.9 36.1 43.9 54.7
1. Fit an exponential curve
Y = abx + et
SOLUTION
1.
Y = abx + et
23
hence we need to nd â and b̂
V = A + Bx + Et
Shift the origin x to 1959 and change the scale by dening a new vari-
able t where
x − 1959
t =
10
V = A + Bt + Et · · · (4)
X X
V = nA + B t
X X X
tV = A t+B t2
24
Year(X) pop(Y) t = X−1959
10
V = lnY t2 tV trend Trend values
values for for
V Y=anti-log
1929 25 -3 3.2188 9 -9.6564 3.116 22.56
1939 25 -2 3.2228 4 3.249 25.72
1949 27.9 -1 3.3286
1959 31.9 0 3.4626 0
1969 36.1 1 3.5863 1
1979 43.9 2 3.7819 4
1989 54.7 3 4.0018 9 12.0054 3.914 50.05
Now,
X
t = 0
X
t2 = 28
X
V = 24.6028
X
tV = 3.7249
25
Since
X
t = 0
X
=⇒ B t = 0
24.6028 = 7A
24.6028
 = = 3.51468
7
3.7249 = 28B
3.7249
B̂ = = 0.133
28
If
A = lna
â = eÂ
= e3.51468 = 33.605
If
B = lnb
b̂ = eB̂
= e0.133 = 1.142
26
Thus the trend line
= Y = âb̂x
= 33.605(1.142)x
V = Â + B̂t
= 3.515 + 0.133t
ii)population in 1999
=57.23
GROWTH CURVE
The method of least squares cannot be used in growth curves because the
number of parameters to be estimated exceeds the number of known variables
.Therefore some special techniques are required:
Xt = a + bct + et (5)
procedure
27
• Choose 3 coordinates say
X1 , X2 , X3
t1 , t2 , t3
t2 − t1 = t3 − t2
X1 = a + bct1 (6)
X2 = a + bct2 (7)
X3 = a + bct3 (8)
(iii) − (ii) = X2 − X1
= b(ct2 − ct1 )
28
(iv) − (iii) = X3 − X2
(vi) X3 − X2
=
(v) X2 − X1
bct2 (ct3 −t2 − 1)
=
bct1 (ct2 −t1 − 1)
= c
since
t3 − t2 = t2 − t1
X3 − X2 t −t
1
ĉ = ( )2 1
X2 − X 1
(X2 − X1 )2 X2 − X1 t t−t
1
b ˆ=(( )( )2 1
X3 − 2X2 + X1 X3 − X2
again
X1 = a + bct1
a = X1 − bct1
29
(X2 − X1 )2 X2 − X1 t t−t
1 X3 − X2 t −t
1
â = X1 − [ ]( ) 2 1( )2 1
X3 − 2X2 + X1 X3 − X2 X2 − X1
X1 X3 − X22
â =
X3 − 2X2 + X1
Xt = â + b̂ĉt
t
Xt = abc + et
Yt = A + Bct + Et (11)
k
Xt = + et
1 + exp(a + bt)
30
estimated.Assuming the error term
k
Xt =
1 + ea+bt
1 ea bt
= + e
k k
∴ Yt = A + BC t · · · eqn(i1)
where
1
Yt =
Xt
1
A =
k
ea
B =
k
C = eb
The method measures the trend by smoothing out the uctuation of the
data by means of moving averages.Moving averages of extent (period) m ,is
a series of successive averages of M-terms starting with 1st,2nd term etc.
The rst average is the mean of the rst M-terms,2nd average is the mean
of M-terms starting with the 2nd term to M+1 term.
If M is odd i.e M=2k+1,the rst moving average is placed against the
31
mid-value of the time interval it covers,i.e against K+1.eg
t observation M.A
1 3 -
2 4 (3+4+10)/3
3 10 (4+10+8)/3
M=3,we have
4 8 (10+8+7)/3
5 7 (8+6+9)/3
6 6 (7+6+9)/3
7 9 -
If M is even i.e M=2k,the rst moving average is placed between two
moving values of the time interval it covers.
eg M=4
t observation M.A
1 3
2 4
3 5
4 6
5 7
6 8
7 9
The moving average does't coincide with the original time period hence
we centered moving average by taking M.A of extent 2 of moving averages
and putting the rst of these values against time t =k+1.
32
The graph obtained on plotting moving average against time gives the
trend.
The main problem in moving average level is determining the period
of moving average that will completely remove the oscillatory movements
aecting the series.
If the uctuations are regular and periodic,then the moving average com-
pletely remove the oscillatory movements provided:
Demerits
The method does not provide trend values for all the terms eg for a moving
average of extend M=2k+1,the trend values of the rst k and last k terms of
the series are forgone.
The method cannot be used to predict future trend ,which is one of the
main objective of trend analysis.
NB:
Moving average method gives a correct feature of the long term trend of
the series if:
33
If the trend is not linear,the M.A introduces bias in the trend values.
Example
A study demand (dt) for the past 12yrs(t=12) has indicated the following
observations.
dt = 100, t = 1, 2, 3, 4, 5
dt = 20, t = 6
t=k+1=3
34
t dt 5year M.A
1 100 -
2 100 100
3 100 84
4 100 84
5 100 84
6 20 84
7 100 84
8 100 84
9 100 100
10 100 100
11 100 -
12 100 -
Example2
Assuming a 4 yearly cycle,calculate the trend using the method of moving
average from the following data
35
t year production 4-yearly M.A centered M.A
1 1961 464 -
2 1962 515 -
3 1963 518 495.75
4 1964 467 503.6
5 1965 502 511.6
6 1966 540 529.5
7 1967 570 553.0
8 1968 571 572.5
9 1969 586 -
10 1970 612 -
In this approach,the measurement of trend consists
• Using the polynomial to estimate the value in the middle range .this
means that we use an odd number of terms.
36
Let the polynomial of 1st degree by
X t = a0 + a1 t (12)
Xk , X(k−1) · · · X−1 , X0 , X1 · · · Xk
We wish to estimate the value of the middle term the value of middle term
i.e when t = 0 eqn(1) becomes X0 = a0 .To estimate a0 ,we use the principle of
least squares and if we estimate a0 ,we shall have estimated the middle term
X0 .
from eqn(1), the normal equations are
k
X k
X
Xt = (2k − 1)a0 + a1 t
t=−k t=−k
X
z = (Xt − a0 − a1 t)2
dz
da0
=0
Pk
∴ t=−k t =0
P
Xt
∴ a0 = ··· (13)
2k + 1
37
middle term is â0 is given by â0 = 1
P
X
2k+1 t
The coecient of Xj in the moving average i.e (in â0 ) is called the weight
of jth term(j = 1, 2 · · · M ).
1 1
Cj = = , j = 1, 2 · · · M
2k + 1 m
we write
[M, 1] = [c1 , c2 , · · · cm ]
1 1 1
= [ , ,··· ]
m m m
1
= [1, 1, · · · 1]
m
NB
m
X 1
cj =
j=1
m
m
=
m
=1
CASE 2
38
M = 2k + 1, p = 2 =⇒ [M, 2]
be
Xt = a0 + a1 t + a2 t2
X X X
Xt = (2k + 1)a0 + a1 t + a2 t2
X X X
t2 + a1 t 2 + a2 t3
P
tXt = a0
X X X
t2 + a1 t3 + a2 t4
P 2
t X t = a0
but
X X
t= t3 = 0
39
if its true,the above equations reduce to
X X
Xt = (2k + 1)a0 + a2 t2
X X
t 2 Xt t2 + a2 t4
P
= a0
X X X X X
Xt t4 = (2k + 1)a0 t 4 + a2 t2 t4
X X X X X X
t2 Xt t2 = a0 t2 t2 + a2 t4 t2
X X X XX X X
(2k + 1)a0 t4 − a0 t2 t2 = Xt t4 − t2 Xt t2
P P 4 P 2 P 2
Xt t − t Xt t
â0 = P P (14)
(2k + 1) t4 − ( t2 )2
but
k
X k
X
2
t = 2 t2
t=−k t=−1
2k(k + 1)(2k + 1)
=
6
40
also
k
X k
X
4
t = 2 t4
t=−k t=1
2k(k + 1)(2k + 1)(3k 2 + 3k − 1)
=
30
2k(k+1)(2k+1)(3k2 +3k−1) Xt
P P 2
t Xt 2k(k+1)(2k+1)
30
− 6
â0 = 2k(k+1)(2k+1)(3k2 +3k−1) 2k(k+1)(2k+1) 2
30
−( 6
) af ter
(3k 2 + 3k − 1) Xt − 5 t2 Xt
P P
â0 = 3[ ] (15)
(2k + 1)(2k − 1)(2k + 3)
(3k 2 + 3k − 1) − 5t2
(16)
X
= {3[ ]Xt } · · ·
(2k + 1)(2k − 1)(2k + 3)
(3k 2 + 3k − 1) − 5j 2
cj = 3[ ]··· (17)
(2k + 1)(2k − 1)(2k + 3)
−3 12 17 12 −3
c−2 = , c−1 = , c0 = , c1 = , c2 =
35 35 35 35 35
41
∴ [5, 2]
1
[−3X−2 , 12X−1 , 17X0 , 12X1 − 3X2 ]
35
NB
Weight are systematic over their weighted value and sum is a unit.
EXERCISE
Find MP=[7,2] and MP[9,2] in a similar manner.
Xt 0 1 8 27 64 125 216 343 512 729
Consider the series
t 1 2 3 4 5 6 7 8 9 10
compute trend value at time t=4 using weight [5,2]
42
solution
moving average
1
[5, 2] = [−3, 12, 17, 12, −3]
35
1
= [−3Xt−2 , 12Xt−1 , 17Xt , 12Xt+1 , −3Xt+2 ]
35
1
= [−3(1), 12(8), 17(27), 12(64), −3(125)]
35
1
= [−3, 96, 459, 768, −375]
35
CASE 3
[M = 2k + 1, p = 3]
Xt = a0 + a1 t + a2 t2 + a3 t3 .
43
We estimate a0 using the following normal equations:
X X X X
Xt = (2k + 1)a0 + a1 t + a2 t2 + a3 t3
X X X X
t2 + a2 t3 + a3 t4
P
tXt = a0 t + a1
X X X X
t2 + a1 t3 + a2 t4 + a3 t5
P 2
t Xt = a0
X X X X
t3 + a1 t4 + a2 t5 + a3 t6
P 3
t Xt = a0
But
X X X
t= t3 = t5 = 0,
X X
Xt = (2k + 1)a0 + a2 t2
X X
t 2 Xt t2 + a2 t4
P
= a0
These equations are similar for the case when p=2 and so get some results
as in case 2.
Exercise
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
90 95 98 99 100 98 96 94 97 102 99
1. Obtain weights of moving averages if a polynomial of order 3 was to be
tted in a set of points.
2. Calculate trend value for 1990,in the data below using the results above.
44
Analysis of Time Series containing seasonal variations:
45
• Express original data as a % of the trend values .
k = 1200
k = 400
sum of preliminary seasonal indices for monthly and quarterly data respec-
tively.
Example
Calculate the seasonal variation for the following data using the ratio to
trend method.
46
Year Q1 Q2 Q3 Q4
1970 30 40 36 34
1971 34 52 50 44
1972 40 58 54 48
1973 54 76 68 62
1974 80 72 86 82
Solution:
Determine trend values for the yearly average Xt using the method of
least squares method;
i.e
Xt = a + bt
X
t2
P
Xt = na + b
47
P
Xt 280
∴ â = = = 56
Pn 5
tX 120
b̂ = P 2t = = 12
t 10
∴ Xt = â + b̂t = 56 + 12t
respectively
The trend value of rst quarter of 1970 is:
30.5 − 3 = 27.5
The trend value of 4th quarter of 1970:
33.5 + 3 = 36.5
We get the following table
48
Year Q1 Q2 Q3 Q4
1970 27.5 30.5 33.5 36.5
1971 39.5 42.5 45.5 48.5
1972 51.5 54.5 57.5 60.5
1973 63.5 66.5 69.5 72.5
1974 75.5 78.5 51.5 84.5
1. Express original data as a percentage of trend value to eliminate the
trend:
Year Q1 Q2 Q3 Q4
1970 109.5 131.1 107.1 93.1
1971 86.1 112.4 109.9 90.7
1972 77.7 106.4 93.9 70.3
1973 85.5 114.3 97.8 85.5
1974 106.0 117.1 105.5 97.0
463.9 591.3 514.6 445.6
463.9
Q1 = 5
= 92.78
591.3
Q2 = 5
= 118.26
514.6
Q3 = 5
= 102.92
445.6
Q4 = 5
= 89.12
49
total = 403.08
400
k=
sum of P SI
Q1 = 92.1
Q2 = 117.4
Q3 = 102.1
Q4 = 88.4
i.e
400
= 0.992
403.08
e.g Q1 = 92.78 ∗ 0.992 = 92.1
50
• calculate the centered 12 month MA averages of the data.
1200
k=
sum of preliminary seasonal indices
EXAMPLE
Use the ratio to moving average method to obtain the seasonal indices
from the following data.
MEASUREMENT OF CYCLIC MOVEMENT
51
A crude method of measuring cyclic uctuation(ct ) of a time series Xt con-
sists of eliminating the trend Tt and seasonal variation St and then removing
the random component et by averaging them.Using the multiplicative model,
Xt = Tt + Ct + St + et
1. Calculate the trend value Tt using the least squares method and seasonal
index which is to be taken in fractional form and not in percentage form.
2. Divide Xt by Tt .St
Example
From the previous example on ratio to trend method,obtain the cyclic
variations from the data.
solution
From this previous example,we have computed the trend values Tt and
seasonal index (adjusted SI).
We have also eliminated the trend values.Seasonal eects are eliminated
by dividing the eliminated trend values by the adjusted seasonal index and
multiplying them by 100 to get a variable Y .For instance,we eliminate sea-
sonal eect for the rst quarter of 1970 as follows:
52
109.1 109.1
× 100 = × 100 = 118.5
adjusted SI 92.1
cyclic variation=Y-100
Year Q1 Q2 Q3 Q4
1970 18.5 11.7 5.3 5.3
1971 -6.5 4.3 7.6 2.6
1972 -15.5 -9.4 -8 -10.3
1973 -7.7 -2.6 -4.2 -3.3
1974 15.1 -0.3 3.3 9.7
53
stationary time series and for this reason time series analysis often requires
one to change a non-stationary time series into a stationary one so as to be
able to use the above theorem.
The following are mathematical denitions of stationary time series:
Stationary in strict sense/rst order stationary
A time series is said to be stationary in strict sense if the joint distribution
of Xt1 , Xt2 , · · · Xtn is the same as the joint distribution of
Xt1+h , Xt2+h . . . . . . Xtn+h for all t1 , t2 , · · · tn and h, where h is the distance(integer)
between the observations, i.e. probability structure of the series does not
change with time.
Stationary in the weak sense/ second order stationary
In practice it is often useful to divide the stationarity in a less restrictive
way than that given in denition (i) above.
A time series is said to be second order stationary in the weak sense if its
mean is a constant and its auto covariance function is independent of time
but depends only on the distance between the observations.
From this denition, the auto covariance function is denoted by ∂(h) is
dened as:
54
We note that the auto covariance ∂(h) is inuenced by the units of mea-
surements.
To compare the basic properties of a time series, it is often useful to have
a function that is not inuenced by the units of measurement.
Such a function is called auto correlation function ( ACF) and is denoted
by ρ(h) and is dened as:
Example 1
Let
Xt = a + bt + et
where
et ∼N(0,σ 2 )
Check if it is stationary.
Solution
E(Xt ) = E(a + bt + et )
= a + bE(t)
, a function of time t.
Xt is not stationary since E(Xt ) is not a constant but depends on time(t).
55
Example 2
Let
Xt = e1 sinλt + e2 Cosλt, t = 0 ± 1
= SinλtE(e1 ) + CosλtE(e2 )
= 0
a constant.
Next, the covariance
But
56
e21 = variance = σ 2
Using
Cos(A − B) = SinASinB + CosACosB
, then
σ 2 Cos[λ(t + h) − λt]
= σ 2 Cosλh
SIS
57
a task of converting a non-stationary time series before the analysis is carried
out.
A lter can be used to eliminate both trend and seasonality in a given
time series.
Linear lter
A linear lter can be used to convert one time series say{Xt } into another
time series say {Yt } by a linear operator given by:
∞
X
Yt = aj Xt−j
j=−∞
Xt = eiλt
= cosλt + isinλt
58
We want to nd the eect of the linear lter on this time series Xt .
Now,
X
Yt = aj Xt−j
j=∞
X∞
= aj eiλ(t−j)
j=−∞
∞
X
= e iλt
ai e−iλt
j=−∞
∞
X
= eiλt ( aj (cosλi − isinλj))
j=−∞
X∞ ∞
X
= eiλt ( aj cosλi − i aj sinλj)
j=−∞ −∞
iλt
= e [A1 (λ) − iA2 (λ)]
A(λ)eiλt
Where
A(λ) = A1 (λ) − iA2 (λ)
59
For any complex number
z = x + iy
z can be expressed as
z = reiθ
y
θ = tan−1 ( )
x
Let
and
A2 (λ)
φ(λ) = tan−1 ( )
A1 (λ)
Yt = g(λ)eiφ(λ) eiλt
= g(λ)ei(φ(λ)+λt)
This means that the lter transforms the original time series
Xt = eiλt
60
to
Yt = g(λ)ei(λt+φλ)
Conclusion
The function:
A(λ) is called the transformation function of the lter.
G(λ) is the gain function
φ(λ) Is the phase function of the lter.
Dierencing
This is the process of transforming a non-stationary process to a station-
ary process.
It is a special type of lter which is particularly useful for removing a
trend by simply dierencing a given time series until it becomes stationary.
Example 1
Let
Xt = a + bt + et ,
, et are iid
N (0, σ 2 )
61
.Let 4 be a dierence operator dened by 4t = Xt − Xt−1 = Yt
Solution
initially E(Xt ) = a + bE(t) =⇒ Xt is nonstationary.
Now,
4Xt = a + bt − et − (a + b(t − 1) + et )
= b + et − et−1
=⇒ E(4Xt ) = E(λt) = b
= σ 2 + σ 2 = 2σ 2
under time t.
Since the E(Yt ) is a constant and var(Yt ),then the series Yt is stationary.
Example 2
Consider a trend of second order polynomial given by
Xt = a + bt + ct2 + et
where
et ∼ N (0, σ 2 )
62
Solution
Denitely Xt is nonstationary.
Let
Yt = 4Xt
= Xt − Xt−1
= b + 2ct − c + et − et−1
=⇒ E(Yt ) = b + 2cE(t) − c
= 2c + et − 2et−1 + et−2
=⇒ E(wt ) = 2c
63
,a constant
var(wt ) = 2σ 2
a constant.
Hence wt is stationary.
To remove the quadratic trend we need to to dierentiate the series twice.
In general if the trend is polynomial of degree n,we dierentiate n times.
NB
Seasonal eect can also be eliminated by dierencing.
For example, with monthly data we employ the operator
412
,where
412 Xt = Xt − Xt−12
44 Xt = Xt − Xt−4
Here we assume that the seasonal indices change slowly with time such
that Xt ≈ Xt−h .
Hence 412 and 44 operators remove monthly and quarterly seasonal vari-
ations respectively to remain with de-seasonalized data.
Example 1
64
Given a seasonal series of a monthly data i.e.Xt , assume that the factors
St are constant so that St is approximately St−12 for all t and that et is a
stationary series.
LetXt = a + bt + st + et . Show that the operator 412 , reduces Xt to
stationary time series.
Solution
412 Xt = Xt − Xt−12
= 12b + et−12
is stationary.
65
Regarding the rst observations in each pair as one variable say Xt and
2nd observation in each pair as the second variable say Xt+1 , i.e.
Xt = X1 , X2 · · · Xn−1
Xt + 1 = X2 , X3 , X4 · · · .Xn
The correlation coecient between the variables Xt and Xt+1 is given by:
Pn−1 Pn−1
t=1 (Xt − X̄(1) ) t=1 (Xt+1 − X̄(2) )
ri = ρ(1) = qP (18)
n−1 2
Pn−1 2
t=1 (Xt − X̄(1) ) t=1 (Xt+1 − X̄(2) )
where
n−1
1 X
X̄(1) = Xt
n − 1 t=1
n−1
1 X
X̄(2) = Xt+1
n − 1 t=1
66
. Lag 3,
(X1 , X4 ), (X2 , X5 ), · · · (Xn−3 , Xn )
. NB
We can also get the sample correlation coecient at lag 2, lag 3, etc
Equation (1) is rather complicated so we assume that equation X̄(1) is ap-
proximated by:
Pn
t=1 Xt
X̄(2) ≈
n
n−1
X n−1
X n
X
(Xt − X̄(1) ) ≈ (Xt+1 − X̄(2) ) ≈ (Xt − X̄)2
t=1 t=1 t=1
Pn−1
( t=1 (X − X̄)(Xt+1 − X̄)
r1 = Pnt 2
t=1 (Xt − X̄)
67
correlation. The sample auto correlation function can be used to analyze the
time series.
Actually it is an important statistic for describing the time series of the
data.
The correlogram
It provides the objective criteria for exploring the nature of internal struc-
ture of time series.
It is a graph obtained by plottingrh against h. It is a useful aid in inter-
preting a set of correlation co-ecient s for a given time series data.
Its shape helps one to make inference about the time series. It identies
the probability model generating the time series. Although a visual inspec-
tion of the correlogram is very useful, the interpretation of the correlogram is
not an easy task.Some general guidelines are followed in the interpretation.
Some useful time series models
Here we describe several types of stochastic processes which are sometimes
useful in setting up a model or a time series.
White noise is a process that has no memory, i.e. the value of process
at time t is uncorrelated with all the past values up to time (t-1) hence
68
it cannot be used for forecasting.
2. Random walk
Denition:
69
X1 = X0 + e 1 = e 1
X2 = X1 + e2 = e1 + e2
X3 = X2 + e3 = e1 + e2 + e3
..
.
Xt = e1 + e2 + · · · + et
Xt
= ei
t=1
t
X
E(Xt ) = (ei )
i=1
Xt
= µ = tµ
i=1
Xt
var(Xt ) = var(ei ) = tσ 2
i=1
4Xt = Xt − Xt−1 = et
70
which is simply a white noise process and it is stationary .One process
that can be modeled by this model is the shared price data, e.g. used
in share prices.
Let et be a white noise with mean 0(zero) and variance σ 2 . Then the process
Xt is said to be a moving average process of order q denoted by:MA(q) if
q
X
βj et−j
j=0
,where
k−h = j
=⇒ k =j+h
then
var(et−j ) = σ 2
When
k 6= j + h, k − h 6= j, E(et−j et−(k−h) ) = 0
71
This is because et is a purely process.
REMARKS
δ 2 T he q−h
P
j=0 βj βj+h , 0 ≤ h ≤ q
δ(h) = 0, h>q
δ(−h),
h<0
72
No restrictions of Bj are required in order for an MA process to be sta-
tionary. However, it is generally desirable to impose restrictions onBj to
ensure that the process satises a condition called invertibility.(Invertibility
ensures that there is a unique MA process for a given ACF ). We explain the
concept as follows:
73
A : Xt = et + θet−1
1
B : Xt = et + et−1
θ
MODEL A:
1 ,h = 0
ρ(h) = β0 β1
= θ
, h = ±1
β02 +β12 1−θ2
0
,h > 1
2. MODEL B:
1
β0 = 1, β1 =
θ
1 ,h = 0
1
ρ(h) = β1
= θ
, h = ±1
β02 +β12 1+( θ1 )2
0
h>1
The two processes have same ACF thus we can't identify an MA process
from the given ACF.
74
To invert the model, make et the subject i.e from model A:
Xt = et + θet−1
et = Xt − θet−1
= Xt − θ(Xt−1 − θet−2 )
= Xt − θXt−1 − θ2 et−2
1 1 1
et = Xt − Xt−1 + 2 Xt−2 − 3 Xt−3
θ θ θ
| θ |< 1
For
| θ |< 1
75
To test for invertibility for any MA process, we let
β i Xt = Xt−i ∀i
Xt = β0 et + β1 et−1 + · · · + βq et−q
= β0 β 0 et + β1 β 1 et + · · · + βq β q et
= ( β0 β 0 + β1 β 1 + · · · + βq β q )et
= φ(β)et
1. Consider model A
Xt = et + θet−1
solution
76
β 0 et + θβ 1 et
= (β 0 + θβ 1 )et
φ(β) = (β 0 + θβ 1 ) = 0
1 + θβ = 0
θβ = −1
−1
β = (root)
θ
1. Determine whether the following process are invertible. Also nd the
LCM
Xt = et + 0.7et−1 − 0.2et−2
where
B0 = 1
B1 = 0.7
B2 = 0.2
77
φ(B) = (1 + 0.7B + 0.2B 2 )
= 2B 2 − 7B − 10 = 0
B = 4.5875 0r − 1.0875
Since the two values are outside the unit circle, we conclude
that Xt is invertible.
MA(2)
1 ,h = 0
0.4 , h = ±1
ρ(h) =
−1 , h = 2
0
elsewhere
For h = ±1
P1
j=0 βj βj+1 β0 β1 + β1 β2
P2 =
2
j=0 βj
β02 + β12 + β22
(1 × 0.7) + (0.7 × 0.2)
1 + 0.72 + 0.22
Solution
78
For MA(q)
1, h=0
Pq−h
βj βj+h
ρ(h) = ρ(h) = j=0
Pq 2 , h = ±1
j=0 βj
0
,h > q
1, h=0
9/26 , h = ±1
ρ(h) = 0 , h = ±2
−4/26 , h = ±3
0
elsewhere
3. et − 1.3et−1 + 0.4et−2
79
answer
1, h=0
−0.64 , h = ±1
0.14
, h = ±2
ρ(h) =
0 elsewhere
is iid.
An AR(1) process can be written as:
Xt = α1 Xt−1 + et
where | α |< 1 · · ·
80
Successive replacing theXt in the AR(I) process we obtain:
Xt = et + αXt−1
= et α(et−1 + αXt−2 )
= et + αet−1 + α2 Xt−2
s
X
E(Xt − αj et−j )2 = E[α2(s+1) Xt−(s+1)
2
]
j=0
From equation 1
E(Xt ) = αE(Xt−1 )
Since
E(et ) = 0
81
Assuming the process is stationary then:
E(Xt ) = αE(Xt−1 ) = 0
= (1 − α)E(Xt ) = 0
s
X
E(Xt − αj et−j )2 = α2(s+1) var[Xt−(s+1) ]
j=0
82
Therefore:
s
X
E(Xt − αj et−j ) = 0
j=0
=⇒ | α |< 1,
s
X
αj et−j
j=0
i.e
s q
X X
Xt = αj et−j = β j et−j
j=0 j=0
s
X
E(Xt ) = αj E(et−j ) = 0
j=0
s j
X
2
X σ2
var(Xt ) = var(et−j ) = σ α2j = , | α |< 1
j=0 j=0
1−α
83
since
E(Xt ) = 0
X∞ ∞
X
j
= α E(et−j ) αi E(et+h−j )
j=0 j=0
X∞ X∞
= αj αi E(et−j et+h−i )
j=0 j=0
X∞ X ∞
= αj αi E(et−j et−(i−h )
j=0 j=0
If j = i − h =⇒ i = j + h then
E(et−j et−(i−h ) = σ 2
∞
X
2
δ(h) = σ αj αJ+h
J=0
∞
X
2 h
= σ α α2j
J=0
2 h
σ α
= , | α |< 1
1 − α2
when h=0
σ2
δ(0) =
1 − α2
84
The ACF is given by
δ(h)
δ(0)
σ 2 αh 1 − α2
=⇒ ×
1 − α2 σ2
85
For negative αWe have:
86
ρ(h) = αh
87
For an AR(2) process we have
Xt = αXt−1 + α2 Xt−2 + et
Xt−h
The ACF
δ(h)
ρ(h) = = α1 ρ(h − 1) + α2 ρ(h − 2) · · ·
δ(0)
88
Equation(i) is known as Yule walker equations. It is linear and homoge-
nous.
To solve equation (i) let:
ρ(h) = mh
mh = α1 mh−1 + α2 mh−2
mh − α1 mh−1 − α2 mh−2 = 0
mh−2 (m2 − α1 m − α2 ) = 0
Since
mh−2 6= 0
then
m2 − α1 m − α2 = 0 · · ·
(characteristic equation)
Equation 2 is known as the auxiliary/characteristic equation.
Let π1 andπ2 be the roots of equation 2 .Then the general solution of the
Yule Walker equations is given by
89
where A1 and A2 are constants to be determined.
√
α1 ± α21 +4α2
The roots of the auxiliary equations are π1 or π2 = 2
hence
,
AR(2) process will be stationary if
p
α1 ± α12 + 4α2
<1
2
i.e. the absolute value of the roots of the characteristic equations are less
than 1.
Two cases shall be considered:
CASE1
In this case both roots π1 and π2 are real and distinct .Then the ACF of
=⇒ ρ(0) = A1 + A2 = 1
=⇒ A2= 1 − A1
90
Next from equation (i)
= (1 − α2 )ρ(1) = α1
α1
=⇒ ρ(1) =
1 − α2
but
α1
ρ(1) = A1 π1 + A2 π2 =
1 − α2
α1
∴ A1 π1 + A2 π2 =
1 − α2
and
A2 = 1 − A1
α1 − π2 + α2 π2
A1 =
(1 − α2 )(π1 − π2 )
and
α 1 − π2 + α 2 π 2
A2 = 1 − A1 = 1 −
(1 − α2 )(π1 − π2 )
π1 − α1 − α2 π1
=
(1 − α2 )(π1 − π2 )
91
Hence the ACF becomes
92
CASE 2
In this case π1 and π2 , the roots are imaginary.
p
α12 α12 + 4α2
π1 = +
2 q 2
α1 i
= + −(α2 + 4α2 ) = reiθ
2 2 p 1
α2 α12 + 4α2
π2 = 1 −
2 q 2
α1 i
= − −(α12 − 4α2 ) = re−iθ
2 2
where
r
α1 2 (−(α12 + 4α2 ))2
r = ) +
(
r 2 4
α1 α 2 √
= ( )2 − 1 − α2 = −α2
2 4
and
1 1
2
−1 2 (−α1 − 4α2 ) 2
θ = tan ( α1 )
2
1
2
−1 (−α1 − 4α2 ) 2
= tan ( )
α
93
The ACF
= A1 (reiθ )h + A2 (re−iθ )h
But
A1 + A2 = 1
and
1
r = −α22
h
=⇒ ρ(h) = (−α2 ) 2 [cosθh + i(A1 + A2 )sinθh]
Suppose
1
ρ(1) = (−α2 ) 2 [cosθ + i(A1 − A2 )sinθ]
94
but
α1
ρ(1) =
1 − α2
1 α1
ρ(1) = (−α2 ) 2 [cosθ + i(A1 + A2 )sinθ] =
1 − α2
α1
[cosθ + i(A1 − A2 )sinθ] = 1
1 − α2 ((−α2 ) 2 )
α1 cosθ
i(A1 − A2 ) = 1
1 − α2 ((−α2 ) )sinθ sinθ
2
α1
= 1 − cosθ
(−α2 ) 2 (1 − α2 )sinθ
Diagram
95
But
α1 1
cosθ = /(−α2 ) 2
2
α1
2cosθ = 1
(−α2 ) 2
2cosθ
i(A1 + A2 ) = − cotθ
sinθ(1 − α2 )
2cotθ
= − cotθ
1 − α2
1 + α2
= cotθ
1 − α2
h 1 + α2
ρ(h) = (−α2 ) 2 [cosθh + cotθsinθh]
1 − α2
96
Examples:
Consider the process
1 3
Xt = Xt−1 + Xt−2 + et
4 64
97
Suppose
ρ(h) = mh
1 (h−1) 3
mh = m + m(h−2)
4 64
1 (h−1) 3
mh − m − m(h−2) = 0
4 64
(h−2) 2 1 3
m (m − m − ) = 0
4 64
but
m(h−2) 6= 0
1 3
m2 − m − =0
4 64
π1 or π2 = m1 or m2
q
1 1 12
4
± 16 + 64
=
2
π1 or m1 = 3/8
π2 or m2 = −1/8
98
ρ(h) = A1 π1h + A2 π2h
now
ρ(0) = A1 + A2 = 1, h = 0
A1 = 1 − A2
and
3/8A1 − 1/8A2 , h = 1
From equation 1
from equation ii
3 1
ρ(1) = A1 − A2 = 16/61
8 8
99
and
A1 = 1 − A2
A2 = 55/244
and
A1 = 1 − A2
= 1 − 55/244
= 189/244
Assignment
Consider an AR(2) process given by
1
Xt = Xt−1 − Xt−2 + et
3
100
SPECTRAL ANALYSIS:
. Thus it can be written as a function of the sum sine and cosine terms
otherwise known as nite series.
i.e
h
X
Xt = (aj cosλj t + bj sinλj t) + et
j=1
where
−π ≤ λj ≤ π
101
Let
Xt ; t = 0, ±1, ±2 · · ·
= E(Xt Xt+h )
{δ(h); h = 0, ±1, ±2 · · · }
is given by
∞
1 X
f (λ) = δ(h)e−ihλ
2π h=−∞
The functionf (λ) can also be written in several dierent forms as follows:
1.
∞
1 X
f (λ) = δ(h)e−ihλ
2π h=−∞
102
−1 ∞
1 X
−ihλ
X
= [δ(0) + δ(−h)e + δ(h)e−ihλ ]
2π h=−∞ h=1
∞ ∞
1 X
−ihλ
X
= [δ(0) + δ(−h)e + δ(h)e−ihλ ]
2π h=1 h=1
∞ ∞
1
(21)
X X
= [δ(0) + δ(h)eihλ + δ(h)e−ihλ ]
2π h=1 h=1
∞
1 X
[δ(0)cos0 + δ(h)(eihλ + e−ihλ )]
2π h=1
∞
1 X
= [δ(0) + δ(h)(coshλ + isinhλ + coshλ − isinhλ)]
2π h=1
∞
1
(22)
X
= [δ(0) + 2 δ(h)coshλ
2π h=1
∞
1 X
= [δ(0)cos0 + δ(h)(coshλ + isinhλ + coshλ − isinhλ)]
2π h=1
−1 ∞
1 X X
= [δ(0)cos0 + δ(−h)(cos(−hλ) + δ(h)coshλ]
2π h=1 h=1
−1 ∞
1 X X
= [δ(0)cos0 + δ(h)(cos(hλ) + δ(h)coshλ]
2π h=1 h=1
∞
1 X
= δ(h)coshλ (23)
2π h=−∞
103
can be shown that the ACF
ˆ π
δ(h) = f (λ)coshλdλ
−π
for h=0
ˆ π
δ(0) = f (λ)dλ
−π
But
δ(0) = σ 2 (variance).
ˆ π
2
σ = f (λ)dλ
−π
ˆ π
f (λ)
=⇒ 1 = 2
dλ
−π σ
f (λ)
σ2
is a pdf of λ.
The function fσ(λ)
2 is known as normalized power spectrum/ normalized
spectral density function λ.
From equation(1),
f (λ)
f (λ) =
σ2
∞
1 X
f (λ) = δ(h)e−ihλ
2π h=−∞
104
,the normalized density function becomes:
1
P∞ −ihλ
f (λ) h=−∞ δ(h)e
f ∗ (λ) = = 2π
σ2 σ2
∞
1 X
= ρ(h)e−ihλ
2π h=−∞
∞
∗ f (λ) 1 X
f (λ) = = δ(h)cosλh
σ2 2π h=−∞
∞
1 X
= ρ(h)cosλh
2π h=−∞
Example 1
Find the spectral density function of
et : t = 0, ±1, ±2 · · ·
∞
1 X
f (λ) = δ(h)e−ihλ
2π h=−∞
105
but
0
1 X
f (λ) = δ(h)e−ihλ
2π h=0
1
= δ(0)e−0
2π
σ2 , h = 0
2π
=
0
h>0
λ1 = αXt−1 + et
where{et } is a white noise sequence and| α |< 1, Show that the nor-
malized density function , is
f (λ) 1 1 − α2
f ∗ (λ) = =
σ2 2π (1 − 2αcosλ + α2 )
106
2. Consider a rst order moving average process given by
Xt = et + θet−1
FORECASTING
be the observed time series. The basic problem is to estimate the future
values such that Xn+k made at time n for k steps ahead.
Note : k is an integer called the lead time.
The forecast of Xn+k made at time n for k steps ahead would be denoted
by X̂(n, k). We need to forecast Xn+k is such a way that the mean square
error (MSE) of the predictor X(n,k) is minimal, i.e.
should be minimum.
There are so many forecasting procedures which include:
107
a) Box Jenkins procedures.
b) Holt winters approach.
c) Exponential smoothing.
d) Extrapolation of trend curves.
e) Stepwise auto regression.
f) Multiple regression.
Note : There is no simple method which can be applied universally.
In fact the method to be considered depends on the nature of the problem
among other factors.
Forecasting methods will be broadly classied into 3:
a) Subjective method
Forecasting can be made on a subjective basis using judgment, intuition,
commercial knowledge and other relevant knowledge.
b) Uni-variate method
forecasting of a given variable are based on a model tted only to past
observations of the given time series so thatX̂(n, k) depends only on the
observation
x1 , x2 , · · · , xn
108
or more other series called the predictive, explanatory variables, for example,
sales forecasts may depend on stock, advertisement, expenditure, etc.
Note: For our case we only concentrate on uni-variate method.
Extrapolation of trend curves. For long term forecasting it often useful to
t a trends curve (e.g logistic, gompertz, polynomials etc) to successive yearly
totals and extrapolate. The method is suitable for long term forecasting. A
major disadvantage of this method is that there is no logical basis . For
choosing among the dierent curves except the goodness of t unfortunately
it is often the case that one can nd several curves which t a give set of data
almost equally well but which can be protected forward they give dierent
forecast.
b) Exponential smoothing
This method should only be used in cases of non seasonal time series
showing no systematic trend. Given a non-seasonal time series with no trend
x1 , x2 , · · · , xn
109
to observations further in the past. An appealing set of weights are geometric
weight which decrease by a constant ratio. To make sure the weights add to
1 we take
Ci = α(1 − α)i , i = 0, 1, 2, · · ·
0<α<1
,then
Suppose we set the forecast of X2 to be X̂(1,1) then we can use ∗to compute
recursively.
Equation ∗can be sometimes written in the error correction form
= αen + X̂(n−1,1)
110
Where
en = (Xn − X̂(n−1,1)
X̂(1, 1) = X1
solution
e2 = X2 − X̂(1, 1) = X2 − X1
e3 = X3 − X̂(2, 1)
..
.
en = Xn − X̂(n − 1, 1)
111
and compute
n
X
= e2i
i=2
Repeat the procedure for other values of αbetween 0 and 1 and select the
value which minimizes
n
X
= e2i
i=2
112
isfactory model is found, forecast may be readily be found . given the data
up to time n this forecast will involve observation and tted residuals up to
and including time n.
We now nd the optimal forecast of Xn+k at time n.
PREDICTION THEORY
Suppose we have up to time n, i.e.
and we need to predict Xn+k for k ≥ 1.Assuming that Xt has 0 mean, the
optimal estimator of Xn+k at time t=n is the conditional expectation ofXn+k
at time n, i.e
X̂(n,k) = E(Xn+k /(X1 , X2 · · · Xn )
Proof.
Let X̂(n, k)be the optimal forecast of Xn+k and X̂(n,k)
∗
any other forecast
of Xn+k .
We introduce the forecast errors
∗
en = Xn+k − X̂(n,k)
113
Then
∗ˆ
E(e∗2
n ) = E(Xn+k − X(n,k) )
2
ˆ + X(n,k)
= E(Xn+k − X(n,k) ˆ − X ∗ˆ )2
(n,k)
ˆ )2 + 2E(Xn+k − X(n,k)
= E(Xn+k − X(n,k) ˆ )(X(n,k) ˆ − X ∗ˆ )2
ˆ − X ∗ˆ ) + E(X(n,k)
(n,k) (n,k)
ˆ − X ∗ˆ ) + E(X(n,k)
= E(e2n ) + 2E(en (X(n,k) ˆ − X ∗ˆ )2
(n,k) (n,k)
suppose we choose X̂(n,k) to make the cross product term vanish then we have
E(e∗2 2 ˆ ∗ˆ 2
n )E(en ) + E(X(n,k) − X(n,k) )
=⇒ E(e∗2 2
n ) ≥ E(en )
Equality i X(n,k)
ˆ = X̂ ∗
(n,k)
EXAMPLE
Consider an AR(1) process given by
Xt = αXt−1 + et , | α |< 1
Forecast Xn+1 and Xn+k and also get the MSE in both cases.
solution
114
1. Let the observations
x1 , x2 , · · · , xn
≡ X(1,n) .Then
Xn+1 = αXn + en+1
ˆ
Xn+1 = E(Xn+1 /X(1,n) )
= αXn
= E(en+1 )2
= σ̂ 2
115
next,for k-steps ahead
j=1
k
= α Xn
116
Next MSE of X̂(n,k) is given by
E(Xn+k X̂(n,k) )2
k
X
= E(αk Xn + αk−j en+j − αk Xn )2
j=1
k
X
= E( αk−j en+j )2
j=1
k
X
= σ2 α2(k−j)
j=1
END!
117