Understanding the Durbin-Watson statistic calculator — concept and principle
The Durbin-Watson statistic d tests whether the residuals of a regression are correlated with the residual just before them (first-order autocorrelation). Use it after fitting a regression on data ordered in time, such as monthly sales or daily readings, because correlated errors make standard errors and p-values unreliable.
How it is calculated
- d = Σ (eₜ − eₜ₋₁)² ÷ Σ eₜ², with the top sum running from t = 2 to n and the bottom from t = 1 to n.
- Lag-1 autocorrelation ≈ 1 − d ÷ 2.
Enter the residuals (observed minus fitted values) in time order, separated by commas. At least three values are needed. d is unitless and lies between 0 and 4.
The principle
Expanding the numerator gives Σeₜ² + Σeₜ₋₁² − 2Σeₜeₜ₋₁. For a long series the first two sums are each about Σeₜ², so d ≈ 2 × (1 − r), where r is the lag-1 autocorrelation of the residuals. If neighbouring residuals are unrelated (r ≈ 0), d ≈ 2. If they tend to share a sign (r near +1), consecutive differences are small and d moves toward 0. If they alternate in sign (r near −1), differences are large and d moves toward 4. Durbin and Watson derived lower and upper critical bounds (dL, dU) that depend on the sample size and number of regressors.
Worked example
- Residuals: 0.5, −0.3, 0.2, 0.4, −0.6, 0.1, −0.2, 0.3 (n = 8).
- Differences squared: 0.64, 0.25, 0.04, 1.00, 0.49, 0.09, 0.25; sum = 2.76.
- Squares of residuals: 0.25, 0.09, 0.04, 0.16, 0.36, 0.01, 0.04, 0.09; sum = 1.04.
- d = 2.76 ÷ 1.04 ≈ 2.653846154.
- Lag-1 autocorrelation ≈ 1 − 2.653846 ÷ 2 ≈ −0.3269230769.
How to read the result
- d near 2: no evidence of first-order autocorrelation.
- d well below 2: positive autocorrelation, the most common problem in time series; standard errors are usually understated.
- d well above 2: negative autocorrelation, as in the example, where residuals frequently switch sign.
For a formal decision compare d with the tabulated dL and dU (for negative autocorrelation compare 4 − d). Between the bounds the test is inconclusive. With only 8 residuals, as here, the test has little power, so treat the value as a hint.
Common mistakes
- Entering residuals in an order other than time order; the statistic is then meaningless.
- Using raw data instead of model residuals.
- Applying the test when a lagged dependent variable is a regressor; Durbin's h test or the Breusch-Godfrey test is appropriate there.
Frequently asked questions
Why is 1 − d/2 only approximate?
The end terms e₁² and eₙ² are counted once rather than twice, so the identity d = 2(1 − r) holds exactly only as n grows.
What do I do if autocorrelation is present?
Add missing time-related predictors or lags, model the errors (for example with an AR term), or use autocorrelation-robust (Newey-West) standard errors.
Sources: J. Durbin and G. S. Watson, "Testing for Serial Correlation in Least Squares Regression I and II", Biometrika 37 (1950) and 38 (1951) · J. M. Wooldridge, Introductory Econometrics: A Modern Approach, Cengage, Chapter 12