Last answered:

14 Nov 2023

Posted on:

03 May 2020

0

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)
Instructor
Posted on:

07 May 2020

0
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
Posted on:

14 Nov 2023

0

Agree with previous answer 

Submit an answer