Calculator
Example Data Table
Use this sample series to see how lag-based results behave.
| t | Value | Note |
|---|---|---|
| 1 | 1.20 | Start of sequence |
| 2 | 0.90 | Slight drop |
| 3 | 1.10 | Recovery |
| 4 | 1.40 | Local rise |
| 5 | 0.80 | Correction |
| 6 | 0.70 | Lower point |
| 7 | 1.00 | Back toward center |
| 8 | 1.30 | Another rise |
Tip: For Q-tests, choose m between 5 and 20 for many practical datasets, but keep m well below n.
Formula Used
How to Use This Calculator
- Paste your time-ordered values into the data box.
- Choose a test method that matches your goal.
- Set maximum lag m and significance level α.
- Click Submit to see results above the form.
- Use CSV or PDF export for documentation.
- If results reject the null, consider modeling dependence.
Guidance: Apply these tests to residuals from a fitted model when checking independence assumptions.
Why Autocorrelation Testing Matters
Autocorrelation measures whether observations in a sequence are related to earlier values. When correlation exists across time, standard errors and confidence intervals based on independence can become misleading. In forecasting, quality control, and experimental monitoring, detecting dependence helps prevent overconfident conclusions and improves model selection. It also indicates whether shocks fade quickly or persist.
Understanding Lag Structure in Real Data
A lag represents the distance between two observations in the series. Lag 1 checks immediate persistence, while higher lags reveal cycles and delayed effects. This calculator reports a sample autocorrelation for each lag and highlights dominant patterns. Large positive values suggest persistence; large negative values suggest alternation or mean reversion. Ensure the data is time ordered, and consider detrending when long-run drift dominates. Missing values should be handled carefully.
How the Ljung–Box Family Aggregates Evidence
The Ljung–Box and Box–Pierce statistics test the joint hypothesis that autocorrelations up to a chosen maximum lag are zero. Instead of judging each lag separately, they combine squared autocorrelations into one statistic. Under the null, the statistic follows an approximate chi-square distribution with degrees of freedom equal to the number of lags tested. Select a maximum lag that matches plausible memory in the process, but avoid extremely high lags in short samples. For model residuals, account for estimated parameters when interpreting the chi-square reference.
Durbin–Watson for Residual Independence Checks
When you fit a regression and analyze residuals, the Durbin–Watson statistic focuses on first-order autocorrelation. Values near 2 indicate weak first-order dependence, below 2 indicates positive autocorrelation, and above 2 indicates negative autocorrelation. Use it as a quick diagnostic, then confirm with lag-based tests when dependence may extend beyond lag 1. Always compute residuals in the original time sequence.
Professional Reporting and Follow-Up Actions
Report the method, sample size, maximum lag, and significance level alongside the p-value and decision. A small p-value indicates evidence against independence, not necessarily large practical impact. If dependence is detected, consider ARIMA errors, generalized least squares, or robust standard errors for inference. Review plots and domain drivers, because seasonality, batching, and sensor smoothing can mimic autocorrelation. Save CSV or PDF outputs to document your assumptions and results.
FAQs
What is the null hypothesis in these tests?
The null hypothesis is that the series is independent up to the tested lags. In practice, this means autocorrelations are zero and past values do not predict future values beyond random noise.
How should I choose the maximum lag m?
Pick m based on expected memory, season length, or business cycle. With small samples, keep m modest so the test has stable degrees of freedom and avoids diluting power.
Why can a trend create autocorrelation?
A trend makes nearby points similar because the mean changes over time. This violates stationarity and often produces positive autocorrelation even if the underlying deviations are independent. Detrend or difference before testing.
Can I use this on regression residuals?
Yes. Residual tests check whether the fitted model removed time dependence. Use the same time ordering as the data, and interpret results alongside Durbin–Watson and residual plots for confirmation.
What sample size is recommended?
More data improves reliability. As a rule, aim for at least 30–50 observations for basic diagnostics, and more when testing many lags. Very short samples can yield unstable p-values.
What should I do if autocorrelation is significant?
Consider adding lag terms, ARIMA errors, or seasonal components. For inference, use robust or GLS methods. Also inspect data collection steps, because batching, filtering, or rounding can introduce dependence.