Autocorrelation Concepts

Chapter 2: Lesson 2

Learning Outcomes

Define key terms in time series analysis
  • Define the ensemble of a time series
  • Define the expected value (or mean function) of a time series model
  • Define the sample estimate of the population mean of a time series
  • Define the variance function of a time series model
  • State the constant variance estimator for a time series model
  • Explain the stationarity assumption
  • Explain the stationary variance assumption
  • Define lag
  • Define autocorrelation
  • Define the second-order stationary time series
  • Explain the autocovariance function in Equation (2.11)
  • Explain the lag k autocorrelation function in Equation (2.12)
  • Define the autocovariance function, acvf
  • Define the sample autocorrelation function, acf
Calculate sample estimates of autocovariance and autocorrelation functions from time series data
  • Define the sample autocovariance function, c_k
  • Define the sample autocorrelation function, r_k

Preparation

  • Read Sections 2.2.5

Learning Journal Exchange (10 min)

  • Review another student’s journal
  • What would you add to your learning journal after reading your partner’s?
  • What would you recommend your partner add to their learning journal?
  • Sign the Learning Journal review sheet for your peer

Hands-on Exercise – Exploring Sample Autocorrelation (40 min)

Comparison of Independent and Autocorrelated Error Terms

In the previous lesson, we computed the sample covariance and sample correlation coefficient between two independent variables. When working with time series, the observations are not independent. There is often a relationship between sequential observations. We will compute the autocovariance function and autocorrelation function for a time series. Note: the prefix “auto” comes from a Greek root meaning “self.”

The figure below illustrates the difference between a series of data, where the residuals are independent compared to a series with autocorrelated data.

Check Your Understanding
  • The variances of the residuals for these two series are approximately equal. What characteristics distinguish the two series in the figure above?

Autocovariance and Autocorrelation

We will use the following data to explore the concepts of autovariance and autocorrelation.

t xt
1 4.4
2 4.2
3 4.2
4 4.0
5 4.4
6 4.7
7 4.9
8 5.3
9 5.4
10 5.5

You can use this R command to read in the observations.

x <- c( 4.4, 4.2, 4.2, 4, 4.4, 4.7, 4.9, 5.3, 5.4, 5.5 )

We will use the sample mean of these data repeatedly. The value of x¯ is:

x¯=1nt=1nxt=11047=4.7

We will be finding the autocovariance and correlation of a time series with itself. First, we start with a lag of 1. With a lag of 1 the corresponding values of the time series that are being compared are shifted by one time unit. Then, we will consider any integer lag: lag k.

Lag k Sample Autocovariance Function (acvf), ck

The lag k sample autocovariance function, acvf, denoted ck, is defined as

ck=1nt=1nk(xtx¯)(xt+kx¯)

We denote the lag by the letter k, where k0. This is the number of values the data set is shifted to compute the autocovariance.

Check Your Understanding
  • Explain the equation for ck to your partner.
  • What is the equation for c0, the value of the autocovariance function with lag k=0?
    • This expression is very similar to a definition we have encountered previously. What is it?

Lag k=1 Sample Autocovariance Function, c1

We will now find the autocovariance between the values in a time series (x=xt) and the same values, shifted by one unit of time (y=xt+1).

t xt xt+1 xtx¯ (xtx¯)2 xt+1x¯ (xx¯)(xt+1x¯)
1 4.4 4.2 -0.3 0.09 -0.5 0.15
2 4.2 4.2 -0.5 0.25 -0.5 0.25
3 4.2 4 -0.5 0.25 -0.7 0.35
4 4 4.4 -0.7 0.49 -0.3 0.21
5 4.4 4.7 -0.3 0.09 0 0
6 4.7 4.9 0 0 0.2 0
7 4.9 5.3 0.2 0.04 0.6 0.12
8 5.3 5.4 0.6 0.36 0.7 0.42
9 5.4 5.5 0.7 0.49 0.8 0.56
10 5.5 0.8 0.64
sum 47 42.6 0 2.7 0.3 2.06
Check Your Understanding
  • Working with your assigned partner, compute each of the values in row 1 by hand. Recall that x¯=4.7.
  • With your partner, add up the values in the last column to verify that the sum is 2.06.

The scatterplot below illustrates the relationship between the observed data (xt) and the next observation (xt+1).

In this example, the second variable is xt+1, where t>1. the autocovariance of xt and xt+1 is:

c1=1nt=1n1(xtx¯)(xt+1x¯)=110t=19(xtx¯)(xt+1x¯)=1102.06=0.206

This is the (auto)covariance of x with itself, but with a lag of 1 time unit. This is the value of the lag k=1 autocovariance function, acvf_1.

Check Your Understanding
  • What does the lag 1 autocovariance measure?

