`P = dwtest(mdl)`

[P,DW] =
dwtest(mdl)

[P,DW] =
dwtest(mdl,method)

[P,DW] =
dwtest(mdl,method,tail)

returns
the `P`

= dwtest(`mdl`

)*p*-value of the Durbin-Watson test on the `mdl`

linear
model.

`[`

also returns the Durbin-Watson
statistic, `P`

,`DW`

] =
dwtest(`mdl`

)`DW`

.

`[`

specifies
the method `P`

,`DW`

] =
dwtest(`mdl`

,`method`

)`dwtest`

uses to compute the *p*-value.

`[`

specifies
the alternative hypothesis.`P`

,`DW`

] =
dwtest(`mdl`

,`method`

,`tail`

)

Let *r* be the vector of residuals (in `mdl.residuals.response`

).
The Durbin-Watson statistic is

$$DW=\frac{{\displaystyle \sum _{i=1}^{n-1}{\left({r}_{i+1}-{r}_{i}\right)}^{2}}}{{\displaystyle \sum _{i=1}^{n}{r}_{i}^{2}}}.$$

Approximate calculation of the *p*-value uses
a normal approximation [1]. Exact calculation uses Pan's algorithm [2].

[1] Durbin, J., and G. S. Watson. *Testing
for Serial Correlation in Least Squares Regression I.* Biometrika
37, pp. 409–428, 1950.

[2] Farebrother, R. W. *Pan's Procedure
for the Tail Probabilities of the Durbin-Watson Statistic.* Applied
Statistics 29, pp. 224–227, 1980.

Was this topic helpful?