You are on page 1of 52

CHAPTER 6

AUTOCORRELATION
(Lec 12)

Nguyen Thu Hang, BMNV, FTU CS2 1


Outline
1. The nature of autocorrelation
2. OLS estimation in the presence of
autocorrelation
3. Consequences of using OLS in the presence of
autocorrelation
4. Detection of autocorrelation
5. Correcting for autocorrelation

Nguyen Thu Hang, BMNV, FTU CS2 2


1. The nature of autocorrelation
Assumption 5:
cov(ut, us)=0 for all t≠s

This assumption states that the disturbances ut


and us are independently distributed, which is
called serial independence.

Nguyen Thu Hang, BMNV, FTU CS2 3


1. The nature of autocorrelation
If this assumption is no longer valid, then the
disturbances are not pair-wise independent,
but pair-wise auto-correlated (or Serially
Correlated).
This means that an error occurring at period t
may be carried over to the next period t+1.

Autocorrelation is most likely to occur in time


series data.
Nguyen Thu Hang, BMNV, FTU CS2 4
Why does serial correlation occur?

• Inertia
• Specification Bias: Excluded variables case.
• Specification Bias: Incorrect functional form
• Cobweb phenomenon
• Lags
• “Manipulation” of Data
• Data transformation

Nguyen Thu Hang, BMNV, FTU CS2 5


Why does serial correlation occur?

• Inertia: A salient feature of most economic time


series is inertia or sluggishness: GDP, price
indexes, production, employment and
unemployment exhibit cycles.

Nguyen Thu Hang, BMNV, FTU CS2 6


Why does serial correlation occur?
• Specification Bias: Excluded variables case:
- Suppose we have the following demand model:
Yt  1   2 X 2t  3 X 3t   4 X 4t  U t

- Where Y= quantity of beef demanded, X2= price of


beef, X3= consumer income, X4= price of pork, t=time.
- For some reason we run the model:

Y  1   2 X 2t  3 X 3t  Vt
Vt   4 X 4t  U t
 The error term will reflect a systematic pattern, thus
creating autocorrelation.
Nguyen Thu Hang, BMNV, FTU CS2 7
Why does serial correlation occur?
• Specification Bias: Incorrect functional form
- Suppose the correct model in a cost-output study:
MC i  1   2 Qi   3 Qi2  U i
Where MC= marginal cost, Q= output
- But we run the model: MC     Q  V
i 1 2 i i
- Or: Vi   3Qi  U i
2

The error term will


reflect a systematic
pattern, and thus
creating autocorrelation.

Nguyen Thu Hang, BMNV, FTU CS2 8


Why does serial correlation occur?
• Cobweb phenomenon: The supply of many agricultural
commodities reflects the so-called cobweb phenomenon,
where supply reacts to price with a lag of one time period
because supply decisions take time to implement.
Supply t  1   2 Pt 1  ut
• At the end of period t, price Pt turns out to be lower than
Pt-1. Therefore, in period t+1, farmers may very well decide
to produce less than they did in period t. In this situation,
the disturbance ut are not expected to be random because
if the farmers overproduce in year t, they are likely to
reduce their production in t+1, and so on, leading to a
Cobweb parttern.

Nguyen Thu Hang, BMNV, FTU CS2 9


Why does serial correlation occur?
• Lags: In a time series regression of consumption
expenditure on income, it is not uncommon to find that the
consumption expenditure in the current period depends ,
among other things, on the consumption expenditure of
the previous period. Consumers do not change their
consumption habits readily for psychological, technological
or institutional reasons.

consumptiont  1   2incomet   2consumptiont 1  ut


• This regression is known as autoregression because one of
the explanatory variables is the lagged value of the
dependent variable.

Nguyen Thu Hang, BMNV, FTU CS2 10


Why does serial correlation occur?
• Manipulation of Data: in time series
regressions involving quarterly data, such data
usually derived from the monthly data by
simply adding three monthly observations and
dividing the sum by 3. This averaging
introduces smoothness into the data by
dampening the fluctuations in the monthly
data. This smoothness may itself lend to a
systematic pattern in the disturbances, and
thereby introducing autocorrelation.

Nguyen Thu Hang, BMNV, FTU CS2 11


