Autocorrelation Calculation Example

Autocorrelation calculator

Autocorrelation Calculation Example

Enter a time series, select a lag, and calculate the sample autocorrelation coefficient. This tool is useful for statistics, signal processing, econometrics, quality control, and forecasting workflows.

Use comma, space, or line breaks. Example: 12, 15, 14, 18, 20, 19, 23, 25, 24, 28
Ready to calculate. Use the default sample data or paste your own series.

Autocorrelation chart

The chart plots the autocorrelation function for lags from 1 up to your selected maximum lag. Values near 1 suggest strong positive persistence. Values near 0 suggest little serial dependence. Negative values indicate alternating behavior.

What is autocorrelation, and why does it matter?

Autocorrelation measures how strongly a variable is related to its own past values. Instead of comparing two different variables, autocorrelation compares a series with lagged versions of itself. If a time series shows a strong relationship between today and yesterday, or between this month and last month, it has positive autocorrelation. If high values tend to be followed by low values, and low values tend to be followed by high values, it may show negative autocorrelation. When the relationship is weak or absent, the autocorrelation is close to zero.

In practical analysis, autocorrelation is one of the first diagnostic tools used to understand whether observations are independent. Independence matters in many models. Ordinary least squares regression, classical control charts, and many hypothesis tests often assume that observations are not serially dependent. If autocorrelation is present and ignored, estimated standard errors can be too small, confidence intervals can be too optimistic, and forecasts can become unreliable. This is why analysts in economics, finance, climatology, manufacturing, epidemiology, and engineering routinely examine autocorrelation before finalizing a model.

Core idea: a sample autocorrelation at lag k asks, “How similar is the series to itself after shifting it by k periods?”

Autocorrelation calculation example, step by step

Suppose we have the following short time series:

12, 15, 14, 18, 20, 19, 23, 25, 24, 28

This sequence has an upward tendency with a few minor reversals. To compute the sample autocorrelation at lag 1, we first calculate the mean of the full series. The average is 19.8. Next, we subtract the mean from each observation to get the centered values. Then we multiply each centered value by the centered value from one period earlier, sum those products, and divide by the total centered sum of squares.

Time Value Centered value, xt – mean Lag 1 product with prior centered value
112-7.8Not applicable
215-4.837.44
314-5.827.84
418-1.810.44
5200.2-0.36
619-0.8-0.16
7233.2-2.56
8255.216.64
9244.221.84
10288.234.44

For this example, the sum of lag 1 products is 145.60. The denominator, which is the total sum of squared centered values, is 229.60. Therefore, the lag 1 sample autocorrelation is:

r1 = 145.60 / 229.60 = 0.6341

A value of 0.6341 indicates moderately strong positive autocorrelation. In plain language, adjacent values in this series tend to move in the same direction and remain somewhat similar from one period to the next.

The formula used by this calculator

The calculator applies the common mean centered sample autocorrelation formula:

rk = Σ[(xt – x̄)(xt-k – x̄)] / Σ[(xt – x̄)2]

Here, is the mean of the entire series, and k is the lag. The numerator is the covariance between the series and its lagged copy. The denominator scales the value so that the result generally falls between -1 and 1.

How to interpret autocorrelation values

  • Near +1: strong positive persistence, neighboring observations are similar.
  • Near 0: little or no linear serial dependence at that lag.
  • Near -1: strong negative dependence, values tend to alternate.

Interpretation always depends on context, sample size, and whether a trend or seasonal component is present. A trending series can produce positive autocorrelation even if the underlying process is not stationary. That is why autocorrelation is often paired with differencing, detrending, residual analysis, and stationarity checks.

Pattern type Typical lag 1 range What it often signals Practical example
Strong positive autocorrelation 0.60 to 0.95 Persistence, trend carryover, slow adjustment Daily temperature, many macroeconomic indicators
Weak or near zero autocorrelation -0.10 to 0.10 Approximate independence, white noise behavior Well shuffled observations, random process residuals
Negative autocorrelation -0.20 to -0.90 Alternation, overshooting, correction effects Inventory adjustments, certain control systems

Why the autocorrelation function, or ACF, is so useful

The autocorrelation function reports autocorrelation for multiple lags instead of just one. Looking at lag 1 alone can miss important structure. For example, a monthly series might have only mild lag 1 autocorrelation but very strong lag 12 autocorrelation because of seasonality. By plotting a full ACF, analysts can identify patterns that suggest autoregressive dynamics, moving average behavior, trend contamination, or periodic cycles.

In forecasting, the ACF helps in the early stages of ARIMA identification. In quality engineering, it can reveal whether process measurements are serially dependent, which affects control chart assumptions. In finance, autocorrelation in returns or volatility informs market efficiency questions and risk modeling. In environmental science, serial dependence is common because physical systems evolve gradually over time.

Common mistakes when working through an autocorrelation calculation example

  1. Using the wrong mean: the mean should usually come from the full observed series, not from only the overlapping lagged segment.
  2. Ignoring trend or seasonality: a trend can inflate positive autocorrelation. Seasonal effects can create spikes at seasonal lags.
  3. Using too few observations: small samples can produce unstable autocorrelation estimates.
  4. Confusing covariance with correlation: covariance is unscaled, while autocorrelation is normalized and easier to interpret.
  5. Overreading small spikes: not every nonzero value is meaningful. Sampling noise matters.

When should you trust an autocorrelation result?

Autocorrelation is most informative when the series is measured at regular intervals and the analyst has enough data to estimate dependence reliably. A very short series can generate a dramatic lag value by chance. A larger sample provides more stable estimates. For many introductory applications, at least 30 to 50 observations is better than 10, although exact needs vary by use case.

Another good practice is to examine residuals rather than only raw data. If you fit a trend line or a regression model, residual autocorrelation tells you whether the model has left structure unexplained. This is often more relevant than the autocorrelation of the raw series itself. The U.S. National Institute of Standards and Technology discusses autocorrelation plots as a core diagnostic in time series and process analysis, and the Penn State statistics curriculum also emphasizes the role of lag structure in model identification and diagnostics.

Worked interpretation of the default example

Using the default data in the calculator, the lag 1 coefficient is positive and noticeably above zero. That means values close together in time tend to be similar. If you increase the chart lag to 5 or 6, you will usually see that the autocorrelation declines as lag increases. This decay pattern is common in persistent series. It does not automatically tell you the exact model, but it does indicate that the observations are not independent.

If you replace the default series with a pattern like 10, 20, 10, 20, 10, 20, the lag 1 autocorrelation will be strongly negative because values alternate sharply. If you enter values that appear more random, such as shuffled measurements with no visible pattern, the lag coefficients should cluster closer to zero.

Useful references from authoritative sources

Best practices for using this calculator

  • Paste values in chronological order, oldest to newest.
  • Choose a lag smaller than the number of observations.
  • Use the chart to look beyond a single coefficient.
  • Inspect your data for trend, seasonality, and outliers.
  • For model building, evaluate residual autocorrelation after fitting a model.

Final takeaway

An autocorrelation calculation example becomes much easier to understand once you see the process in small steps: compute the mean, center the data, multiply matched values across a lag, add the products, and scale by the total centered variation. The result gives a compact summary of serial dependence. Positive values indicate persistence, negative values indicate alternation, and values near zero suggest weak linear dependence at that lag. With the calculator above, you can test your own series, inspect the ACF visually, and build intuition that carries directly into forecasting, diagnostics, and statistical modeling.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top