Durbin-Watson test with residual inputs
returns the p-value for the Durbin-Watson test of the null hypothesis that the residuals from a linear regression are uncorrelated. The alternative hypothesis is that there is autocorrelation among the residuals.p = dwtest(r,x)
returns the p-value for the Durbin-Watson test with additional options specified by one or more name-value pair arguments. For example, you can conduct a one-sided test or calculate the p-value using a normal approximation.p = dwtest(r,x,Name,Value)
You can create a linear regression model object by using fitlm or stepwiselm and use the object function dwtest to perform the Durbin-Watson test.
A LinearModel object provides the object properties and the object functions to investigate a fitted linear regression model. The object properties include information about coefficient estimates, summary statistics, fitting method, and input data. Use the object functions to predict responses and to modify, evaluate, and visualize the linear regression model.
[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.