Durbin-Watson Test
Durbin-Watson Test
Definition
Core Statement
The Durbin-Watson (DW) Test detects autocorrelation (or serial correlation) in the residuals of a regression analysis. It tests whether adjacent residuals are correlated, which violates the assumption of independence in Simple Linear Regression.
Purpose
- Diagnose Assumption Violation: Ensure regression error terms are independent.
- Flag Time Series Issues: Detect if a model fails to capture time-dependent patterns.
When to Use
Use Durbin-Watson When...
- Data was collected over time (Time Series).
- You fit a Linear Regression model.
- You suspect the error at time
depends on error at time .
Do NOT Use When...
- Data is cross-sectional (order doesn't matter).
- Use Breusch-Godfrey Test for higher-order autocorrelation (lag > 1).
Theoretical Background
The Statistic ( )
where
Interpretation Range
The
: No Autocorrelation (Ideal). : Positive Autocorrelation (Common in time series). : Negative Autocorrelation (Rapid oscillation).
Worked Numerical Example
Stock Returns vs Market Returns
Regression:
Residuals: [0.5, 0.4, 0.6, -0.2, -0.3, -0.5]
Observation: Positive residuals cluster together; Negative residuals cluster together.
Calculation:
- DW Statistic
.
Conclusion:
Implication: Standard errors are underestimated. Calculated t-stats are inflated. The relationship appears more significant than it really is.
Assumptions
Limitations
Pitfalls
- Order Matters: Calculating DW on unsorted cross-sectional data is meaningless.
- Inconclusive Region: The test has "bounds" (
). If falls between them, the test is inconclusive. - Only Lag 1: Does not detect seasonal patterns (e.g., Lag 4 or Lag 12 autocorrelation).
Python Implementation
import statsmodels.api as sm
from statsmodels.stats.stattools import durbin_watson
# Feature: Residuals from a fitted model
residuals = model.resid
# Calculate DW
dw_stat = durbin_watson(residuals)
print(f"Durbin-Watson: {dw_stat:.2f}")
if dw_stat < 1.5:
print("Warning: Positive Autocorrelation")
elif dw_stat > 2.5:
print("Warning: Negative Autocorrelation")
else:
print("Assumption Met: Residuals are independent")
R Implementation
library(lmtest)
# Fit Model
model <- lm(Sales ~ Time, data = df)
# Durbin-Watson Test
dwtest(model)
# Output includes DW statistic and p-value
Interpretation Guide
| DW Value | Interpretation | Edge Case Notes |
|---|---|---|
| 2.0 | No Autocorrelation. | Perfect independence. |
| 1.8 - 2.2 | Acceptable range. | Usually considered "close enough" to 2. |
| 0.5 | Strong Positive Autocorrelation. | Standard errors will be biased downwards. Risk of spurious regression. |
| 1.3 | Inconclusive Zone? | Check critical value tables ( |
Related Concepts
- Breusch-Godfrey Test - More general test for AR(p) errors.
- Ljung-Box Test - Tests white noise in ARIMA residuals.
- Time Series Analysis
- Stationarity (ADF & KPSS)