title: Ordinary Least Squares in statsmodels: Our model needs an intercept
body: <p>I'm starting to learn about linear regression and got stumped right at the beginning. I think my problem is not conceptually but about the implementation. I don't understand why, as per the <a href="https://www.statsmodels.org/dev/examples/notebooks/generated/ols.html" rel="nofollow noreferrer">documentation</a>, I need to include an extra column with the intercept of value 1 when trying to fit a regression line.</p>
  
  <pre><code>#Artificial data:
  nsample = 100
  x = np.linspace(0, 10, 100)
  X = np.column_stack((x, x**2))
  beta = np.array([1, 0.1, 10])
  e = np.random.normal(size=nsample)
  
  #Our model needs an intercept so we add a column of 1s:
  X = sm.add_constant(X)
  y = np.dot(X, beta) + e
  
  #Fit and summary:
  model = sm.OLS(y, X)
  results = model.fit()
  print(results.summary())
  </code></pre>
  
  <p>Isn't the intercept determined by the data? Why do I need to specify what it is? Or is this more like an parameter, where no intercept or intercept=0 means the regression line is forced through the origin and otherwise it is calculated? Why would I specify an intercept other than 0 or 1, like 100000?</p>