First-Order Autocorrelation
The simplest and most commonly observed is the
first-order autocorrelation.
Consider the multiple regression model:
Yt=β1+β2X2t+β3X3t+β4X4t+…+βkXkt+ut
in which the current observation of the error term
ut is a function of the previous (lagged)
observation of the error term:
ut=ρut-1+et

Nguyen Thu Hang, BMNV, FTU CS2 12


First-Order Autocorrelation
The coefficient ρ is called the first-order
autocorrelation coefficient and takes values from
-1 to +1.
This is called a first –order autoregressive scheme,
AR(1).
It is obvious that the size of ρ will determine the
strength of serial correlation.

Nguyen Thu Hang, BMNV, FTU CS2 13


First-Order Autocorrelation
Three different cases:
(a) If ρ is zero, then we have no autocorrelation.
(b) If ρ approaches unity, the value of the previous
observation of the error becomes more important in
determining the value of the current error and
therefore high degree of autocorrelation exists. In this
case we have positive autocorrelation.
(c) If ρ approaches -1, we have high degree of negative
autocorrelation.

Nguyen Thu Hang, BMNV, FTU CS2 14


First-Order Autocorrelation

Nguyen Thu Hang, BMNV, FTU CS2 15


First-Order Autocorrelation

Nguyen Thu Hang, BMNV, FTU CS2 16


Higher-Order Autocorrelation
Second-order when:
ut=ρ1ut-1+ ρ2ut-2+et
Third-order when
ut=ρ1ut-1+ ρ2ut-2+ρ3ut-3 +et
p-th order when:
ut=ρ1ut-1+ ρ2ut-2+ρ3ut-3 +…+ ρput-p +et

Nguyen Thu Hang, BMNV, FTU CS2 17


2. OLS estimation in the presence of autocorrelation

Yt   1   2 X t  u t E (u i u j )  0

 Assume that the error term can be modeled as


follows: u t  u t 1  t 1    1
   is known as the coefficient of autocovariance and
the error term satisfies the OLS assumption.

Nguyen Thu Hang, BMNV, FTU CS2 18


2. OLS estimation in the presence of autocorrelation

ˆ 2 
S xy

 xt y t var( ˆ2 ) 
2
S xx  t
x 2
 t
x 2

 n1 n2

 2   xt xt 1  xt xt 2
x x 
var( ˆ2 ) AR(1)   1  2  t 1
 2  2 t 1
 ...  2  n1 1 n

 xt 
2


n
x 2

n
x 2

n
x 2
 t 1
t
t 1
t
t 1
t 

The coefficient estimator is still linear and


unbiased. However it does not have minimum
variance It is not BLUE.
Nguyen Thu Hang, BMNV, FTU CS2 19
The BLUE estimator in the presence of autocorrelation

 Under the AR (1) process, the BLUE


estimator of β2 is given by the following
expression.
 ( x  x )( y  y )
n
t 1 t 1
ˆ
 GLS t 2
C
t t

 ( x  x )
2 n 2
t 2 t t 1

2
Var ( ˆ GLS
) D

2
( x t  x t 1 )
n 2
t 2

Under autocorrelation, the estimators obtained the method of


GLS are BLUE. The method of GLS can be learnt in advanced
courses.
Nguyen Thu Hang, BMNV, FTU CS2 20
3. Consequences of Using OLS in the
presence of autocorrelation
 The estimator is no more not BLUE, and even
if we use the variance, the confidence
intervals derived from there are likely to be
wider than those based on the GLS procedure.

Hypothesis testing: we are likely to declare a


coefficient statistically insignificant even
though in fact it may be.
 One should use GLS and not OLS.

Nguyen Thu Hang, BMNV, FTU CS2 21


3. Consequences of Using OLS in the
presence of autocorrelation
 The estimated variance of the error is likely to
overestimate the true variance
 Over estimate R-square
 Therefore, the usual t and F tests of significance
are no longer valid, and if applied, are likely to
give seriously misleading conclusions about the
statistical significance of the estimated
regression coefficients.

Nguyen Thu Hang, BMNV, FTU CS2 22


4. Detecting Autocorrelation
4.1. Graphical Method
4.2. The Runs Test
4.3. The Durbin Watson Test
4.4. A general test of autocorrelation: The
Breusch-Godfrey (BG) Test

Nguyen Thu Hang, BMNV, FTU CS2 23


4.1. Graphical Method
There are various ways of examining the residuals.
• The time sequence plot: Plot residuals against time.
• Plot the standardized residuals against time. The
standardized residuals is the residuals divided by the
standard error of the regression.
 If the actual and standard plot shows a pattern, then
