Skip to content

_repr_html_ for ols fit summary does not show warning for multicollinearity #1448

Open

Description

@cancan101

Running the following:

N = 1000
e4 = numpy.random.normal(size=N)
e5 = numpy.random.normal(size=N)
e6 = numpy.random.normal(size=N)

y = e4 + e5

data4 = pd.DataFrame({'a':e4,'b':e4+e5/1000,'y':y})
fit = ols("y ~ a + b", data4).fit()

I get the following:

In [139]:

print fit.summary()
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                      y   R-squared:                       1.000
Model:                            OLS   Adj. R-squared:                  1.000
Method:                 Least Squares   F-statistic:                 2.641e+26
Date:                Thu, 06 Mar 2014   Prob (F-statistic):               0.00
Time:                        00:48:23   Log-Likelihood:                 25520.
No. Observations:                1000   AIC:                        -5.103e+04
Df Residuals:                     997   BIC:                        -5.102e+04
Df Model:                           2                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
Intercept  -1.087e-13   6.36e-14     -1.710      0.088     -2.33e-13   1.6e-14
a           -999.0000   6.18e-11  -1.62e+13      0.000      -999.000  -999.000
b           1000.0000   6.18e-11   1.62e+13      0.000      1000.000  1000.000
==============================================================================
Omnibus:                        4.445   Durbin-Watson:                   1.986
Prob(Omnibus):                  0.108   Jarque-Bera (JB):                4.519
Skew:                          -0.159   Prob(JB):                        0.104
Kurtosis:                       2.918   Cond. No.                     2.01e+03
==============================================================================

Warnings:
[1] The condition number is large, 2.01e+03. This might indicate that there are
strong multicollinearity or other numerical problems.

but this fit.summary()._repr_html_() shows no such warning:

<table class="simpletable">
<caption>OLS Regression Results</caption>
<tr>
  <th>Dep. Variable:</th>            <td>y</td>        <th>  R-squared:         </th>  <td>   1.000</td> 
</tr>
<tr>
  <th>Model:</th>                   <td>OLS</td>       <th>  Adj. R-squared:    </th>  <td>   1.000</td> 
</tr>
<tr>
  <th>Method:</th>             <td>Least Squares</td>  <th>  F-statistic:       </th>  <td>2.641e+26</td>
</tr>
<tr>
  <th>Date:</th>             <td>Thu, 06 Mar 2014</td> <th>  Prob (F-statistic):</th>   <td>  0.00</td>  
</tr>
<tr>
  <th>Time:</th>                 <td>00:49:04</td>     <th>  Log-Likelihood:    </th>  <td>  25520.</td> 
</tr>
<tr>
  <th>No. Observations:</th>      <td>  1000</td>      <th>  AIC:               </th> <td>-5.103e+04</td>
</tr>
<tr>
  <th>Df Residuals:</th>          <td>   997</td>      <th>  BIC:               </th> <td>-5.102e+04</td>
</tr>
<tr>
  <th>Df Model:</th>              <td>     2</td>      <th>                     </th>      <td> </td>    
</tr>
</table>
<table class="simpletable">
<tr>
      <td></td>         <th>coef</th>     <th>std err</th>      <th>t</th>      <th>P>|t|</th> <th>[95.0% Conf. Int.]</th> 
</tr>
<tr>
  <th>Intercept</th> <td>-1.087e-13</td> <td> 6.36e-14</td> <td>   -1.710</td> <td> 0.088</td> <td>-2.33e-13   1.6e-14</td>
</tr>
<tr>
  <th>a</th>         <td> -999.0000</td> <td> 6.18e-11</td> <td>-1.62e+13</td> <td> 0.000</td> <td> -999.000  -999.000</td>
</tr>
<tr>
  <th>b</th>         <td> 1000.0000</td> <td> 6.18e-11</td> <td> 1.62e+13</td> <td> 0.000</td> <td> 1000.000  1000.000</td>
</tr>
</table>
<table class="simpletable">
<tr>
  <th>Omnibus:</th>       <td> 4.445</td> <th>  Durbin-Watson:     </th> <td>   1.986</td>
</tr>
<tr>
  <th>Prob(Omnibus):</th> <td> 0.108</td> <th>  Jarque-Bera (JB):  </th> <td>   4.519</td>
</tr>
<tr>
  <th>Skew:</th>          <td>-0.159</td> <th>  Prob(JB):          </th> <td>   0.104</td>
</tr>
<tr>
  <th>Kurtosis:</th>      <td> 2.918</td> <th>  Cond. No.          </th> <td>2.01e+03</td>
</tr>
</table>

Activity

  1. josef-pkt commented on Mar 6, 2014

    @josef-pkt
    Member

    The trailing information in summary is just a string, not part of a SimpleTable.

    So if we want to include in in other formats, html and Latex, then we need to generate the markup for it.
    I think changes need only be in https://github.com/statsmodels/statsmodels/blob/master/statsmodels/iolib/summary.py#L777 for summary

    summary2 combines the tables in the methods, e.g. https://github.com/statsmodels/statsmodels/blob/master/statsmodels/iolib/summary2.py#L183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions