Линейная регрессия


In [1]:
import statsmodels
import scipy as sc
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
import statsmodels.stats.api as sms
from statsmodels.graphics.regressionplots import plot_leverage_resid2
import matplotlib.pyplot as plt

In [2]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [3]:
def func(x):
    if x['nevermarr'] == 1:
        if pd.notnull(x['heduc']):
            return x
        else:
            x['heduc'] = -1
            return x
    else:
        return x
#foo['z'] = foo.apply(func(row), axis = 1)
#foo

Посмотрим на распределение целевого признака — уровня заработной платы:


In [4]:
raw = pd.read_csv('botswana.tsv', sep = '\t', header = 0, parse_dates = [2])
raw.head()
raw['heduc'].isnull().sum()
print raw.shape
data = raw
data['nevermarr'] = data['agefm'].apply(lambda x : 0 if pd.notnull(x) else 1)
data.drop('evermarr', axis=1, inplace=True)
print data['agefm'].isnull().sum()
data['agefm'] = data['agefm'].apply(lambda x : x if pd.notnull(x) else 0)
print data['agefm'].isnull().sum()
#data['heduc'].where(data['nevermarr']  == 1).apply(lambda x : x if pd.notnull(x) else -1 )
data = data.apply(lambda x : func(x), axis = 1)

data['idlnchld_noans'] = data['idlnchld'].apply(lambda x : 0 if pd.notnull(x) else 1)
data['heduc_noans'] = data['heduc'].apply(lambda x : 0 if pd.notnull(x) else 1)
data['usemeth_noans'] = data['usemeth'].apply(lambda x : 0 if pd.notnull(x) else 1)

data['idlnchld'] = data['idlnchld'].apply(lambda x : x if pd.notnull(x) else -1)
data['heduc'] = data['heduc'].apply(lambda x : x if pd.notnull(x) else -2)
data['usemeth'] = data['usemeth'].apply(lambda x : x if pd.notnull(x) else -1)

data = data.dropna(axis=0)
print data.shape[0] * data.shape[1]


(4361, 15)
2282
0
78264

In [5]:
string = ""
string = " + ".join(data.columns.values)
print string


ceb + age + educ + religion + idlnchld + knowmeth + usemeth + agefm + heduc + urban + electric + radio + tv + bicycle + nevermarr + idlnchld_noans + heduc_noans + usemeth_noans

In [6]:
print data.head(100)
data['heduc'][:10]
print data['heduc'].isnull().sum()


    ceb  age educ    religion  idlnchld  knowmeth  usemeth  agefm  heduc  \
