Skip to content

Autocorrelation Calculator

Updated:

Compute sample autocorrelation coefficients r_k for any time series at one or more lags. Paste your ordered observations, choose the lags and the estimator, and get r_k with a white-noise significance band.

Test Whether a Series Is Correlated with Its Own Past

Input Fields
k
One or more lag lengths k (how many steps back to compare). Separate several lags with spaces or semicolons, e.g. 1; 2; 3; 4.
If enabled, the result will update automatically when you change any value.

Autocorrelation Formula

Formula
\[ r_k = \frac{c_k}{c_0}, \qquad c_k = \frac{1}{n}\sum_{t=1}^{n-k} (x_t - \bar{x})(x_{t+k} - \bar{x}), \qquad c_0 = \frac{1}{n}\sum_{t=1}^{n} (x_t - \bar{x})^2 \]

Where:

  • \(r_k\) — sample autocorrelation at lag \(k\) (the correlation of the series with itself shifted \(k\) steps back)
  • \(x_t\) — observation at time \(t\); \(\bar{x}\) — mean of the series
  • \(n\) — number of observations
  • \(c_k\) — sample autocovariance at lag \(k\); \(c_0\) — sample variance

The coefficient compares each observation with the one \(k\) steps earlier, after both are centered on the mean. Dividing by \(c_0\) forces every \(r_k\) into the range \([-1, 1]\). With the "unbiased" estimator, the sum defining \(c_k\) is divided by \(n-k\) instead of \(n\).

Autocorrelation – Calculation Example

Example: a series of 12 observations: 2, 4, 3, 5, 7, 6, 8, 10, 9, 11, 13, 12, with lags 1, 2, 3 and the standard ACF estimator.

\[ \bar{x} = \frac{90}{12} = 7.5, \qquad c_0 = \frac{143}{12} = 11.9167 \]

\[ c_1 = \frac{101.75}{12} = 8.4792 \;\Rightarrow\; r_1 = \frac{8.4792}{11.9167} = 0.7117 \]

\[ c_2 = \frac{69}{12} = 5.75 \;\Rightarrow\; r_2 = 0.4825, \qquad c_3 = \frac{39.75}{12} = 3.3125 \;\Rightarrow\; r_3 = 0.2780 \]

Result: \(r_1 = 0.7117\), \(r_2 = 0.4825\), \(r_3 = 0.2780\). The 95% white-noise band is \(\pm 1.96/\sqrt{12} = \pm 0.566\), so only the lag-1 autocorrelation is significant: the series shows persistence — high values follow high values — and the autocorrelation decays smoothly, which is typical of a trending series.

How to use the calculator

  1. Enter your observations in Time-series values (in order), oldest first. Separate values with spaces, semicolons or line breaks; decimal commas are accepted. You need at least 3 values.
  2. Type the lag lengths in Lag(s) to compute — a single lag (e.g. 1) or several separated by spaces or semicolons (e.g. 1; 2; 3; 4). Each lag must be a whole number between 1 and \(n-1\).
  3. Choose the Estimator: "Standard ACF (divide by n)" matches what statistical software plots in ACF charts; "Unbiased (divide by n − k)" corrects the small-sample downward bias at longer lags.
  4. Read the results table: the number of overlapping pairs used at each lag, the coefficient \(r_k\), and whether it falls outside the \(\pm 1.96/\sqrt{n}\) white-noise band.

What is autocorrelation?

Autocorrelation (serial correlation) measures how strongly a time series is linearly related to its own past. Instead of correlating two different variables, you correlate the series with a copy of itself shifted back by \(k\) time steps — the lag. The result, \(r_k\), is interpreted exactly like a Pearson correlation: \(+1\) means the shifted series moves in perfect lockstep with the original, \(-1\) means it moves perfectly oppositely, and values near 0 mean no linear relationship at that lag.

Autocorrelation is one of the first diagnostic tools in time-series analysis. A lag-1 coefficient well above zero indicates persistence (values tend to stay above or below the mean for a while), while a strong negative one indicates alternation — the series overshoots the mean in both directions. Plotting \(r_k\) against \(k\) gives the autocorrelation function (ACF), the standard tool for identifying ARIMA models and for spotting seasonality.

The pattern across lags matters more than any single value. Slowly decaying positive autocorrelations suggest a trend or non-stationarity — consider differencing the series first. A single spike at lag k points to a seasonal or cyclical pattern with period \(k\) (e.g. a spike at lag 12 in monthly data means an annual cycle). Coefficients that stay inside the white-noise band at all lags suggest the series has no linear memory, which is exactly what you want to see in model residuals.

