Test for Autocorrelation Among Residuals
This example shows how to test for autocorrelation among the residuals of a linear regression model.
Load the sample data and fit a linear regression model.
load hald mdl = fitlm(ingredients,heat);
Perform a two-sided Durbin-Watson test to determine if there is any autocorrelation among the residuals of the linear model, mdl.
[p,DW] = dwtest(mdl,'exact','both')
p = 0.8421 DW = 2.0526
The value of the Durbin-Watson test statistic is 2.0526. The -value of 0.8421 suggests that the residuals are not autocorrelated.