Lag k Sample Autocorrelation Function (acf), rk

The sample autocorrelation function, acf, denoted rk, where k is the lag, is defined as

rk=ckc0=1nt=1nk(xtx¯)(xt+kx¯)1nt=1n(xtx¯)2=t=1nk(xtx¯)(xt+kx¯)t=1n(xtx¯)2

Note that c0 is the variance of x, but computed by dividing by n, instead of n1.

Check Your Understanding
  • Interpret the components of the numerator and the denominator of the expression for rk to your partner.

Lag k=1 Sample Autocorrelation Function, r1

We can compute the lag 1 autocorrelation or the autocorrelation of x with lag 1 as the quotient r1=c1c0. We have already determined that c1=0.206. We now compute c0:

c0=1nt=1n0(xtx¯)(xt+0x¯)=1nt=1n(xtx¯)2=1102.7=0.27

We use c0 and c1 to compute r1. Here are two ways we can compute this value:

r1=c1c0=1nt=19(xtx¯)(xt+1x¯)1nt=110(xtx¯)2=1102.061102.7=0.2060.27=0.763=t=19(xtx¯)(xt+1x¯)t=110(xtx¯)2=2.062.7=0.763

  • What does the lag 1 autocorrelation, c1, measure?

Lag k=2

Check Your Understanding
  • Working with your assigned partner, fill in the blanks in the following table. Use the results to compute c2 and r2.

Tables-Handout-Excel

t xt xt+k xtx¯ (xtx¯)2 xt+kx¯ (xx¯)(xt+kx¯)
1 4.4 4.2 -0.3 0.09 -0.5 0.15
2 4.2 4 -0.5 0.25 -0.7 0.35
3 4.2 4.4 -0.5 0.25 -0.3 0.15
4 4
5 4.4
6 4.7
7 4.9 5.4 0.2 0.04 0.7 0.14
8 5.3 5.5 0.6 0.36 0.8 0.48
9 5.4 0.7 0.49
10 5.5 0.8 0.64
sum 47

The figure below illustrates the relationship between xt and xt+2.

Lag k=3

t xt xt+k xtx¯ (xtx¯)2 xt+kx¯ (xx¯)(xt+kx¯)
1 4.4 4 -0.3 0.09 -0.7 0.21
2 4.2 4.4 -0.5 0.25 -0.3 0.15
3 4.2 4.7 -0.5 0.25 0 0
4 4 4.9 -0.7 0.49 0.2 -0.14
5 4.4 5.3 -0.3 0.09 0.6 -0.18
6 4.7 5.4 0 0 0.7 0
7 4.9 5.5 0.2 0.04 0.8 0.16
8 5.3 0.6 0.36
9 5.4 0.7 0.49
10 5.5 0.8 0.64
sum 47 34.2 0 2.7 1.3 0.2

The figure below illustrates the correlations between xt and xt+3. Note that c3=0.210=0.02 and r3=0.020.27=0.0741.

Check Your Understanding
  • Does the value of r3=0.0741 seem reasonable, given the pattern in this plot?

Lag k=4

Check Your Understanding
  • Compute c4 and r4 using R (but not automated functions), Excel, or hand calculations.
t xt xt+k xtx¯ (xtx¯)2 xt+kx¯ (xx¯)(xt+kx¯)
1 4.4
2 4.2
3 4.2
4 4
5 4.4
6 4.7
7 4.9
8 5.3
9 5.4
10 5.5
sum 47

The figure below illustrates the correlations between xt and xt+4.

Check Your Understanding
  • Does the value of r4 you computed seem reasonable, given the pattern in this plot?

Class Activity: Using R to compute the acvf and acf (5 min)

We will continue to use the following sample data.

 x <- c( 4.4, 4.2, 4.2, 4, 4.4, 4.7, 4.9, 5.3, 5.4, 5.5 ) 
 df <- data.frame(x = x)

acvf

This code gives the values of the acvf.

acf(df$x, plot=FALSE, type = "covariance")

Autocovariances of series 'df$x', by lag

     0      1      2      3      4      5      6      7      8      9 
 0.270  0.206  0.121  0.020 -0.064 -0.113 -0.127 -0.093 -0.061 -0.024 

acf

We can obtain the acf by changing the argument for the paramter type to "correlation".

acf(df$x, plot=FALSE, type = "correlation")

Autocorrelations of series 'df$x', by lag

     0      1      2      3      4      5      6      7      8      9 
 1.000  0.763  0.448  0.074 -0.237 -0.419 -0.470 -0.344 -0.226 -0.089 

Homework Preview (5 min)

  • Review upcoming homework assignment
  • Clarify questions

Homework

Download Homework

Class Activity: k=2

Class Activity: k=4