0     0   18   10    catholic       4.0       1.0      1.0    0.0   -1.0   
1     2   43   11  protestant       2.0       1.0      1.0   20.0   14.0   
2     0   49    4      spirit       4.0       1.0      0.0   22.0    1.0   
3     0   24   12       other       2.0       1.0      0.0    0.0   -1.0   
4     3   32   13       other       3.0       1.0      1.0   24.0   12.0   
5     1   30    5      spirit       5.0       1.0      0.0   24.0    7.0   
6     3   42    4       other       3.0       1.0      0.0   15.0   11.0   
7     1   36    7       other       4.0       1.0      1.0   24.0    9.0   
8     4   37   16    catholic       4.0       1.0      1.0   26.0   17.0   
9     1   34    5  protestant       4.0       1.0      1.0   18.0    3.0   
10    3   42   15       other       3.0       1.0      1.0   24.0   16.0   
11    3   29    7      spirit       6.0       1.0      1.0   24.0    7.0   
12    4   45    0      spirit       6.0       1.0      0.0   23.0   -2.0   
13   10   48    4  protestant       4.0       1.0      1.0   26.0    3.0   
14    3   35   12  protestant       3.0       1.0      1.0   21.0   16.0   
15    0   26    7    catholic       4.0       1.0      1.0    0.0   -1.0   
16    4   38    7  protestant       5.0       1.0      1.0    0.0   -1.0   
17    2   47    5      spirit       1.0       1.0      0.0    0.0   -1.0   
18    0   32   16  protestant       2.0       1.0      1.0   25.0   16.0   
19    1   27   12      spirit       3.0       1.0      1.0   23.0   16.0   
20    0   23   12  protestant       2.0       1.0      1.0   18.0   12.0   
21    4   39   11  protestant       4.0       1.0      0.0   23.0   16.0   
22    2   38   12       other       4.0       1.0      0.0   25.0   14.0   
23    4   39    6      spirit       4.0       1.0      0.0   18.0   10.0   
24    1   21   10      spirit       1.0       1.0      0.0    0.0   -1.0   
25    2   43   16  protestant       4.0       1.0      1.0   22.0   15.0   
26    6   41   13  protestant       6.0       1.0      1.0   18.0   15.0   
27    3   46    3  protestant       4.0       1.0      0.0    0.0   -1.0   
28    1   25   10  protestant      -1.0       1.0      1.0    0.0   -1.0   
29    4   46    0       other       4.0       1.0      1.0    0.0   -1.0   
..  ...  ...  ...         ...       ...       ...      ...    ...    ...   
70    1   24   16  protestant       3.0       1.0      1.0    0.0   -1.0   
71    1   36    2  protestant       4.0       1.0      0.0   35.0    0.0   
72    3   41   19  protestant       3.0       1.0      1.0   27.0   16.0   
73    2   49    6  protestant       2.0       0.0      0.0   22.0    4.0   
74    2   41    0    catholic       2.0       1.0      0.0    0.0   -1.0   
75    2   47   15       other       2.0       1.0      1.0   21.0   15.0   
76    2   40   13    catholic       2.0       1.0      1.0   20.0   12.0   
77    4   39   15  protestant       4.0       1.0      1.0   22.0   13.0   
78    2   22    0      spirit       5.0       1.0      0.0   20.0    6.0   
79    0   17    7       other       4.0       1.0      1.0    0.0   -1.0   
80    2   30   16      spirit       2.0       1.0      1.0   24.0   15.0   
81    2   36   14  protestant       4.0       1.0      1.0   22.0   10.0   
82    4   27   10       other       4.0       1.0      1.0   19.0   10.0   
83    4   36    7  protestant       6.0       1.0      1.0    0.0   -1.0   
84    0   17    8  protestant       2.0       1.0      0.0    0.0   -1.0   
85    1   29    6  protestant       2.0       1.0      1.0   15.0   15.0   
86    2   36    2       other       3.0       1.0      1.0    0.0   -1.0   
87    5   46   10  protestant       4.0       1.0      1.0   24.0   10.0   
88    3   30    5  protestant       3.0       1.0      1.0    0.0   -1.0   
89    3   39   12       other       4.0       1.0      1.0   19.0   12.0   
90    2   33   17       other       2.0       1.0      1.0   23.0   17.0   
91    1   18   10  protestant       4.0       1.0      1.0    0.0   -1.0   
92    2   28   11    catholic       4.0       1.0      1.0   22.0   12.0   
93    1   24    7      spirit       4.0       1.0      1.0    0.0   -1.0   
94    3   25   10  protestant       3.0       1.0      1.0   24.0   16.0   
95    0   21    7  protestant       4.0       1.0      1.0    0.0   -1.0   
96    0   16    7      spirit       4.0       1.0      1.0    0.0   -1.0   
97    2   23    7       other       4.0       1.0      1.0    0.0   -1.0   
98    2   25   10       other       3.0       1.0      1.0    0.0   -1.0   
99    6   39   12       other       4.0       1.0      1.0   16.0   12.0   

    urban  electric  radio   tv  bicycle  nevermarr  idlnchld_noans  \
