Python: OLS Regression does not generate intercept
<p>Can someone please tell me where I'm missing as the summary output does not provide constant at all though I have explicitly called it out? My df is 6212 rows Ã 64 columns. Thanks much.</p>

<pre><code>import statsmodels.api as sm   
from statsmodels.api import add_constant

y1 = df.ix[:,-1:]

x1 = df.ix[:,16:-1]
x1 = add_constant(x1)

model1  = sm.OLS(y1 , x1 ).fit()
model1.summary()
</code></pre>

<p>Check your data to see if it already has a column with variance zero. <code>add_constant()</code> will not, by default, add a constant column to your dataset if it already has a zero-variance column; you should explicitly tell it to add the constant even if a zero-variance column exists:</p>

<pre><code>x1 = add_constant(x1, has_constant = 'add')
</code></pre>

<p>You can read more about different options for the <code>has_constant</code> argument here: <a href="http://statsmodels.sourceforge.net/stable/generated/statsmodels.tsa.tsatools.add_constant.html" rel="nofollow">http://statsmodels.sourceforge.net/stable/generated/statsmodels.tsa.tsatools.add_constant.html</a></p>

python regression