Note that autocorrelation captures only linear dependence. A series can be strongly predictable by nonlinear rules yet show near-zero autocorrelation, so a "clean" ACF is not proof of independence. For a formal check of whether a whole set of autocorrelations is consistent with white noise, use a portmanteau test such as Ljung–Box.

Assumptions, limitations and practical tips

  • Order and spacing matter. The values must be in their natural time order and equally spaced (same time step between observations). Shuffling the data destroys the autocorrelation.
  • Stationarity. The coefficients are only meaningful if the series has a roughly stable mean and variance. A trending series inflates early-lag autocorrelations; difference it first if needed.
  • Long lags are unreliable. At lag \(k\) only \(n-k\) overlapping pairs are used, so lags beyond about \(n/2\) rest on very few pairs. With 12 observations, treat anything above lag 6 as noise.
  • Estimator choice. The standard estimator (divide by \(n\)) always yields a valid correlation function and matches ACF plots in Box–Jenkins software. The unbiased version (divide by \(n-k\)) removes the downward bias at long lags but can theoretically push coefficients outside \([-1, 1]\).
  • The significance band is a guide. The \(\pm 1.96/\sqrt{n}\) limits assume the true series is white noise. If real autocorrelation exists, the band underestimates the sampling spread at neighboring lags.
  • Outliers distort results. A single extreme observation can dominate both the mean and the products in \(c_k\). Check your data first, or consider robust alternatives such as rank-based correlation measures.

If you are comparing two different series instead of a series with its own past, use a correlation tool such as the Spearman rank correlation calculator or the Kendall's tau calculator. To summarize the overall shape of a single series before modeling it, the skewness and kurtosis calculator is a natural companion.

Frequently Asked Questions

What is a good or normal autocorrelation value?

There is no universal "good" value — it depends on what you are testing. For raw data, the size of \(r_k\) simply tells you how much linear memory the series has. For model residuals, you want values near zero: anything outside the \(\pm 1.96/\sqrt{n}\) band suggests the model has not captured all the structure. As a rough scale, \(|r_1| > 0.5\) is strong, 0.2–0.5 is moderate, and below 0.2 is weak.

How is autocorrelation different from partial autocorrelation (PACF)?

The autocorrelation at lag \(k\) includes both the direct relationship between \(x_t\) and \(x_{t-k}\) and all the indirect links through the lags in between. Partial autocorrelation removes those intermediate lags and isolates the direct effect. That is why the ACF and PACF are read together when identifying ARIMA models: a slowly decaying ACF with a single significant PACF spike suggests an AR process, while the reverse suggests an MA process.

How many lags should I calculate, and how long does my series need to be?

A common rule of thumb is to examine lags up to about \(n/4\), and to treat any lag beyond \(n/2\) as unreliable because only \(n-k\) overlapping pairs remain. For serious ACF analysis you ideally want at least 50 observations; with 10–20 points only the first one or two lags carry meaningful information. For seasonal data, include at least one or two full seasonal cycles, e.g. lags up to 24 for monthly data.

Does autocorrelation have units?

No. Like any correlation coefficient, \(r_k\) is dimensionless and always lies between \(-1\) and \(+1\), regardless of whether your data are measured in dollars, degrees Celsius, or counts. The autocovariance \(c_k\) does carry the squared units of the data, but dividing by the variance \(c_0\) cancels them out. This also means rescaling your series (e.g. from Celsius to Fahrenheit) does not change any autocorrelation.

Can I compute this by correlating the series with a shifted copy in Excel?

You can get close: put the series in column A, a copy shifted by \(k\) rows in column B, and use CORREL on the overlapping range. The result differs slightly from the standard ACF because Excel's CORREL centers each truncated segment on its own mean, while the ACF centers both on the mean of the full series. The discrepancy is small for long series but noticeable for short ones — use this calculator's method if you need to match statistical software.

What does a negative lag-1 autocorrelation mean?

A negative \(r_1\) indicates alternation: values above the mean tend to be followed by values below it, and vice versa. You often see this after over-differencing a smooth series, in oscillating or mean-reverting processes, or when consecutive adjustments deliberately offset each other. Strongly negative residual autocorrelation can signal that a model overcorrects from one period to the next. Values near \(-1\) at lag 1 are rare in real data and may indicate the series was artificially constructed.

What should I do if my series has missing values or uneven time spacing?

Autocorrelation assumes equally spaced observations in strict time order, so gaps change the meaning of a lag. Options: interpolate or impute small gaps; aggregate irregular data into regular intervals (e.g. daily averages); or, if timestamps are available, use methods designed for irregular series. Simply deleting the missing rows shortens the apparent lag structure and can bias results. Also make sure you enter values oldest first — entering them in reverse order flips the sign of nothing but can matter for asymmetric analyses.

Leave a Reply

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