0       1       1.0    1.0  1.0      1.0          1               0   
1       1       1.0    1.0  1.0      1.0          0               0   
2       1       1.0    1.0  0.0      0.0          0               0   
3       1       1.0    1.0  1.0      1.0          1               0   
4       1       1.0    1.0  1.0      1.0          0               0   
5       1       1.0    0.0  0.0      0.0          0               0   
6       1       1.0    0.0  1.0      0.0          0               0   
7       1       1.0    0.0  0.0      0.0          0               0   
8       1       1.0    1.0  1.0      1.0          0               0   
9       1       0.0    1.0  0.0      0.0          0               0   
10      1       1.0    1.0  1.0      1.0          0               0   
11      1       1.0    1.0  0.0      0.0          0               0   
12      1       1.0    1.0  0.0      0.0          0               0   
13      1       1.0    1.0  0.0      0.0          0               0   
14      1       1.0    1.0  1.0      1.0          0               0   
15      1       1.0    1.0  0.0      0.0          1               0   
16      1       1.0    1.0  0.0      1.0          1               0   
17      1       1.0    1.0  0.0      0.0          1               0   
18      1       1.0    1.0  1.0      0.0          0               0   
19      1       1.0    1.0  1.0      0.0          0               0   
20      1       1.0    1.0  1.0      0.0          0               0   
21      1       1.0    1.0  1.0      1.0          0               0   
22      1       1.0    1.0  1.0      1.0          0               0   
23      1       1.0    1.0  0.0      1.0          0               0   
24      1       1.0    1.0  0.0      1.0          1               0   
25      1       1.0    1.0  1.0      1.0          0               0   
26      1       1.0    1.0  1.0      1.0          0               0   
27      1       1.0    1.0  1.0      1.0          1               0   
28      1       0.0    0.0  0.0      0.0          1               1   
29      1       1.0    1.0  0.0      0.0          1               0   
..    ...       ...    ...  ...      ...        ...             ...   
70      1       1.0    1.0  1.0      1.0          1               0   
71      1       1.0    1.0  0.0      0.0          0               0   
72      1       1.0    1.0  1.0      1.0          0               0   
73      1       1.0    0.0  0.0      0.0          0               0   
74      1       1.0    0.0  0.0      0.0          1               0   
75      1       1.0    1.0  0.0      1.0          0               0   
76      1       1.0    1.0  1.0      1.0          0               0   
77      1       1.0    1.0  1.0      0.0          0               0   
78      1       0.0    0.0  0.0      0.0          0               0   
79      1       1.0    1.0  1.0      0.0          1               0   
80      1       1.0    1.0  1.0      1.0          0               0   
81      1       1.0    1.0  1.0      1.0          0               0   
82      1       1.0    1.0  1.0      0.0          0               0   
83      1       1.0    1.0  1.0      0.0          1               0   
84      1       1.0    1.0  1.0      0.0          1               0   
85      1       1.0    1.0  1.0      0.0          0               0   
86      1       1.0    1.0  0.0      0.0          1               0   
87      1       1.0    1.0  1.0      1.0          0               0   
88      1       0.0    0.0  0.0      0.0          1               0   
89      1       1.0    1.0  1.0      0.0          0               0   
90      1       1.0    1.0  1.0      0.0          0               0   
91      1       0.0    1.0  0.0      0.0          1               0   
92      1       1.0    1.0  1.0      1.0          0               0   
93      1       0.0    0.0  0.0      0.0          1               0   
94      1       1.0    1.0  1.0      0.0          0               0   
95      1       0.0    0.0  0.0      0.0          1               0   
96      1       0.0    0.0  0.0      0.0          1               0   
97      1       0.0    1.0  0.0      0.0          1               0   
98      1       0.0    1.0  0.0      0.0          1               0   
99      1       1.0    1.0  1.0      0.0          0               0   

    heduc_noans  usemeth_noans  
