pastas.stats.tests.durbin_watson ================================ .. py:function:: pastas.stats.tests.durbin_watson(series: pandas.Series) -> float Durbin-Watson test for autocorrelation. :param series: residuals series. :type series: pandas.Series, optional :returns: **dw_stat** -- The method returns the Durbin-Watson test statistic. :rtype: float .. rubric:: Notes The Durban Watson statistic ([R0fd492ec46e4-durbin_1951]_, [R0fd492ec46e4-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: .. math:: 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 :math:`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. .. rubric:: References .. [R0fd492ec46e4-durbin_1951] Durbin, J., & Watson, G. S. (1951). Testing for serial correlation in least squares regression. II. Biometrika, 38(1/2), 159-177. .. [R0fd492ec46e4-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. .. rubric:: 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) .. !! processed by numpydoc !!