Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

Algoritmo Lab Forum

Algoritmo Lab Forum Logo Algoritmo Lab Forum Logo

Algoritmo Lab Forum Navigation

  • Forum
  • Algoritmo Lab
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Forum
  • Algoritmo Lab
Home/ Questions/Q 510
Next
In Process
NehaSequeira
NehaSequeira

NehaSequeira

  • 2 Questions
  • 0 Answers
  • 0 Best Answers
  • 0 Points
View Profile
  • 0
NehaSequeiraUser
Asked: June 16, 20212021-06-16T03:14:31+00:00 2021-06-16T03:14:31+00:00In: Linear Regression

Intercept in linear regression model

  • 0

Why do we need an intercept in a linear regression model?

If we use statsmodel.OLS do we need to add the intercept explicitly and how do we do it?

  • 2 2 Answers
  • 62 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. shreemann

      shreemann

      • 0 Questions
      • 1 Answer
      • 0 Best Answers
      • 2 Points
      View Profile
      shreemann User
      2021-06-23T04:53:26+00:00Added an answer on June 23, 2021 at 4:53 am

      If we remove the intercept then that would make the regression pass through the origin and the dependent and independent variables are equal to zero. In a regression model, it is always good practice to add intercept in your equation unless you are specifically asked to make the regression line pass through the origin.

      In statsmodel.OLS, the intercept has to be added by the user and is not added by default. You can add it using:

      X = sm.add_constant(X)

      OR

      sm.OLS(y, statsmodels.tools.add_constant(X))
       
      
      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. Suchita

      Suchita

      • 0 Questions
      • 5 Answers
      • 1 Best Answer
      • 17 Points
      View Profile
      Suchita SME
      2021-06-16T05:41:42+00:00Added an answer on June 16, 2021 at 5:41 am

      Intercept is the value of y, when all Xs are 0. So the y-intercept is the predicted value of y when all X1, X2, X3,….Xn are zero. In 2-dimensional space, y-intercept is where the  regression line cuts the y-axis (value of x=0 at this point).

      Y-intercept is interpreted as the value of the target y-variable when all the predictors are 0.

      For example, if we try to fit a regression line to predict the marks obtained in the test based on no. of hours of studies:

      y = 20+.6x, where y is the marks and x is the number of hours of study.

      20 is the y-intercept and it means a student will obtain 20 marks, even if he does not study.

      However, when this value zero is outside the range of the values of the predictor, used to build the model,  the y-intercept will not make much sense in the context of the problem.

      Statsmodel , by default fits a line passing through the origin, i.e., there is no y-intercept included by default.

      To include y-intercept we use the function add_constant().

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Ask A Question
    • Popular
    • Answers
    • Tags
    • Aditya Sharma

      Are there any coding standards in Python?

      • 2 Answers
    • Bikash Ghosh

      Model Overfitting or Underfitting

      • 2 Answers
    • NehaSequeira

      Intercept in linear regression model

      • 2 Answers
    • NehaSequeira

      Scaling for numeric variables

      • 2 Answers
    • mahima_vaidya

      Multiple Linear Regression

      • 2 Answers
    • Dipayan Sarkar
      Dipayan Sarkar added an answer One of the assumptions of Linear Regression - No multicollinearity.… July 14, 2021 at 4:46 am
    • mahima_vaidya
      mahima_vaidya added an answer 'OLS' object has no attribute 'pvalues' This is the error… July 6, 2021 at 7:24 am
    • Dipayan Sarkar
      Dipayan Sarkar added an answer The statsmodels.regression.linear_model.OLSResults.pvalues should give you the pvalues of the respective… July 5, 2021 at 6:10 pm
    • shreemann
      shreemann added an answer If we remove the intercept then that would make the… June 23, 2021 at 4:53 am
    • Suchita
      Suchita added an answer When we scale the date prior to train-test split,  we… June 18, 2021 at 11:35 am
    codingstandards linear regression logistic regression p-value python pythoncoding question

    Top Members

    Dipayan Sarkar

    Dipayan Sarkar

    • 0 Questions
    • 39 Points
    SME
    Shivam17

    Shivam17

    • 0 Questions
    • 29 Points
    SME
    Prasad Valse

    Prasad Valse

    • 0 Questions
    • 28 Points
    SME

    Explore

    • Recent Questions
    • Feed
    • Most Answered
    • Answers
    • No Answers
    • Most Visited
    • Most Voted

    © 2021 Algoritmo Lab. All Rights Reserved