0             0              0  
1             0              0  
2             0              0  
3             0              0  
4             0              0  
5             0              0  
6             0              0  
7             0              0  
8             0              0  
9             0              0  
10            0              0  
11            0              0  
12            1              0  
13            0              0  
14            0              0  
15            0              0  
16            0              0  
17            0              0  
18            0              0  
19            0              0  
20            0              0  
21            0              0  
22            0              0  
23            0              0  
24            0              0  
25            0              0  
26            0              0  
27            0              0  
28            0              0  
29            0              0  
..          ...            ...  
70            0              0  
71            0              0  
72            0              0  
73            0              0  
74            0              0  
75            0              0  
76            0              0  
77            0              0  
78            0              0  
79            0              0  
80            0              0  
81            0              0  
82            0              0  
83            0              0  
84            0              0  
85            0              0  
86            0              0  
87            0              0  
88            0              0  
89            0              0  
90            0              0  
91            0              0  
92            0              0  
93            0              0  
94            0              0  
95            0              0  
96            0              0  
97            0              0  
98            0              0  
99            0              0  

[100 rows x 18 columns]
0

In [7]:
data.info()


<class 'pandas.core.frame.DataFrame'>
Int64Index: 4348 entries, 0 to 4360
Data columns (total 18 columns):
ceb               4348 non-null int64
age               4348 non-null int64
educ              4348 non-null object
religion          4348 non-null object
idlnchld          4348 non-null float64
knowmeth          4348 non-null float64
usemeth           4348 non-null float64
agefm             4348 non-null float64
heduc             4348 non-null float64
urban             4348 non-null int64
electric          4348 non-null float64
radio             4348 non-null float64
tv                4348 non-null float64
bicycle           4348 non-null float64
nevermarr         4348 non-null int64
idlnchld_noans    4348 non-null int64
heduc_noans       4348 non-null int64
usemeth_noans     4348 non-null int64
dtypes: float64(9), int64(7), object(2)
memory usage: 611.4+ KB

Построение модели


In [35]:
m1 = smf.ols('ceb ~ age + educ + religion + idlnchld + knowmeth + usemeth + agefm + heduc + urban + electric + '\
             'radio + tv + bicycle + nevermarr + idlnchld_noans + heduc_noans + usemeth_noans', 
             data=data)
fitted = m1.fit()
print fitted.summary()


                            OLS Regression Results                            
==============================================================================
Dep. Variable:                    ceb   R-squared:                       0.647
Model:                            OLS   Adj. R-squared:                  0.644
Method:                 Least Squares   F-statistic:                     208.1
Date:                Mon, 27 Jun 2016   Prob (F-statistic):               0.00
Time:                        16:43:57   Log-Likelihood:                -7713.0
No. Observations:                4348   AIC:                         1.550e+04
Df Residuals:                    4309   BIC:                         1.575e+04
Df Model:                          38                                         
Covariance Type:            nonrobust                                         
==========================================================================================
                             coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------------------
