balipour

Durbin Watson Test Statistic [pig]

In statistics, the Durbin–Watson statistic is a test statistic used to detect the presence of autocorrelation at lag 1 (AR(1) process) in the residuals (prediction errors) from a regression analysis. With the new array function tradingview implemented, we are able to do our calculations on the residuals.

The residual is given by subtracting the actual value (in this case it's log returns) from the prediction value (generated by linear regression ). The following chart displays who we get the error term from the regression.
Then we do our calculation based on the residuals. The formula is basically sum of squared of the difference between error and it's 1 lagged term divided by sum of squared of all the error terms. It's a very simple test on residual sum of squares. The value you get is from 0 to 4.
When DW > 2, there's a possible negative autocorrelation.
When DW < 2, there's a possible positive autocorrelation.
Note: above 2 and below 2 is only possible autocorrelation, it might not be statistically significant.

If we want to know if the autocorrelation presence is significant or not. We need a Durbin Watson Stats Table. Based on the lookback period you use, you can find the critical value on the table (usually the first column).
Durbin Watson 0. 05 Table
For the default setting 30 lookbacks, the 5% critical level for positive autocorrelation is 1.35. (We round to 1.4 on the default setting for convenience ). The other side for negative autocorrelation is just 4 - 1.35 = 2.65 due to its symmetry. For other lookbacks like 50, the critical value is 1.5 and 2.5, we just need to check the table to find the corresponding value. The user only has to find the lower threshold, the indicator will automatically give you the 4- lower threshold value on the other side.

As we have mentioned in the autocorrelation function and Hurst exponent . Positive autocorrelation means positive returns are more likely to be followed by positive returns and negative returns are more likely to be followed by negative returns. People may call it trending. Negative autocorrelation means positive returns are more likely to be followed by negative returns and negative returns may be followed by positive returns. People may call it mean-reverting.
The Durbin Watson test only tests the first-order autocorrelation. But there might also be significant autocorrelation in other lagged values. You can see the autocorrelation of other lags in our ACF.
We may also publish more advanced autocorrelation tests in the future.
Phát hành các Ghi chú: A typo in graph one displaying the error as distance between the points and the regression line. "E5" should be "E3".
Phát hành các Ghi chú: Implemented 0.05 Significance Dubrin Watson Statistics Table in the code. No need to check the table or type in the critical value. The value will be automatically adjusted according to the lookback period.

Changed the color theme.

White means DW > 2, possible - autocorrelation / mean reversion
Orange means DW < 2, possible + autocorrelation / trending

Blue background means DW > upper critical value, Significant - autocorrelation / mean reversion
Red background means DW < lower critical value, Significant + autocorrelation / trending

Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
Our Website🅱🅰🐷: https://bapigindicator.com

Sign up on our website to get access to our indicators.

Join Our Discord for further discussions:

https://discord.gg/ink

Bình luận

500 xu
Phản hồi
This publication is now featured in our Editors' Picks. In the name of all TradingView traders, thank you for your valuable contribution to the TradingView community, and congrats!
+11 Phản hồi
balipour PineCoders
@PineCoders, I was trying to find where I was saying there should be another word for “help” that actually helps. And that’s all you guys have done for us every single time there was an opportunity. So I want to thank you for being great and providing the greatest platform to allow us to do what we do. Thank you.
+8 Phản hồi
PineCoders balipour
@balipour, Thx for the good words. Appreciate. Without exceptional creations such as yours, there would be nothing for us to select for Editors' Picks, so thanks to you guys for your work, and for sharing it open-source.
+5 Phản hồi
balipour PineCoders
@PineCoders, far too kind.
+4 Phản hồi
Sexy
+9 Phản hồi
balipour DairyMilk
@DairyMilk, one person gets it lol.
+2 Phản hồi
Đã xóa bình luận.
balipour CryptoCYCLOPS
@CryptoCYCLOPS, Happy Birthday my man. Least we could do, lol.
+1 Phản hồi
Awesomeness!

Thanks Bali/Pig!
+3 Phản hồi