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

  1. Diagnose Assumption Violation: Ensure regression error terms are independent.
  2. 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 t depends on error at time t1.

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 (d)

d=t=2T(etet1)2t=1Tet2

where et is the residual at time t.

Interpretation Range

The d statistic ranges from 0 to 4:


Worked Numerical Example

Stock Returns vs Market Returns

Regression: ReturnAsset=β0+β1ReturnMarket
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 d=0.8.

Conclusion: d2. Strong Positive Autocorrelation.
Implication: Standard errors are underestimated. Calculated t-stats are inflated. The relationship appears more significant than it really is.


Assumptions


Limitations

Pitfalls

  1. Order Matters: Calculating DW on unsorted cross-sectional data is meaningless.
  2. Inconclusive Region: The test has "bounds" (dL,dU). If d falls between them, the test is inconclusive.
  3. 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 (dL,dU based on n and k).