Intercept                 -1.1702      0.215     -5.441      0.000        -1.592    -0.748
educ[T.1]                 -0.1033      0.192     -0.538      0.591        -0.480     0.273
educ[T.10]                -0.6971      0.091     -7.668      0.000        -0.875    -0.519
educ[T.11]                -0.6653      0.262     -2.544      0.011        -1.178    -0.153
educ[T.12]                -1.1297      0.137     -8.221      0.000        -1.399    -0.860
educ[T.13]                -0.9444      0.347     -2.723      0.006        -1.624    -0.265
educ[T.14]                -0.7766      0.253     -3.069      0.002        -1.273    -0.280
educ[T.15]                -1.4138      0.303     -4.660      0.000        -2.009    -0.819
educ[T.16]                -1.3374      0.365     -3.667      0.000        -2.052    -0.622
educ[T.17]                -1.4845      0.383     -3.873      0.000        -2.236    -0.733
educ[T.18]                -1.3331      0.838     -1.592      0.112        -2.975     0.309
educ[T.19]                -1.9553      0.728     -2.687      0.007        -3.382    -0.529
educ[T.2]                  0.1034      0.150      0.691      0.490        -0.190     0.397
educ[T.20]                -1.3778      1.442     -0.955      0.339        -4.205     1.450
educ[T.3]                 -0.0457      0.130     -0.351      0.726        -0.301     0.210
educ[T.4]                  0.0131      0.114      0.114      0.909        -0.211     0.237
educ[T.5]                 -0.1251      0.108     -1.162      0.246        -0.336     0.086
educ[T.6]                 -0.1689      0.100     -1.697      0.090        -0.364     0.026
educ[T.7]                 -0.3968      0.073     -5.450      0.000        -0.540    -0.254
educ[T.8]                 -0.2702      0.124     -2.174      0.030        -0.514    -0.026
educ[T.9]                 -0.3639      0.115     -3.155      0.002        -0.590    -0.138
religion[T.other]         -0.0731      0.083     -0.880      0.379        -0.236     0.090
religion[T.protestant]    -0.0197      0.082     -0.240      0.810        -0.181     0.142
religion[T.spirit]        -0.0293      0.078     -0.377      0.706        -0.181     0.123
age                        0.1719      0.003     50.429      0.000         0.165     0.179
idlnchld                   0.0751      0.011      6.847      0.000         0.054     0.097
knowmeth                   0.5303      0.122      4.360      0.000         0.292     0.769
usemeth                    0.6611      0.048     13.683      0.000         0.566     0.756
agefm                     -0.0602      0.007     -9.149      0.000        -0.073    -0.047
heduc                     -0.0504      0.008     -6.173      0.000        -0.066    -0.034
urban                     -0.2326      0.047     -4.901      0.000        -0.326    -0.140
electric                  -0.2442      0.078     -3.139      0.002        -0.397    -0.092
radio                     -0.0295      0.051     -0.577      0.564        -0.130     0.071
tv                        -0.0848      0.094     -0.903      0.366        -0.269     0.099
bicycle                    0.2025      0.050      4.027      0.000         0.104     0.301
nevermarr                 -2.2118      0.148    -14.908      0.000        -2.503    -1.921
idlnchld_noans             0.6515      0.152      4.273      0.000         0.353     0.950
heduc_noans               -0.8497      0.145     -5.862      0.000        -1.134    -0.566
usemeth_noans              0.8047      0.196      4.115      0.000         0.421     1.188
==============================================================================
Omnibus:                      239.910   Durbin-Watson:                   1.891
Prob(Omnibus):                  0.000   Jarque-Bera (JB):              971.564
Skew:                           0.018   Prob(JB):                    1.07e-211
Kurtosis:                       5.316   Cond. No.                     2.09e+03
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
[2] The condition number is large, 2.09e+03. This might indicate that there are
strong multicollinearity or other numerical problems.

In [10]:
print  sms.het_breushpagan(fitted.resid, fitted.model.exog)


(1126.2841398970429, 1.4104933848476806e-211, 39.641824170360152, 1.4399529083318361e-247)

In [13]:
m2 = smf.ols('ceb ~ age + educ + idlnchld + knowmeth + usemeth + agefm + heduc + urban + electric + '\
             'bicycle + nevermarr + idlnchld_noans + heduc_noans + usemeth_noans', 
             data=data)
fitted = m2.fit()
print fitted.summary()
print  sms.het_breushpagan(fitted.resid, fitted.model.exog)
print "F=%f, p=%f, k1=%f" % m1.fit().compare_f_test(m2.fit())


                            OLS Regression Results                            
==============================================================================
Dep. Variable:                    ceb   R-squared:                       0.647
Model:                            OLS   Adj. R-squared:                  0.644
Method:                 Least Squares   F-statistic:                     239.8
Date:                Mon, 27 Jun 2016   Prob (F-statistic):               0.00
Time:                        16:07:27   Log-Likelihood:                -7714.1
No. Observations:                4348   AIC:                         1.550e+04
Df Residuals:                    4314   BIC:                         1.571e+04
Df Model:                          33                                         
Covariance Type:            nonrobust                                         
==================================================================================
                     coef    std err          t      P>|t|      [95.0% Conf. Int.]