the errors may not be random.
• Plot the error term with its first lag.

Nguyen Thu Hang, BMNV, FTU CS2 24


Example
• Effects of inflation and deficits on interest rate
(intdef.dta).

i3t  1   2 inf t   3 def t  ut

• where i3= the three-month T-bill rate, inf=


annual inflation rate, def= the federal budget
deficit as a percentage of GDP.

Nguyen Thu Hang, BMNV, FTU CS2 25


Example
• Stata output
. reg i3 inf def

Source SS df MS Number of obs = 56


F( 2, 53) = 40.09
Model 272.420338 2 136.210169 Prob > F = 0.0000
Residual 180.054275 53 3.39725047 R-squared = 0.6021
Adj R-squared = 0.5871
Total 452.474612 55 8.22681113 Root MSE = 1.8432

i3 Coef. Std. Err. t P>|t| [95% Conf. Interval]

inf .6058659 .0821348 7.38 0.000 .4411243 .7706074


def .5130579 .1183841 4.33 0.000 .2756095 .7505062
_cons 1.733266 .431967 4.01 0.000 .8668497 2.599682

Nguyen Thu Hang, BMNV, FTU CS2 26


Example
The time sequence plot

4
predict i3hat, xb

2
gen uhat= i3-i3hat uhat

twoway scatter uhat


-2

year
-4

1950 1960 1970 1980 1990 2000


1948 to 2003

Nguyen Thu Hang, BMNV, FTU CS2 27


Example
The standardized residuals against time

3
sduhat= uhat/Root

2
MSE= uhat/1.8432

1
sduhat

twoway scatter
sduhat year 0
-1
-2

1950 1960 1970 1980 1990 2000


1948 to 2003

Nguyen Thu Hang, BMNV, FTU CS2 28


Example
• Plot the error term with its first lag.

4
tsset year
gen uhatlag=l.uhat

2
uhat

0
twoway scatter uhat
uhatlag
-2
-4

-4 -2 0 2 4
uhatlag

Nguyen Thu Hang, BMNV, FTU CS2 29


4.2. The Runs Test
 Consider a list of estimated error term, the errors
term can be positive or negative. In the following
sequence, there are three runs.
 (─ ─ ─ ─ ─ ─ ─ ─ ─ ) ( + + + + + + + + + + + + +
+ + + + + + + +) (─ ─ ─ ─ ─ ─ ─ ─ ─ ─ )
 A run is defined as uninterrupted sequence of one
symbol or attribute, such as + or -.
 The length of the run is defined as the number of
element in it. The above sequence as three runs, the
first run is 9 minuses, the second one has 21 pluses
and the last one has 10 runs.
Nguyen Thu Hang, BMNV, FTU CS2 30
4.2. The Runs Test
 By examining how runs behave in s strictly random
sequence of observations, one can derive a test of
randomness of runs.
 Are the 3 runs observed in our illustrative example
consisting of 40 observations too many or two few
compared with the number of runs expected in a
strictly random sequence of 40 observations?
 If there are too many runs, it would mean that in our
example the residuals change sign frequently, thus
indicating negative serial correlation.
 If there are two few runs, they may suggest positive
autocorrelation.
Nguyen Thu Hang, BMNV, FTU CS2 31
4.2. The Runs Test

 Define
 N: total number of observations (N=N1+N2)
 N1: number of + symbols (i.e. + residuals)
 N2: number of ─ symbols (i.e. ─ residuals)
 R: number of runs
 Assuming that the N1 >10 and N2 >10, then
the number of runs is normally distributed
with:
Nguyen Thu Hang, BMNV, FTU CS2 32
4.2. The Runs Test
 Then, 2N1 N 2 2 N 1 N 2 (2 N 1 N 2  N )
E ( R)  1   2

( N ) 2 ( N  1)
R
N
 If the null hypothesis of randomness is sustainable,
following the properties of the normal distribution,
we should expect that
 Prob [E(R) – 1.96 R ≤ R ≤ E(R) – 1.96 R]
 Hypothesis: do not reject the null hypothesis of
randomness with 95% confidence if R, the number
of runs, lies in the preceding confidence interval;
reject otherwise

Nguyen Thu Hang, BMNV, FTU CS2 33


