Course contentsShow
← Data Science
Lesson 721 of 2,14519. Time Series FoundationsFree lesson

Computing ACF Values

Calculating autocorrelation for specific lags using covariance and variance.

Computing ACF Values

You'll learn how to actually calculate the autocorrelation coefficient for a specific lag using covariance and variance.

The Core Formula

Now that you understand what the ACF is (a function showing correlation at different lags), let's compute the actual values. The autocorrelation coefficient at lag k is calculated as:

ACF(k) = Covariance(yₜ, yₜ₋ₖ) / Variance(yₜ)

In plain English: divide the covariance between the series and its lagged version by the variance of the original series.

Step-by-Step Calculation

Let's say you have time series values: [10, 12, 13, 15, 14]

For lag 1:

  1. Create pairs: (10,12), (12,13), (13,15), (15,14)
  2. Calculate covariance between original and lag-1 values
  3. Calculate variance of the original series
  4. Divide covariance by variance → ACF(1)

For lag 2:

  1. Create pairs: (10,13), (12,15), (13,14)
  2. Follow the same covariance/variance division
  3. This gives you ACF(2)

Why This Works

Think of it like a correlation coefficient (which it is!). The covariance measures how the series moves with its past self, while dividing by variance standardizes this to a scale from -1 to +1. A value near +1 means strong positive autocorrelation at that lag; near 0 means no relationship; near -1 means negative autocorrelation.

The ACF at lag 0 is always 1.0 (a series is perfectly correlated with itself).

Key Takeaway: The ACF value at any lag k equals the covariance between observations k steps apart divided by the series variance—giving you a standardized measure of temporal dependence.