Durbin-Watson Test

Introduction
The Durbin-Watson Test checks whether the residuals from a regression model are serially correlated-that is, whether knowing one residual tells you something about the residual that comes right after it. If you are fitting a regression to time-ordered data-monthly sales, daily stock returns, quarterly economic indicators-and want to know whether your model's errors are behaving like independent noise or quietly trending together over time, this is usually the test you are looking for.
By the end of this article you will be able to state exactly when a Durbin-Watson Test applies, compute the statistic completely by hand on two different worked examples, understand the famous "inconclusive zone" and why it exists, interpret the result correctly, know what to do if autocorrelation is detected, and run the same test in one line of Python with statsmodels.
What Is the Durbin-Watson Test?
Ordinary least squares regression assumes the errors are independent of one another. When data is collected in a sequence-over time, or in any other naturally ordered fashion-that assumption can quietly fail: a positive shock this period often leaves a positive residual next period too, because whatever caused the first deviation (an economic trend, a seasonal effect, an omitted variable) hasn't fully gone away. The Durbin-Watson Test measures exactly this kind of first-order autocorrelation by comparing how much consecutive residuals differ from each other against how much the residuals vary overall.
It exists because autocorrelated residuals don't bias the regression coefficients themselves, but they do make the standard errors reported by ordinary least squares unreliable-typically too small-which makes t-statistics and p-values look more significant than they really are. Catching this early, before trusting a model's significance tests, is the entire purpose of running a Durbin-Watson Test as a standard regression diagnostic.
When to Use It
Use a Durbin-Watson Test after fitting a regression whenever your observations have a natural order-almost always time, but occasionally spatial position or any other sequence where nearby observations might influence each other. The key requirement: you already have a fitted ordinary least squares regression, and you want to check whether its residuals, in their natural order, behave like independent noise.
| Scenario | Regression | What's Being Checked |
|---|---|---|
| Sales forecasting | Monthly sales vs marketing spend, season, price | Whether residuals trend together month to month |
| Macroeconomic modeling | GDP growth vs interest rate, inflation | Whether quarterly shocks persist across quarters |
| Stock return modeling | Daily returns vs market factors | Whether pricing errors carry over day to day |
| Sensor/IoT data analysis | Temperature reading vs time, load | Whether measurement errors persist across readings |
| Panel/longitudinal studies | Outcome vs covariates, repeated over time per subject | Whether within-subject residuals are serially linked |
Key Assumptions
- Regression includes an intercept: the model the residuals come from must have been fitted with a constant term for the standard Durbin-Watson tables to apply.
- Regressors are strictly exogenous (non-stochastic, or fixed in repeated sampling): the classical test is not valid when a lagged dependent variable appears among the predictors-in that case the statistic is biased toward 2, masking real autocorrelation.
- Errors follow a first-order autoregressive process, if autocorrelated at all: the test is specifically built to detect first-order (lag-1) autocorrelation; it is not designed to catch higher-order patterns directly.
- Observations are in their natural, meaningful order: shuffling the data destroys the information the test relies on-row order must reflect the true sequence (e.g., time or space).
- No missing observations within the sequence: gaps in an otherwise time-ordered series can distort the statistic, since the test assumes consecutive rows are genuinely adjacent in the underlying sequence.
Hypotheses
The Durbin-Watson Test formally tests whether the first-order autocorrelation coefficient \( \rho \) of the regression residuals is zero:
- Null Hypothesis (\( H_0 \)): \( \rho = 0 \)-there is no first-order autocorrelation in the residuals.
- Alternative Hypothesis (\( H_1 \)): \( \rho \neq 0 \)-the residuals exhibit first-order autocorrelation (commonly tested as a one-sided alternative, \( \rho > 0 \), for positive autocorrelation).
(Because positive autocorrelation is by far the most common real-world concern-especially in economic and business time series-most practical applications of the Durbin-Watson Test use the one-sided alternative \( H_1: \rho > 0 \), checking only whether the statistic falls significantly below 2.)
The Formula, Explained
Let \( e_1, e_2, \ldots, e_n \) be the residuals from a fitted ordinary least squares regression, kept in their natural time (or sequence) order. The Durbin-Watson statistic is:
\[ d = \frac{\displaystyle\sum_{t=2}^{n} (e_t - e_{t-1})^2}{\displaystyle\sum_{t=1}^{n} e_t^2} \]The numerator sums the squared change between every pair of consecutive residuals; the denominator is simply the sum of squared residuals (proportional to their total variance). This ratio always falls between 0 and 4, and it is closely related to the first-order sample autocorrelation \( \hat{\rho} \) of the residuals by the approximation:
\[ d \approx 2(1 - \hat{\rho}) \]This relationship is the key to reading the statistic at a glance:
| Durbin-Watson \( d \) | Implied \( \hat{\rho} \) | Interpretation |
|---|---|---|
| \( d \approx 0 \) | \( \hat{\rho} \approx 1 \) | Strong positive autocorrelation |
| \( d \approx 2 \) | \( \hat{\rho} \approx 0 \) | No autocorrelation |
| \( d \approx 4 \) | \( \hat{\rho} \approx -1 \) | Strong negative autocorrelation |
Critical Values and the Inconclusive Zone
Unlike most test statistics, the exact sampling distribution of \( d \) under \( H_0 \) depends on the specific values of the regressors used-not just on \( n \) and the number of predictors \( k \). Durbin and Watson could not derive one universal set of critical values, so instead they published two bounds for every combination of \( n \) and \( k \): a lower bound \( d_L \) and an upper bound \( d_U \).
For testing positive autocorrelation (\( H_1: \rho > 0 \)) at a chosen significance level:
| Condition | Decision |
|---|---|
| \( d < d_L \) | Reject \( H_0 \)-significant positive autocorrelation |
| \( d_L \leq d \leq d_U \) | Inconclusive-the test cannot decide either way |
| \( d > d_U \) | Fail to reject \( H_0 \)-no significant positive autocorrelation |
By symmetry (since \( d \) ranges from 0 to 4), negative autocorrelation is checked using \( 4 - d \) against the same \( d_L \) and \( d_U \) bounds.
Worked Example 1: A Small Numerical Example by Hand
Suppose a simple regression on 6 time-ordered observations produces the following residuals, already listed in their correct time order:
| Time \( t \) | Residual \( e_t \) |
|---|---|
| 1 | 2.0 |
| 2 | 1.5 |
| 3 | 1.0 |
| 4 | -0.5 |
| 5 | -1.5 |
| 6 | -2.0 |
Step 1: Compute the squared consecutive differences (numerator)
\[ (e_2-e_1)^2 = (1.5-2.0)^2 = 0.25 \qquad (e_3-e_2)^2 = (1.0-1.5)^2 = 0.25 \] \[ (e_4-e_3)^2 = (-0.5-1.0)^2 = 2.25 \qquad (e_5-e_4)^2 = (-1.5-(-0.5))^2 = 1.00 \] \[ (e_6-e_5)^2 = (-2.0-(-1.5))^2 = 0.25 \] \[ \sum_{t=2}^{6}(e_t - e_{t-1})^2 = 0.25+0.25+2.25+1.00+0.25 = 4.00 \]Step 2: Compute the sum of squared residuals (denominator)
\[ \sum_{t=1}^{6} e_t^2 = 2.0^2+1.5^2+1.0^2+(-0.5)^2+(-1.5)^2+(-2.0)^2 \] \[ = 4.00+2.25+1.00+0.25+2.25+4.00 = 13.75 \]Step 3: Compute the Durbin-Watson statistic
\[ d = \frac{4.00}{13.75} \approx 0.291 \]Step 4: Interpret
With \( d \approx 0.291 \), far below 2 and close to 0, the residuals show strong positive autocorrelation-and indeed, looking at the table, the residuals trend smoothly from positive to negative rather than bouncing around randomly, exactly the pattern positive autocorrelation produces. Using the implied-correlation approximation, \( \hat{\rho} \approx 1 - d/2 \approx 0.855 \), confirming the residuals are very strongly correlated with their immediate predecessor.
Worked Example 2: Sales Trend Regression
A retailer regresses monthly sales (in $1,000s) on a simple linear time trend for 10 consecutive months. After fitting the regression, the residuals \( e_t \) (already in time order) are:
| Month \( t \) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Residual \( e_t \) | -1.2 | 0.8 | -0.9 | 1.1 | -1.0 | 0.9 | -1.1 | 1.0 | -0.8 | 1.2 |
Step 1: Compute the squared consecutive differences
Each consecutive pair alternates sign, so each difference is roughly double the residual magnitude:
\[ (0.8-(-1.2))^2=4.00,\ (-0.9-0.8)^2=2.89,\ (1.1-(-0.9))^2=4.00,\ (-1.0-1.1)^2=4.41, \] \[ (0.9-(-1.0))^2=3.61,\ (-1.1-0.9)^2=4.00,\ (1.0-(-1.1))^2=4.41,\ (-0.8-1.0)^2=3.24,\ (1.2-(-0.8))^2=4.00 \] \[ \sum_{t=2}^{10}(e_t-e_{t-1})^2 = 4.00+2.89+4.00+4.41+3.61+4.00+4.41+3.24+4.00 = 34.56 \]Step 2: Compute the sum of squared residuals
\[ \sum_{t=1}^{10} e_t^2 = 1.44+0.64+0.81+1.21+1.00+0.81+1.21+1.00+0.64+1.44 = 10.20 \]Step 3: Compute the Durbin-Watson statistic
\[ d = \frac{34.56}{10.20} \approx 3.388 \]Step 4: Interpret
With \( d \approx 3.388 \), well above 2 and approaching 4, the residuals show negative autocorrelation-consecutive residuals alternate sign almost every single month, a classic zig-zag pattern. For \( n = 10 \) and \( k = 1 \) predictor at \( \alpha = 0.05 \), the published bounds are approximately \( d_L \approx 0.88 \) and \( d_U \approx 1.32 \). Testing negative autocorrelation uses \( 4 - d \approx 0.612 \), which falls below \( d_L \), so we reject \( H_0 \): the negative autocorrelation is statistically significant. This pattern often signals an over-differenced series or an over-corrected trend term-worth investigating before trusting the regression's standard errors.
Python Example
You can compute the Durbin-Watson statistic in one line using statsmodels.stats.stattools.durbin_watson, or read it directly off any OLS summary:
import numpy as np
import statsmodels.api as sm
from statsmodels.stats.stattools import durbin_watson
# Worked Example 2 data: monthly sales vs a simple time trend
month = np.arange(1, 11)
sales = np.array([48.8, 51.8, 51.1, 54.1, 53.0, 55.9, 54.9, 58.0, 58.2, 61.2])
X = sm.add_constant(month)
model = sm.OLS(sales, X).fit()
dw_stat = durbin_watson(model.resid)
print(f"Durbin-Watson statistic: {dw_stat:.3f}")
# Also printed automatically in the regression summary:
print(model.summary())
Output (excerpt):
Durbin-Watson statistic: 3.388
...
==============================================================================
Durbin-Watson: 3.388
==============================================================================
This matches Worked Example 2 exactly-OLS summaries in statsmodels report the Durbin-Watson statistic by default in every regression output, right next to the Jarque-Bera and condition-number diagnostics, precisely because checking for autocorrelation is considered a standard part of validating any regression.
Getting an Exact p-value with Breusch-Godfrey
Because the classical Durbin-Watson tables only provide bounds, it is common practice to follow up with the Breusch-Godfrey Test for a definitive p-value:
from statsmodels.stats.diagnostic import acorr_breusch_godfrey
bg_test = acorr_breusch_godfrey(model, nlags=1)
lm_stat, lm_pvalue, f_stat, f_pvalue = bg_test
print(f"Breusch-Godfrey LM statistic: {lm_stat:.3f}")
print(f"Breusch-Godfrey p-value: {lm_pvalue:.4f}")
# A small p-value confirms significant autocorrelation,
# resolving any ambiguity from the Durbin-Watson bounds.
How to Interpret Results
Because the Durbin-Watson statistic is a bounded ratio rather than a p-value, interpretation happens on its own 0-to-4 scale, anchored at 2 for no autocorrelation.
| Range of \( d \) | Interpretation |
|---|---|
| Roughly \( 1.5 \) to \( 2.5 \) | No strong evidence of autocorrelation (rule of thumb, not a formal test) |
| Well below \( 1.5 \), especially below \( d_L \) | Positive autocorrelation-residuals trend together over time |
| Well above \( 2.5 \), especially above \( 4 - d_L \) | Negative autocorrelation-residuals alternate sign over time |
| Between \( d_L \) and \( d_U \) (or their \( 4 - d \) mirror) | Formally inconclusive-consult Breusch-Godfrey instead |
Checking Assumptions in Practice
- Confirm the data is genuinely ordered: verify the rows are sorted by time (or the relevant sequence) before running the test-shuffled data will silently produce a meaningless statistic.
- Check for a lagged dependent variable: if any predictor is a lagged version of the outcome itself, the classical Durbin-Watson statistic is biased toward 2 and should not be trusted-use the Breusch-Godfrey Test instead.
- Residual plot over time: a simple line plot of residuals against their time index visually confirms what the statistic suggests-smooth trending (as in Worked Example 1) or a zig-zag pattern (as in Worked Example 2).
- Higher-order autocorrelation: the classical Durbin-Watson Test only checks lag-1 autocorrelation-if seasonal or longer-lag patterns are suspected (e.g., quarterly effects in monthly data), run Breusch-Godfrey with a higher
nlagsvalue instead. - Sample size: the published critical-value tables assume a reasonably sized sample; very small \( n \) makes the inconclusive zone proportionally larger and less useful.
What to Do If Autocorrelation Is Detected
- Check for model misspecification first: a missing trend, seasonal dummy, or omitted explanatory variable is the single most common cause of residual autocorrelation-adding the missing term often resolves the issue entirely.
- Use HAC (Newey-West) standard errors: if the coefficients themselves look reasonable, keep them and simply replace the standard errors with heteroskedasticity-and-autocorrelation-consistent estimates, which remain valid under autocorrelated errors.
- Switch to Generalized Least Squares (GLS): if the autocorrelation structure is well understood (e.g., a simple AR(1) process), GLS can produce more efficient coefficient estimates than plain OLS.
- Model the error structure directly: for genuinely time-series data, consider an ARIMA-type model or add lagged values of the outcome as predictors (while switching your diagnostic test to Breusch-Godfrey, since Durbin-Watson is no longer valid in that case).
- Difference the data: for strongly trending series, taking first differences of both the outcome and predictors before regressing can remove much of the autocorrelation, though this changes what the coefficients represent.
Advantages
- Extremely simple to compute-just squared differences and squared residuals, both already available after any regression fit.
- Reported automatically by most statistical software (including
statsmodels'OLSsummary) as a routine diagnostic, so it is nearly always available at no extra cost. - The 0-to-4 scale with a clear "2 means no autocorrelation" anchor is intuitive to read at a glance, without needing to consult a p-value first.
- Well-established, published critical-value tables exist for a wide range of sample sizes and numbers of predictors.
- Serves as a standard first check before deciding whether more elaborate autocorrelation-robust methods are needed.
Limitations
- Only detects first-order (lag-1) autocorrelation-misses higher-order or seasonal patterns unless those happen to also produce a lag-1 signal.
- Has a formally inconclusive zone between \( d_L \) and \( d_U \), where the classical test simply cannot decide.
- Invalid when the regression includes a lagged dependent variable as a predictor-the statistic becomes biased toward 2, hiding real autocorrelation.
- Requires observations to be correctly ordered; provides no meaningful information on unordered (cross-sectional) data.
- Critical value tables become harder to find or use for unusual designs with many predictors or irregular spacing.
When NOT to Use It
- Breusch-Godfrey Test: use instead when a lagged dependent variable is among the predictors, when you need to test autocorrelation beyond lag 1, or whenever you want a definitive p-value with no inconclusive zone.
- Ljung-Box Test: use instead when testing a time series (or its residuals) for autocorrelation across multiple lags jointly, rather than just lag 1-common in ARIMA model diagnostics.
- Cross-sectional data with no natural order: don't use the Durbin-Watson Test at all if your observations have no meaningful sequence-there is nothing for "consecutive" residuals to represent.
- Runs Test: use instead as a simpler, distribution-free check for non-randomness in a residual sequence, useful as a quick sanity check alongside Durbin-Watson.
Durbin-Watson vs Breusch-Godfrey vs Ljung-Box
17.1 Durbin-Watson Test vs Breusch-Godfrey Test
| Aspect | Durbin-Watson Test | Breusch-Godfrey Test |
|---|---|---|
| Lags detected | Only lag 1 | Any specified number of lags |
| Lagged dependent variable as predictor | Invalid-biased toward 2 | Remains valid |
| Output | Bounded statistic (0 to 4), with inconclusive zone | Chi-square/F statistic with an exact p-value |
| Underlying framework | Direct ratio of squared residual differences | Lagrange Multiplier (Score) Test on an auxiliary regression |
17.2 Durbin-Watson Test vs Ljung-Box Test
| Aspect | Durbin-Watson Test | Ljung-Box Test |
|---|---|---|
| Typical use case | Diagnostic on regression residuals | Diagnostic on time series or ARIMA model residuals |
| Lags tested | Lag 1 only | Jointly tests multiple lags at once |
| Distribution | Bounded 0-4 statistic with published bounds | Chi-square distribution with exact p-value |
| Common software | Standard output in regression summaries | Standard output in ARIMA/time-series diagnostics |
17.3 Durbin-Watson Test vs Runs Test
| Aspect | Durbin-Watson Test | Runs Test |
|---|---|---|
| What it measures | Magnitude of consecutive residual differences | Number of sign changes (runs) in the residual sequence |
| Sensitivity | Sensitive to the size of autocorrelation, not just its sign pattern | Only uses the sign pattern-ignores magnitude entirely |
| Distributional assumptions | Approximate, based on published bounds | Distribution-free (non-parametric) |
Common Misconceptions
- "A Durbin-Watson value of exactly 2 is required to pass." Not true-values reasonably close to 2 (commonly cited as roughly 1.5 to 2.5) are generally fine; formal critical values, not an exact target of 2, determine statistical significance.
- "The Durbin-Watson Test works on any regression." It specifically requires ordered data and breaks down when a lagged dependent variable is used as a predictor-see Limitations.
- "Detecting autocorrelation means the regression coefficients are biased." Generally not true for ordinary least squares-coefficients typically remain unbiased under autocorrelation; it is the standard errors that become unreliable, as discussed in How to Interpret Results.
- "An inconclusive result means there is no autocorrelation." Inconclusive means exactly that-inconclusive. It is not evidence for \( H_0 \); the honest next step is a definitive test like Breusch-Godfrey.
- "High Durbin-Watson values near 4 mean the model is even better than d = 2." No-values near 4 indicate strong negative autocorrelation, which is just as problematic for inference as values near 0, as shown in Worked Example 2.
Interview Questions
- Derive the Durbin-Watson statistic and explain why it always falls between 0 and 4.
- Show algebraically why \( d \approx 2(1 - \hat{\rho}) \), where \( \hat{\rho} \) is the first-order sample autocorrelation of the residuals.
- Why does the Durbin-Watson Test have a formally inconclusive zone, unlike most test statistics?
- Why is the classical Durbin-Watson Test invalid when a lagged dependent variable is included as a predictor, and what would you use instead?
- Does autocorrelation in the residuals bias the OLS coefficient estimates, the standard errors, or both? Explain why.
- How would you distinguish, using only the Durbin-Watson statistic, between positive and negative autocorrelation?
- Explain how the Breusch-Godfrey Test generalizes the Durbin-Watson Test to higher-order autocorrelation using a Lagrange Multiplier framework.
- If a Durbin-Watson statistic lands in the inconclusive zone, what practical steps would you take next?
- What is the difference between fixing autocorrelation via HAC (Newey-West) standard errors versus switching to Generalized Least Squares?
- Why might residual autocorrelation be a symptom of an omitted variable rather than a genuine error-structure problem?
Frequently Asked Questions
- The Durbin-Watson Test checks whether the residuals from a fitted regression model are serially correlated-meaning a residual tends to be systematically related to the residual immediately before it. It is most commonly applied to time series regressions or any regression where the observations have a natural order, such as monthly sales, sensor readings, or stock returns.
- The statistic is d = [sum from t=2 to n of (e_t - e_{t-1})^2] divided by [sum from t=1 to n of e_t^2], where e_t denotes the residual at time t from the fitted regression, kept in their natural time order. The statistic always falls between 0 and 4.
- A value close to 2 indicates little or no autocorrelation. Values well below 2, approaching 0, indicate positive autocorrelation-consecutive residuals tend to share the same sign and move together. Values well above 2, approaching 4, indicate negative autocorrelation-consecutive residuals tend to alternate sign.
- Because the exact sampling distribution of the Durbin-Watson statistic depends on the specific regressors used in the model, Durbin and Watson could only publish lower (d_L) and upper (d_U) critical bounds rather than exact critical values. When the observed statistic falls between these bounds, the classical test cannot draw a definitive conclusion, and analysts typically turn to an exact alternative such as the Breusch-Godfrey Test.
- The Durbin-Watson Test is limited to detecting first-order autocorrelation only, assumes strictly exogenous regressors (no lagged dependent variable), and has a formally inconclusive zone. The Breusch-Godfrey Test, built on the Lagrange Multiplier framework, can test for autocorrelation at any chosen lag order, remains valid with lagged dependent variables among the regressors, and always yields a definite chi-square-based p-value.
- First check for an omitted variable or missing trend/seasonal term, since autocorrelated residuals often signal misspecification rather than a true error-structure problem. If the autocorrelation is genuine, consider Generalized Least Squares, an ARIMA-type error structure, or simply switch to heteroskedasticity-and-autocorrelation-consistent (HAC) standard errors such as Newey-West, which correct inference without changing the coefficient estimates themselves.
- A Durbin-Watson statistic close to 2.0 is the benchmark for no autocorrelation, since under the null hypothesis of zero first-order autocorrelation, the expected value of the statistic is approximately 2. As a common rule of thumb, values roughly between 1.5 and 2.5 are often treated as showing no strong autocorrelation, though formal critical values should be consulted for a rigorous conclusion.
Key Takeaways
- The Durbin-Watson Test checks whether regression residuals exhibit first-order autocorrelation-a residual being systematically related to the one right before it-most relevant for time-ordered data.
- The statistic \( d = \sum(e_t - e_{t-1})^2 / \sum e_t^2 \) ranges from 0 to 4, with 2 meaning no autocorrelation, values near 0 meaning positive autocorrelation, and values near 4 meaning negative autocorrelation.
- Because exact critical values depend on the regressor matrix, the classical test uses published lower and upper bounds (\( d_L \), \( d_U \)) and has a formally inconclusive zone between them.
- Autocorrelation generally leaves OLS coefficients unbiased but makes the standard errors unreliable, which is why detecting it matters before trusting significance tests.
- In Python,
statsmodelsreports the Durbin-Watson statistic automatically in everyOLSsummary, andacorr_breusch_godfreyprovides a definitive follow-up p-value when needed. - If autocorrelation is detected, first check for an omitted trend or predictor; if it's genuine, switch to HAC standard errors, Generalized Least Squares, or an explicit time-series model, as outlined in What to Do If Autocorrelation Is Detected.
- If a lagged dependent variable is among your predictors, or you need to test beyond lag 1, use the Breusch-Godfrey Test instead-it has no inconclusive zone and remains valid in both cases.
The Durbin-Watson Test remains one of the most widely reported regression diagnostics precisely because ordered data-time series above all-is everywhere, and the consequences of ignoring autocorrelated residuals are easy to overlook: coefficients that still look reasonable, standard errors that quietly understate the true uncertainty, and significance tests that overstate how confident you should really be. By comparing how much consecutive residuals change against their overall spread, the test offers a fast, well-established first check before trusting a regression's inference.
The two worked examples above show both directions this can go-strong positive autocorrelation, where residuals drift smoothly from positive to negative, and strong negative autocorrelation, where residuals alternate sign almost every observation. Reporting the Durbin-Watson statistic alongside a residual plot, and following up with the Breusch-Godfrey Test whenever the classical bounds land in the inconclusive zone or a lagged dependent variable is present, gives a complete and reliable picture that the statistic alone cannot always provide.