----------------------------------------------------------------------------------
Intercept         -1.2267      0.202     -6.084      0.000        -1.622    -0.831
educ[T.1]         -0.1057      0.192     -0.551      0.582        -0.482     0.270
educ[T.10]        -0.6964      0.088     -7.872      0.000        -0.870    -0.523
educ[T.11]        -0.6663      0.259     -2.568      0.010        -1.175    -0.158
educ[T.12]        -1.1354      0.134     -8.450      0.000        -1.399    -0.872
educ[T.13]        -0.9632      0.345     -2.788      0.005        -1.640    -0.286
educ[T.14]        -0.7901      0.251     -3.147      0.002        -1.282    -0.298
educ[T.15]        -1.4245      0.303     -4.705      0.000        -2.018    -0.831
educ[T.16]        -1.3544      0.363     -3.735      0.000        -2.065    -0.643
educ[T.17]        -1.5262      0.381     -4.009      0.000        -2.273    -0.780
educ[T.18]        -1.3464      0.837     -1.609      0.108        -2.987     0.294
educ[T.19]        -1.9579      0.726     -2.696      0.007        -3.382    -0.534
educ[T.2]          0.1097      0.149      0.736      0.462        -0.183     0.402
educ[T.20]        -1.4471      1.441     -1.004      0.315        -4.272     1.378
educ[T.3]         -0.0391      0.130     -0.301      0.763        -0.294     0.215
educ[T.4]          0.0162      0.114      0.143      0.887        -0.207     0.240
educ[T.5]         -0.1209      0.107     -1.128      0.259        -0.331     0.089
educ[T.6]         -0.1620      0.099     -1.642      0.101        -0.355     0.031
educ[T.7]         -0.3940      0.072     -5.501      0.000        -0.534    -0.254
educ[T.8]         -0.2647      0.123     -2.150      0.032        -0.506    -0.023
educ[T.9]         -0.3572      0.114     -3.144      0.002        -0.580    -0.134
age                0.1720      0.003     50.814      0.000         0.165     0.179
idlnchld           0.0756      0.011      6.909      0.000         0.054     0.097
knowmeth           0.5296      0.121      4.363      0.000         0.292     0.768
usemeth            0.6638      0.048     13.765      0.000         0.569     0.758
agefm             -0.0602      0.007     -9.165      0.000        -0.073    -0.047
heduc             -0.0516      0.008     -6.379      0.000        -0.067    -0.036
urban             -0.2371      0.047     -5.045      0.000        -0.329    -0.145
electric          -0.2728      0.071     -3.826      0.000        -0.413    -0.133
bicycle            0.1937      0.049      3.929      0.000         0.097     0.290
nevermarr         -2.2175      0.148    -14.961      0.000        -2.508    -1.927
idlnchld_noans     0.6511      0.152      4.278      0.000         0.353     0.950
heduc_noans       -0.8580      0.145     -5.927      0.000        -1.142    -0.574
usemeth_noans      0.8112      0.195      4.153      0.000         0.428     1.194
==============================================================================
Omnibus:                      240.198   Durbin-Watson:                   1.891
Prob(Omnibus):                  0.000   Jarque-Bera (JB):              973.580
Skew:                           0.019   Prob(JB):                    3.89e-212
Kurtosis:                       5.318   Cond. No.                     2.09e+03
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
[2] The condition number is large, 2.09e+03. This might indicate that there are
strong multicollinearity or other numerical problems.
(1120.1821725794809, 4.472387239428725e-214, 45.367603814262218, 6.1797254040121324e-250)
F=0.456283, p=0.808965, k1=5.000000

In [15]:
m3 = smf.ols('ceb ~ age + educ + idlnchld + knowmeth + agefm + heduc + urban + electric + '\
             'bicycle + nevermarr + idlnchld_noans + heduc_noans', 
             data=data)
fitted = m3.fit()
print fitted.summary()
print  sms.het_breushpagan(fitted.resid, fitted.model.exog)
m2.fit().compare_f_test(m3.fit())[1]


                            OLS Regression Results                            
