title: StatsModels formula Polynomial Regression does not match numpy polyfit coefficients
body: <p>My polynomial regression using statsmodels formula does not match nupy polyfit coefficients.</p>
  
  <p>Link to data <a href="https://drive.google.com/file/d/1fQuCoCF_TeXzZuUFyKaHCbD1zle2f1MF/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1fQuCoCF_TeXzZuUFyKaHCbD1zle2f1MF/view?usp=sharing</a></p>
  
  <p>Below is my code </p>
  
  <pre><code>import numpy as np
  import pandas as pd
  import scipy
  import statsmodels.formula.api as smf
  
  data = pd.read_csv('sp500.csv')
  
  data['Date_Ordinal'] = pd.to_datetime(data['Date']).apply(lambda date: date.toordinal())
  
  x = data['Date_Ordinal']
  y = data['Value']
  
  np.polyfit(x,y,2)
  
  model = smf.ols(formula='y ~ x + I(x**2)', data = data).fit()
  model.summary()
  </code></pre>
  
  <p><strong>Numpy polyfit coefficient results:</strong> </p>
  
  <p>array([ 4.17939013e-05, -6.09338454e+01,  2.22098809e+07])</p>
  
  <p><strong>Statsmodels coefficient results:</strong></p>
  
  <p>x**2: 7.468e-07</p>
  
  <p>x: -0.5466</p>
  
  <p>Intercept: -1.486e-06   </p>
  
  <p>When I add a quadratic trend line to the data in Excel, Excel results coincide with the numpy coefficients. However, if I add an intercept of 1 to the Excel trend line, the coefficients for x**2 and x equal the statsmodels coefficients but the excel intercept becomes 1 where as the statsmodels intercept is -1.486e-06.</p>
  
  <p>If remove the intercept from the statsmodels formula by subtracting 1,all it does is remove the intercept altogether from statsmodels results but the coefficients remain the same.</p>
  
  <p>How can I get statsmodels to show the same coefficient results as numpy polyfit and Excel? </p>