为什么statsmodels对于make_regression的sklearn中的这么多变量给出p〜0?

时间:2019-09-20 18:47:03

标签: python python-3.x scikit-learn statsmodels

我在玩scikit elarn和statsmodels,我从make_regression函数生成了数组,以适合statsmodels

from sklearn.datasets import make_regression
x,y,coef = make_regression(n_samples=10000,n_informative=10,coef=True)

所以我有10个变量在回归中似乎很重要。

但是,当我从statsmodels运行api来检查哪个是“真正的生成器”时:

import statsmodels.api as sm
x = sm.add_constant(x, prepend=False)
mod = sm.OLS(y,x)
res = mod.fit()
res.summary()

它给了我:

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                      y   R-squared:                       1.000
Model:                            OLS   Adj. R-squared:                  1.000
Method:                 Least Squares   F-statistic:                 2.336e+31
Date:                Fri, 20 Sep 2019   Prob (F-statistic):               0.00
Time:                        15:38:01   Log-Likelihood:             2.7280e+05
No. Observations:               10000   AIC:                        -5.454e+05
Df Residuals:                    9899   BIC:                        -5.447e+05
Df Model:                         100                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
x1            24.0004    3.5e-15   6.85e+15      0.000      24.000      24.000
x2           1.11e-14   3.49e-15      3.183      0.001    4.27e-15    1.79e-14
x3          2.953e-14   3.46e-15      8.546      0.000    2.28e-14    3.63e-14
x4            40.4471   3.46e-15   1.17e+16      0.000      40.447      40.447
x5         -2.665e-14   3.49e-15     -7.629      0.000   -3.35e-14   -1.98e-14
x6         -1.887e-15   3.43e-15     -0.550      0.583   -8.62e-15    4.84e-15
x7          2.578e-14   3.45e-15      7.474      0.000     1.9e-14    3.25e-14
x8         -2.265e-14   3.45e-15     -6.568      0.000   -2.94e-14   -1.59e-14
x9          5.662e-15   3.49e-15      1.621      0.105   -1.19e-15    1.25e-14
x10        -7.772e-14   3.45e-15    -22.497      0.000   -8.45e-14   -7.09e-14
x11         2.143e-14   3.51e-15      6.109      0.000    1.46e-14    2.83e-14
x12         5.318e-14   3.48e-15     15.269      0.000    4.64e-14       6e-14
x13        -3.952e-14   3.49e-15    -11.340      0.000   -4.64e-14   -3.27e-14
x14         3.642e-14   3.45e-15     10.556      0.000    2.97e-14    4.32e-14
x15        -6.661e-16   3.51e-15     -0.190      0.849   -7.54e-15    6.21e-15
x16        -2.637e-14   3.49e-15     -7.556      0.000   -3.32e-14   -1.95e-14
x17         5.135e-14    3.5e-15     14.672      0.000    4.45e-14    5.82e-14
x18         4.718e-15   3.45e-15      1.369      0.171   -2.04e-15    1.15e-14
x19         3.186e-14    3.5e-15      9.112      0.000     2.5e-14    3.87e-14
x20        -1.488e-14   3.44e-15     -4.319      0.000   -2.16e-14   -8.13e-15
x21        -2.998e-14   3.41e-15     -8.790      0.000   -3.67e-14   -2.33e-14
x22        -5.118e-14   3.52e-15    -14.560      0.000   -5.81e-14   -4.43e-14
x23        -2.354e-14    3.5e-15     -6.717      0.000   -3.04e-14   -1.67e-14
x24         -8.16e-15   3.44e-15     -2.375      0.018   -1.49e-14   -1.42e-15
x25         1.443e-15   3.45e-15      0.418      0.676   -5.33e-15    8.21e-15
x26        -2.331e-15   3.51e-15     -0.664      0.507   -9.22e-15    4.55e-15
x27        -7.383e-15   3.44e-15     -2.144      0.032   -1.41e-14   -6.34e-16
x28        -3.175e-14   3.48e-15     -9.128      0.000   -3.86e-14   -2.49e-14
x29         1.887e-15   3.52e-15      0.537      0.591      -5e-15    8.78e-15
x30        -8.993e-15    3.5e-15     -2.571      0.010   -1.58e-14   -2.14e-15
x31        -1.432e-14   3.46e-15     -4.138      0.000   -2.11e-14   -7.54e-15
x32        -5.307e-14   3.47e-15    -15.309      0.000   -5.99e-14   -4.63e-14
x33        -4.036e-14   3.49e-15    -11.550      0.000   -4.72e-14   -3.35e-14
x34        -2.297e-14   3.46e-15     -6.631      0.000   -2.98e-14   -1.62e-14
x35         1.776e-15   3.48e-15      0.510      0.610   -5.05e-15     8.6e-15
x36         2.184e-14   3.48e-15      6.278      0.000     1.5e-14    2.87e-14
x37           61.7653   3.46e-15   1.79e+16      0.000      61.765      61.765
x38        -1.332e-15   3.48e-15     -0.383      0.702   -8.16e-15    5.49e-15
x39        -1.577e-14   3.52e-15     -4.478      0.000   -2.27e-14   -8.86e-15
x40         1.849e-14   3.48e-15      5.317      0.000    1.17e-14    2.53e-14
x41        -1.965e-14   3.46e-15     -5.685      0.000   -2.64e-14   -1.29e-14
x42        -2.265e-14   3.42e-15     -6.614      0.000   -2.94e-14   -1.59e-14
x43         -4.73e-14   3.48e-15    -13.594      0.000   -5.41e-14   -4.05e-14
x44        -2.176e-14   3.44e-15     -6.324      0.000   -2.85e-14    -1.5e-14
x45        -5.568e-14   3.49e-15    -15.959      0.000   -6.25e-14   -4.88e-14
x46         6.883e-15    3.5e-15      1.967      0.049    2.29e-17    1.37e-14
x47         2.454e-14    3.5e-15      7.005      0.000    1.77e-14    3.14e-14
x48          3.12e-14   3.46e-15      9.016      0.000    2.44e-14     3.8e-14
x49        -1.515e-14   3.42e-15     -4.432      0.000   -2.19e-14   -8.45e-15
x50         3.553e-15   3.48e-15      1.021      0.307   -3.27e-15    1.04e-14
x51         7.484e-14   3.48e-15     21.533      0.000     6.8e-14    8.17e-14
x52        -2.276e-15   3.43e-15     -0.663      0.507      -9e-15    4.45e-15
x53        -3.908e-14   3.44e-15    -11.377      0.000   -4.58e-14   -3.23e-14
x54        -5.329e-15   3.48e-15     -1.531      0.126   -1.22e-14    1.49e-15
x55        -2.176e-14   3.43e-15     -6.352      0.000   -2.85e-14    -1.5e-14
x56        -5.917e-14   3.41e-15    -17.334      0.000   -6.59e-14   -5.25e-14
x57          5.54e-14   3.51e-15     15.769      0.000    4.85e-14    6.23e-14
x58         1.532e-14   3.48e-15      4.406      0.000     8.5e-15    2.21e-14
x59        -3.064e-14   3.48e-15     -8.805      0.000   -3.75e-14   -2.38e-14
x60           12.2240   3.45e-15   3.54e+15      0.000      12.224      12.224
x61        -2.964e-14   3.49e-15     -8.504      0.000   -3.65e-14   -2.28e-14
x62        -6.384e-16   3.48e-15     -0.184      0.854   -7.45e-15    6.18e-15
x63           75.2689    3.5e-15   2.15e+16      0.000      75.269      75.269
x64        -3.264e-14   3.46e-15     -9.445      0.000   -3.94e-14   -2.59e-14
x65         5.085e-14   3.49e-15     14.574      0.000     4.4e-14    5.77e-14
x66        -1.743e-14   3.48e-15     -5.010      0.000   -2.43e-14   -1.06e-14
x67         3.131e-14   3.46e-15      9.057      0.000    2.45e-14    3.81e-14
x68          3.63e-14   3.52e-15     10.308      0.000    2.94e-14    4.32e-14
x69         3.919e-14   3.52e-15     11.143      0.000    3.23e-14    4.61e-14
x70           14.7147    3.5e-15   4.21e+15      0.000      14.715      14.715
x71         7.438e-15   3.43e-15      2.168      0.030    7.14e-16    1.42e-14
x72         6.106e-16   3.48e-15      0.176      0.861    -6.2e-15    7.42e-15
x73         1.826e-14   3.48e-15      5.247      0.000    1.14e-14    2.51e-14
x74         1.565e-14   3.48e-15      4.498      0.000    8.83e-15    2.25e-14
x75         5.662e-15   3.47e-15      1.631      0.103   -1.14e-15    1.25e-14
x76         1.821e-14   3.51e-15      5.193      0.000    1.13e-14    2.51e-14
x77         2.798e-14   3.48e-15      8.036      0.000    2.12e-14    3.48e-14
x78           47.3326    3.5e-15   1.35e+16      0.000      47.333      47.333
x79        -2.376e-14   3.47e-15     -6.838      0.000   -3.06e-14   -1.69e-14
x80        -1.266e-14   3.47e-15     -3.644      0.000   -1.95e-14   -5.85e-15
x81         2.953e-14   3.49e-15      8.454      0.000    2.27e-14    3.64e-14
x82           30.8112   3.47e-15   8.88e+15      0.000      30.811      30.811
x83         6.117e-14   3.51e-15     17.453      0.000    5.43e-14     6.8e-14
x84           51.1612   3.48e-15   1.47e+16      0.000      51.161      51.161
x85        -2.603e-14   3.51e-15     -7.411      0.000   -3.29e-14   -1.91e-14
x86        -2.953e-14   3.46e-15     -8.525      0.000   -3.63e-14   -2.27e-14
x87           97.7774   3.44e-15   2.84e+16      0.000      97.777      97.777
x88         4.108e-14   3.46e-15     11.863      0.000    3.43e-14    4.79e-14
x89          5.24e-14   3.49e-15     15.009      0.000    4.56e-14    5.92e-14
x90         6.772e-15   3.49e-15      1.940      0.052   -7.08e-17    1.36e-14
x91         1.332e-14   3.48e-15      3.829      0.000     6.5e-15    2.01e-14
x92        -9.881e-15   3.49e-15     -2.828      0.005   -1.67e-14   -3.03e-15
x93        -1.166e-14   3.51e-15     -3.321      0.001   -1.85e-14   -4.78e-15
x94         3.431e-14   3.52e-15      9.754      0.000    2.74e-14    4.12e-14
x95        -2.531e-14   3.46e-15     -7.321      0.000   -3.21e-14   -1.85e-14
x96         7.105e-15   3.49e-15      2.036      0.042    2.63e-16    1.39e-14
x97         1.732e-14   3.46e-15      5.009      0.000    1.05e-14    2.41e-14
x98        -2.315e-14   3.45e-15     -6.704      0.000   -2.99e-14   -1.64e-14
x99         2.665e-14    3.5e-15      7.618      0.000    1.98e-14    3.35e-14
x100        7.235e-14   3.51e-15     20.639      0.000    6.55e-14    7.92e-14
const       6.883e-15   3.48e-15      1.980      0.048    6.83e-17    1.37e-14
==============================================================================
Omnibus:                        0.635   Durbin-Watson:                   1.959
Prob(Omnibus):                  0.728   Jarque-Bera (JB):                0.653
Skew:                           0.018   Prob(JB):                        0.721
Kurtosis:                       2.986   Cond. No.                         1.22
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

不是statsmodels的p值仅返回约10个变量的“好” p值吗?

0 个答案:

没有答案