The Runs Test - Example
R=3, N1=19, N2=21,N=40
E(R)=10.975
SigmaR= 3.1134

The 95% confidence interval for R in our


example:
10+/- 1.96*3.1134 = (4.8728, 17.0722)

Nguyen Thu Hang, BMNV, FTU CS2 34


4.3. The Durbin Watson Test
 The most celebrated test for detecting serial
correlation.
 The Durbin-Watson d statistic
t n

 t t 1
(uˆ
t 2
 ˆ
u ) 2

d t n

 t
ˆ
u 2

t 1

 It is simply the ratio of the sum of squared


differences in successive residuals to the RSS.
 The number of observation is n-1 as one observation
is lost in taking Nguyen
successive differences.
Thu Hang, BMNV, FTU CS2 35
The assumptions underlying the d statistic

- The regression model includes the intercept term.


- The explanatory variables are nonstochastic, or fixed in
repeated sampling.
- The disturbances are generated by the first order
autoregressive scheme: ut=ρut-1+et

Nguyen Thu Hang, BMNV, FTU CS2 36


The assumptions underlying the d statistic

- The error term is assumed to be normally distributed.


- The regression model does not include the lagged
values of the dependent an explanatory variables.
- There are no missing values in the data.
- Durbin-Watson have derived a lower bound dL and an
upper bound dU such that if the computed d lies
outside these critical values, a decision can be made
regarding the presence of positive or negative serial
correlation.

Nguyen Thu Hang, BMNV, FTU CS2 37


d statistic

d
 t  t 1  2 uˆ t uˆ t 1
ˆ
u 2
 ˆ
u 2

 21 
 uˆ uˆ
t t 1


 t
ˆ
u 2 
  uˆ 2
t


d  21  ̂ 

 Where ˆ 
 uˆ uˆt t 1

 uˆ 2
t

 But since -1 ≤  ≤ 1, this implies that 0 ≤ d ≤ 4.

Nguyen Thu Hang, BMNV, FTU CS2 38


d statistic
 If the statistic lies near the value 2, there is no
serial correlation.
 But if the statistic lies in the vicinity of 0,
there is positive serial correlation.
 The closer the d is to zero, the greater the
evidence of positive serial correlation.
 If it lies in the vicinity of 4, there is evidence
of negative serial correlation
 If it lies between dL and dU / 4 –dL and 4 – dU,
then we are in the zone of indecision.
Nguyen Thu Hang, BMNV, FTU CS2 39
4.3. The Durbin Watson Test

Zone of Zone of
No
indecision indecision
autocorrelation Reject H0,
Reject H0,
evidence of evidence of
positive negative
auto- auto-
correlation correlation

0 dL dU 2 4-dU 4-dL 4

Nguyen Thu Hang, BMNV, FTU CS2 40


Modified d test

 Use Modified d test if d lies in the zone in the of indecision.


Given the level of significance ,
 Ho:  = 0 versus H1:  > 0, reject Ho at  level if d < dU. That
is there is statistically significant evidence of positive
autocorrelation.
 Ho :  = 0 versus H1 :  < 0, reject Ho at  level if 4- d < dU.
That is there is statistically significant evidence of negative
autocorrelation.
 Ho :  = 0 versus H1 :  ≠ 0, reject Ho at 2 level if d < dU
and 4- d < dU. That is there is statistically significant
evidence of either positive or negative autocorrelation.

Nguyen Thu Hang, BMNV, FTU CS2 41


The mechanics of the Durbin-Watson test

 Run the OLS regression and obtain the residuals


 Compute d
 For the given sample size and given number of
explanatory variables, find out the critical dL and dU.
 Follow the decisions rule

Nguyen Thu Hang, BMNV, FTU CS2 42


Example
. reg i3 inf def

Source SS df MS Number of obs = 56


F( 2, 53) = 40.09
Model 272.420338 2 136.210169 Prob > F = 0.0000
Residual 180.054275 53 3.39725047 R-squared = 0.6021
Adj R-squared = 0.5871
Total 452.474612 55 8.22681113 Root MSE = 1.8432

i3 Coef. Std. Err. t P>|t| [95% Conf. Interval]

inf .6058659 .0821348 7.38 0.000 .4411243 .7706074


def .5130579 .1183841 4.33 0.000 .2756095 .7505062
_cons 1.733266 .431967 4.01 0.000 .8668497 2.599682

Because this is time series data, we should consider the possibility


of autocorrelation. To run the Durbin-Watson, first we have to
specify the data as time series with the tsset command. Next we
use the dwstat command.
Durbin-Watson d-statistic( 3, 56) = .7161527
DL=1.490, DU=1.641
Reject H0, evidence of positive
auto-correlation
Nguyen Thu Hang, BMNV, FTU CS2 43
4.4. The Breusch – Godfrey
 The BG test, also known as the LM test, is a general
test for autocorrelation in the sense that it allows for
(1) nonstochastic regressors such as the lagged values of
the regressand;
(2) higher-order autoregressive schemes such as AR(1),
AR (2)etc.; and
(3) simple or higher-order moving averages of white
noise error terms.

Nguyen Thu Hang, BMNV, FTU CS2 44


The Breusch – Godfrey

 Consider the following model:


Yt  1   2 X t  u t

u t  1u t 1   2 u t  2  ........ p u t  p  t
H o : 1   2  .....   p  0

 Estimate the regression using OLS


 Run the following regression and obtained the
R-square

Nguyen Thu Hang, BMNV, FTU CS2 45


The Breusch – Godfrey

 If the sample size is large, Breusch and


Godfrey have shown that (n – p) R2 follow a
chi-square p df.
 If (n – p) R2 exceeds the critical value at the
chosen level of significance, we reject the null
hypothesis, in which case at least one rho is
statistically different from zero.

Nguyen Thu Hang, BMNV, FTU CS2 46


Example
• Stata output
. estat bgodfrey

Breusch-Godfrey LM test for autocorrelation

lags(p) chi2 df Prob > chi2

1 20.154 1 0.0000

H0: no serial correlation


. estat bgodfrey, lags(3)

Breusch-Godfrey LM test for autocorrelation

lags(p) chi2 df Prob > chi2

3 20.773 3 0.0001

H0: no serial correlation

Nguyen Thu Hang, BMNV, FTU CS2 47


4.4. The Breusch – Godfrey

Point to note:
 The regressors included in the regression model may
contain lagged values of the regressand Y. In DW,
this is not allowed.
 The BG test is applicable even if the disturbances
follow a pth-order moving averages (MA) process,
that is ut is integrated as follows:
u t   t  1 t 1   2  t  2  ........ p  t  p
 A drawback of the BG test is that the value of p, the
length of the lag cannot be specified as a priori.
Nguyen Thu Hang, BMNV, FTU CS2 48
What to do when you find autocorrelation:
• Try to find out if the autocorrelation is pure autocorrelation
and not the result of mis-specification of the model.
Sometimes, we observe patterns in residuals because the
model is mis-specified- it has excluded some important
variables or because its functional form is incorrect.
• If it is pure autocorrelation, one can use appropriate
transformation of the original model so that in the
transformed model we do not have the problem of pure
autocorrelation.  Use generalized least square (GLS)
method.
• In large samples, we can use the Newey-West method to
obtain standard errors of OLS estimators that are corrected
for autocorrelation. This method is an extension of White’s
heteroskedasticity-consistent standard errors method.
• In some situations, we canThucontinue
Nguyen Hang, BMNV, FTU to
CS2 use the OLS method. 49
Model Misspecification vs. Pure Autocorrelation
 It is important to find out whether
autocorrelation is pure autocorrelation and not
the result of mis-specification of the model.
 Suppose that the Durbin Watson test of a
given regression model reveals a value of
0.716. This indicates positive autocorrelation .
 However, could this correlation have arisen
because the model was not correctly
specified?
 Time series model do exhibit trend, so add a
trend variable in the equation.
Nguyen Thu Hang, BMNV, FTU CS2 50
Example
The Newey-West method
. newey i3 inf def, lag(1)

Regression with Newey-West standard errors Number of obs = 56


maximum lag: 1 F( 2, 53) = 23.72
Prob > F = 0.0000

Newey-West
i3 Coef. Std. Err. t P>|t| [95% Conf. Interval]

inf .6058659 .1012887 5.98 0.000 .4027065 .8090252


def .5130579 .1852435 2.77 0.008 .1415065 .8846092
_cons 1.733266 .4654222 3.72 0.000 .7997471 2.666784

Nguyen Thu Hang, BMNV, FTU CS2 51


Assignments

Nguyen Thu Hang, BMNV, FTU CS2 52

You might also like