Durbin-Watson test with linear regression model object
Test Residuals for Autocorrelation
Determine whether a fitted linear regression model has autocorrelated residuals.
census data set and create a linear regression model.
load census mdl = fitlm(cdate,pop);
Find the p-value of the Durbin-Watson autocorrelation test.
p = dwtest(mdl)
p = 3.6190e-15
The small p-value indicates that the residuals are autocorrelated.
method — Algorithm for computing p-value
tail — Type of alternative hypothesis
'both' (default) |
Type of alternative hypothesis to test, specified as one of these values:
Serial correlation is not 0.
Serial correlation is greater than 0 (right-tailed test).
Serial correlation is less than 0 (left-tailed test).
dwtest tests whether
mdl has no serial correlation, against the specified alternative hypothesis.
p — p-value of test
p-value of the test, returned as a numeric value.
dwtest tests whether the residuals are uncorrelated, against the alternative that autocorrelation exists among the residuals. A small p-value indicates that the residuals are autocorrelated.
DW — Durbin-Watson statistic
nonnegative numeric value
Durbin-Watson statistic value, returned as a nonnegative numeric value.
The Durbin-Watson test tests the null hypothesis that linear regression residuals of time series data are uncorrelated, against the alternative hypothesis that autocorrelation exists.
The test statistic for the Durbin-Watson test is
where ri is the ith raw residual, and n is the number of observations.
The p-value of the Durbin-Watson test is the probability of observing a test statistic as extreme as, or more extreme than, the observed value under the null hypothesis. A significantly small p-value casts doubt on the validity of the null hypothesis and indicates autocorrelation among residuals.
 Durbin, J., and G. S. Watson. "Testing for Serial Correlation in Least Squares Regression I." Biometrika 37, pp. 409–428, 1950.
 Farebrother, R. W. Pan's "Procedure for the Tail Probabilities of the Durbin-Watson Statistic." Applied Statistics 29, pp. 224–227, 1980.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
Usage notes and limitations:
This function supports model objects fitted with GPU array input arguments.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).