==============================================================================
Dep. Variable:                    ceb   R-squared:                       0.631
Model:                            OLS   Adj. R-squared:                  0.629
Method:                 Least Squares   F-statistic:                     238.6
Date:                Mon, 27 Jun 2016   Prob (F-statistic):               0.00
Time:                        16:10:07   Log-Likelihood:                -7808.6
No. Observations:                4348   AIC:                         1.568e+04
Df Residuals:                    4316   BIC:                         1.589e+04
Df Model:                          31                                         
Covariance Type:            nonrobust                                         
==================================================================================
                     coef    std err          t      P>|t|      [95.0% Conf. Int.]
----------------------------------------------------------------------------------
Intercept         -1.3626      0.206     -6.621      0.000        -1.766    -0.959
educ[T.1]         -0.1668      0.196     -0.851      0.395        -0.551     0.217
educ[T.10]        -0.5071      0.089     -5.680      0.000        -0.682    -0.332
educ[T.11]        -0.5008      0.265     -1.891      0.059        -1.020     0.018
educ[T.12]        -0.8768      0.136     -6.450      0.000        -1.143    -0.610
educ[T.13]        -0.7337      0.353     -2.081      0.038        -1.425    -0.042
educ[T.14]        -0.6471      0.256     -2.525      0.012        -1.150    -0.145
educ[T.15]        -1.2141      0.309     -3.931      0.000        -1.820    -0.609
educ[T.16]        -1.1792      0.370     -3.186      0.001        -1.905    -0.453
educ[T.17]        -1.2977      0.389     -3.339      0.001        -2.060    -0.536
educ[T.18]        -1.1180      0.855     -1.308      0.191        -2.794     0.558
educ[T.19]        -1.8702      0.742     -2.520      0.012        -3.325    -0.415
educ[T.2]          0.1310      0.152      0.860      0.390        -0.168     0.430
educ[T.20]        -1.2611      1.472     -0.857      0.392        -4.147     1.625
educ[T.3]          0.0201      0.133      0.152      0.879        -0.240     0.280
educ[T.4]          0.0580      0.116      0.498      0.618        -0.170     0.286
educ[T.5]         -0.0036      0.109     -0.033      0.974        -0.217     0.210
educ[T.6]         -0.0936      0.101     -0.930      0.353        -0.291     0.104
educ[T.7]         -0.2608      0.073     -3.596      0.000        -0.403    -0.119
educ[T.8]         -0.1636      0.126     -1.303      0.193        -0.410     0.083
educ[T.9]         -0.2439      0.116     -2.107      0.035        -0.471    -0.017
age                0.1798      0.003     52.844      0.000         0.173     0.186
idlnchld           0.0687      0.011      6.153      0.000         0.047     0.091
knowmeth           0.8481      0.122      6.976      0.000         0.610     1.086
agefm             -0.0643      0.007     -9.596      0.000        -0.077    -0.051
heduc             -0.0462      0.008     -5.598      0.000        -0.062    -0.030
urban             -0.2068      0.048     -4.314      0.000        -0.301    -0.113
electric          -0.2706      0.073     -3.714      0.000        -0.413    -0.128
bicycle            0.1886      0.050      3.743      0.000         0.090     0.287
nevermarr         -2.3239      0.151    -15.387      0.000        -2.620    -2.028
idlnchld_noans     0.5235      0.155      3.373      0.001         0.219     0.828
heduc_noans       -0.7646      0.148     -5.177      0.000        -1.054    -0.475
==============================================================================
Omnibus:                      261.768   Durbin-Watson:                   1.915
Prob(Omnibus):                  0.000   Jarque-Bera (JB):             1033.326
Skew:                          -0.150   Prob(JB):                    4.13e-225
Kurtosis:                       5.369   Cond. No.                     2.09e+03
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
[2] The condition number is large, 2.09e+03. This might indicate that there are
strong multicollinearity or other numerical problems.
(1066.6508033862499, 2.5598887674717488e-204, 45.257395481396586, 1.6368951155556597e-236)
Out[15]:
1.906265566261508e-41