pastas.stats.tests.durbin_watson#

durbin_watson(series=None)[source]#

Durbin-Watson test for autocorrelation.

Parameters

series (pandas.Series, optional) – residuals series

Returns

dw_stat – The method returns the Durbin-Watson test statistic.

Return type

float

Notes

The Durban Watson statistic ([durbin_1951], [Fahidy_2004]) tests the null-hypothesis that the correlation between the noise values at lag one equals zero. The formula to calculate the Durbin-Watson statistic (DW) is:

\[DW = \frac{\sum_{t=2}^{n}(\upsilon_t-\upsilon_{t-1}^2)} {\sum_{t=1}^{n}\upsilon_t^2}\]

where $n$ is the number of values in the noise series. The test-statistic has a range \(0 \geq DW \leq 4\), where values of $DW < 2$ indicate a positive correlation and values of $DW > 2$ indicates negative autocorrelation. The Durbin-Watson test requires a constant time interval of the noise series and tests for autocorrelation at a lag of 1 time step.

Considerations for this test:

  • The time series should have equidistant time steps.

  • The Durbin-Watson test tests for autocorrelation at lag 1 but not for larger time lags.

  • The test statistic for this test is difficult to compute and is usually obtained from pre-calculated tables.

References

durbin_1951

Durbin, J., & Watson, G. S. (1951). Testing for serial correlation in least squares regression. II. Biometrika, 38(1/2), 159-177.

Fahidy_2004

Fahidy, T. Z. (2004). On the Application of Durbin-Watson Statistics to Time-Series-Based Regression Models. CHEMICAL ENGINEERING EDUCATION, 38(1), 22-25.

Examples

>>> data = pd.Series(index=pd.date_range(start=0, periods=1000, freq="D"),
>>>                data=np.random.rand(1000))
>>> result = ps.stats.durbin_watson(data)