Calculates the sample autocorrelation function (ACF) of a stationary time series.

## Syntax

**ACF**(

**X**,

**Order**,

**K**,

**Method**)

- X
- is the univariate time series data (a one-dimensional array of cells (e.g., rows or columns)).
- Order
- is the time order in the data series (i.e., the first data point's corresponding date (earliest date = 1 (default), latest date = 0)).
Order Description 1 Ascending (the first data point corresponds to the earliest date) (default). 0 Descending (the first data point corresponds to the latest date). - K
- is the lag order (e.g., 0=no lag, 1=1st lag, etc.). If missing, the default lag order of zero (i.e., Lag=0) is assumed.
- Method
- is the calculation method for estimating the autocorrelation function (0 = Sample Autocorrelation (Default), 1 = Periodogram-based estimate, 2 = Cross-correlation).
Value Method 0 Sample autocorrelation method (default). 1 Periodogram-based estimate. method. 2 Cross-correlation method.

## Remarks

- The time series is homogeneous or equally spaced.
- The time series may include missing values (e.g., #N/A) at either end.
- The lag order (k) must be less than the time series size, or an error value (#VALUE!) is returned.
- The ACF values are bound between -1 and 1, inclusive.
- Method 1: The sample autocorrelation is computed as:$$\hat{\rho}(h)=\frac{\sum_{k=h}^T{(y_{k}-\bar y)(y_{k-h}-\bar y)}}{\sum_{k=1}^T(y_{k}-\bar y)^2}$$Where:

- $y_{t}$ is the value of the time series at time $t$.
- $h$ is the lag order.
- $T$ is the number of non-missing values in the time series data.
- $\bar y$ is the sample average/mean of the time series.

$\bar y=\frac{\sum_{i=1}^{N} y_i}{N}$

- Note that we subtract the full sample mean $\bar y$.
- Method 2: Periodogram estimate.

In this method, we compute the spectral density (periodogram is an estimator) of the sample data set and use it to calculate the sample auto-correlation. - Although the periodogram-based ACF estimate is usually biased, it generally exhibits a smaller standard error.
- Method 3: cross-correlation method:$$\rho(h)=\frac{\sum_{i=1}^{N-h}(y_i-\bar y)\times (y_{i+h}-\bar y_h)}{\sqrt{\sum_{i=1}^{N-h}(y_i-\bar y)^2 \times\sum_{j=h}^N (y_j-\bar y_h)^2}}$$Where:

- $y_{t}$ is the value of the time series at time $t$.
- $h$ is the lag order.
- $\bar y=\frac{\sum_{i=1}^{N-h} y_i}{N-h}$
- $\bar y_h=\frac{\sum_{i=h}^N y_i}{N-h}$
- $T$ is the number of non-missing values in the time series data.
- $\bar y$ is the sample average/mean of the time series.

- Special Cases:

- By definition, $\hat{\rho}(0) \equiv 1.0$.

## Files Examples

## Related Links

## References

- D. S.G. Pollock; Handbook of Time Series Analysis, Signal Processing, and Dynamics; Academic Press; Har/Cdr edition(Nov 17, 1999), ISBN: 125609906.
- James Douglas Hamilton; Time Series Analysis; Princeton University Press; 1st edition(Jan 11, 1994), ISBN: 691042896.
- Tsay, Ruey S.; Analysis of Financial Time Series; John Wiley & SONS; 2nd edition(Aug 30, 2005), ISBN: 0-471-690740.
- Box, Jenkins, and Reisel; Time Series Analysis: Forecasting and Control; John Wiley & SONS.; 4th edition(Jun 30, 2008), ISBN: 470272848.
- Walter Enders; Applied Econometric Time Series; Wiley; 4th edition(Nov 03, 2014), ISBN: 1118808568.

## Comments

Article is closed for comments.