Is it mandatory to use statsmodel add_constant() method while implementing linear regression model? Can't be directly put the coef_ nd intercept_ value directly in the equation y=mx+b ? Also what is the use of OLS( ). Please clarify it.
2 answers ( 0 marked as helpful)
Hi Nishant, This is a very good question. First, we always need to add the constant. The reason for this is that it takes care of the bias in the data (a constant difference which is there for all observations). Your idea involves adding a column of ones to the X, so that you can avoid 'add_constant()' right? Well, this is precisely the same as using the method. The two are equivalent and almost equally hard to implement. It is your choice in the end. Best, The 365 Team