Notes

Durbin-Watson Test

The Durbin-Watson test is a quick “sanity check” for a common problem in regression: errors that aren’t really independent over time. If yesterday’s model mistake makes today’s mistake more likely, your model can look more confident than it should.

What it tests
In a regression model, the residuals are the differences between observed values and the model’s predictions. The Durbin-Watson test checks for first-order autocorrelation in those residuals—meaning whether residuals tend to be correlated with the immediately previous residual (often written as correlation between et and et−1). This matters most in time-ordered data like monthly sales, daily demand, sensor readings, or economic indicators.

The statistic (and how to read it)
The test produces a Durbin-Watson statistic (often noted as d) that ranges roughly from 0 to 4:

  • d ≈ 2: little to no first-order autocorrelation (good for the usual regression assumptions).
  • d < 2: evidence of positive autocorrelation (residuals “stick” in the same direction).
  • d > 2: evidence of negative autocorrelation (residuals tend to alternate signs).

Intuitively, it compares how much residuals change from one time step to the next versus how large the residuals are overall.

Why it matters in ML and AI workflows
Autocorrelated residuals can make standard errors too small, p-values misleading, and confidence intervals overly optimistic—so feature importance and “significance” claims can be wrong. In forecasting-style ML, it’s a hint you may need time-aware structure (lags, seasonality), different error models (e.g., GLS), or a model designed for sequences.

Where you’ll see it
Common in econometrics and regression diagnostics, including statsmodels in Python and many R workflows, especially when validating linear regression on time series.

Durbin-Watson Test is a regression diagnostic that checks for first-order autocorrelation in residuals, especially in time-ordered data. It computes a statistic from successive residual differences; values near 2 suggest no autocorrelation, below 2 indicate positive autocorrelation, and above 2 indicate negative autocorrelation. This matters because autocorrelated errors can invalidate standard errors and hypothesis tests. Example: testing residual independence in a linear model forecasting daily demand.

Imagine you’re checking a weather forecast app and notice it’s wrong in a pattern: if it overestimates today, it also overestimates tomorrow. That “clumping” of mistakes is a warning sign.

The Durbin-Watson Test checks for this kind of pattern in a regression model’s errors (the differences between what the model predicts and what actually happens). Specifically, it looks for autocorrelation, meaning the errors are related across time or order. If errors are autocorrelated, the model may look more reliable than it really is, and conclusions like which factors matter can be misleading.