In [1]:
import first
live, firsts, others = first.MakeFrames()
df = live[live.prglngth>30]

The following are the only variables I found that have a statistically significant effect on pregnancy length.


In [21]:
import statsmodels.formula.api as smf
model = smf.ols('prglngth ~ birthord==1 + race==2 + nbrnaliv>1', data=df)
results = model.fit()
results.summary()


Out[21]:
OLS Regression Results
Dep. Variable: prglngth R-squared: 0.019
Model: OLS Adj. R-squared: 0.018
Method: Least Squares F-statistic: 15.05
Date: Thu, 26 Jun 2014 Prob (F-statistic): 3.48e-12
Time: 16:04:17 Log-Likelihood: -6501.2
No. Observations: 3109 AIC: 1.301e+04
Df Residuals: 3104 BIC: 1.304e+04
Df Model: 4
coef std err t P>|t| [95.0% Conf. Int.]
Intercept 38.7087 0.087 446.225 0.000 38.539 38.879
birthord == 1[T.True] 0.1329 0.073 1.832 0.067 -0.009 0.275
race == 2[T.True] 0.1691 0.076 2.236 0.025 0.021 0.317
nbrnaliv > 1[T.True] -2.0538 0.292 -7.043 0.000 -2.626 -1.482
workpreg -0.0079 0.018 -0.441 0.659 -0.043 0.027
Omnibus: 452.571 Durbin-Watson: 1.784
Prob(Omnibus): 0.000 Jarque-Bera (JB): 1520.144
Skew: -0.722 Prob(JB): 0.00
Kurtosis: 6.106 Cond. No. 29.1

Let's go mining for variables that predict sex ratio.


In [22]:
import regression
join = regression.JoinFemResp(live)

In [31]:
def GoMining(df):
    """Searches for variables that predict birth weight.

    df: DataFrame of pregnancy records

    returns: list of (rsquared, variable name) pairs
    """
    df['boy'] = (df.babysex==1).astype(int)
    variables = []
    for name in df.columns:
        try:
            if df[name].var() < 1e-7:
                continue

            formula='boy ~ agepreg + ' + name
            model = smf.logit(formula, data=df)
            nobs = len(model.endog)
            if nobs < len(df)/2:
                continue

            results = model.fit()
        except:
            continue

        variables.append((results.prsquared, name))

    return variables

variables = GoMining(join)


Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692848
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692949
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692731
         Iterations 6
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692984
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692769
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.687615
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693032
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692949
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693046
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692955
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692978
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692904
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693076
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693096
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692561
         Iterations 6
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692822
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692908
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692553
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692954
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692961
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693044
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693043
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692684
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692572
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693061
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692921
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692903
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692863
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692860
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692854
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692455
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692582
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692490
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692760
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692274
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692925
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692966
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692969
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692863
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692870
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692870
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692833
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692938
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692995
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692890
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692907
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692609
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692859
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692660
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692904
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692714
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692923
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692965
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692934
         Iterations 4
Warning: Maximum number of iterations has been exceeded.
         Current function value: 0.692798
         Iterations: 35
Optimization terminated successfully.
         Current function value: 0.692665
         Iterations 6
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692930
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692816
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.687464
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692945
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692913
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692885
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692870
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692863
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692870
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692938
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692833
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692831
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692988
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692957
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692933
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692987
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692912
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692554
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692939
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692994
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693033
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692954
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693051
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693031
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692869
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693049
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692910
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692973
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692297
         Iterations 6
Optimization terminated successfully.
         Current function value: 0.692978
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692854
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692924
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692890
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692962
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692780
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693100
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692985
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693053
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693040
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692913
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693036
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693037
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693057
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693056
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692973
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692816
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693072
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693052
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692921
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692892
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693034
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692853
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692988
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692994
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692954
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692747
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692850
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.693004
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693085
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692994
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692962
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692943
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693074
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692942
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692952
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692887
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692876
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692770
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692786
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692890
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692827
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692997
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693134
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693131
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692976
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692915
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692846
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692928
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692874
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692877
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693004
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692993
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693035
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692713
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692650
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693038
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692868
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692862
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692957
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692677
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693072
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692725
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692964
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692961
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692833
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692929
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692942
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692895
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692910
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692963
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693005
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693004
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692967
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692897
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692983
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692967
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692981
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693044
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693045
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693082
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693051
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693008
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692867
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692980
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692997
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693005
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692988
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692992
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692995
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693005
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692779
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692991
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692644
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692625
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692858
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692820
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692864
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693010
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692903
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692912
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692889
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693010
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692978
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692986
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692828
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692990
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692838
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692986
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692987
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692940
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692985
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692955
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692862
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692913
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692825
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692742
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692993
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692570
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692668
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693004
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692766
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692791
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693033
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692730
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693033
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692658
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692996
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692704
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693046
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692603
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693058
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692822
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693085
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692743
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693078
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692815
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692964
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692889
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692805
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693075
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692964
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692980
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692984
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692994
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692952
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692689
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692830
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692937
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692766
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692742
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692705
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692849
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692937
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692906
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692849
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692699
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692958
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692901
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692994
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692952
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692885
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692974
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692828
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692609
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692905
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693070
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692937
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692866
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692937
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692986
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692976
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692603
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692978
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692847
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693115
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693046
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692929
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692872
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692887
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692849
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692944
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692965
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692991
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693004
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692938
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692946
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692990
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692966
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692924
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692870
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692833
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692995
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692633
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692970
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692830
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692771
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692982
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692890
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692899
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692759
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692681
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692936
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692599
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692779
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692852
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692753
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692701
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692968
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692871
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692836
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692834
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692727
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692996
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692884
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692847
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692483
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692861
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692538
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692911
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692673
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692829
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692929
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692757
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692921
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692908
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Warning: Maximum number of iterations has been exceeded.
         Current function value: 0.692957
         Iterations: 35
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692889
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692987
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692983
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692900
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692898
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692916
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692917
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692904
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692855
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692806
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692987
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692962
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692900
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692898
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692973
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692931
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692879
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692983
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692904
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692898
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693008
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692960
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692946
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692946
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693008
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692946
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692958
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692956
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692938
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692918
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692923
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693055
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692796
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692997
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692802
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692952
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692872
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693070
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692726
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692873
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692933
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692728
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692775
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692894
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692739
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692755
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692855
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692971
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692788
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692995
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692992
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693013
         Iterations 4
Warning: Maximum number of iterations has been exceeded.
         Current function value: 0.692882
         Iterations: 35
Optimization terminated successfully.
         Current function value: 0.692882
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692757
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692886
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692842
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692821
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692711
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692898
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692881
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692846
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692786
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692716
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692974
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692783
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692773
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692982
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692952
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692870
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692958
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692963
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692970
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693046
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693004
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693023
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693025
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692982
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692298
         Iterations 5
Warning: Maximum number of iterations has been exceeded.
         Current function value: 0.692722
         Iterations: 35
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692786
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692675
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692960
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692794
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692901
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693038
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692888
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692824
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692882
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692999
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692882
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692896
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692816
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692935
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692812
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692896
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692945
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692921
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692921
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693017
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692975
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692948
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692817
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.693029
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692915
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692863
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692939
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692940
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692888
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692973
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693022
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692998
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692888
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693002
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693003
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692973
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693018
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693020
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692962
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692847
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.692953
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692978
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692973
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692987
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692993
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693027
         Iterations 3
Warning: Maximum number of iterations has been exceeded.
         Current function value: 0.692956
         Iterations: 35
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692823
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693007
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693011
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693001
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692840
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692718
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692504
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692809
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693005
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693024
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.692697
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.693009
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693012
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693006
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692907
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693028
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692972
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692948
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693014
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693030
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692816
         Iterations 4
Optimization terminated successfully.
         Current function value: 0.693021
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693015
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693000
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693026
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693019
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.693016
         Iterations 3
Optimization terminated successfully.
         Current function value: 0.692979
         Iterations 3

Here are the 30 variables that yield the highest pseudo-$R^2$ value.


In [32]:
regression.MiningReport(variables)


totalwgt_lb 0.00804663447664
birthwgt_lb 0.00783469107423 BD-3 BIRTHWEIGHT IN POUNDS - 1ST BABY FROM THIS PREGNANCY
lbw1 0.00110496535201 LOW BIRTHWEIGHT - BABY 1
nplaced 0.00107176328366 # OF R'S BIO CHILDREN SHE PLACED FOR ADOPTION (BASED ON BPA)
constat3 0.00107097717817 3RD PRIORITY CODE FOR CURRENT CONTRACEPTIVE STATUS
fmarout5 0.00084452858083 FORMAL MARITAL STATUS AT PREGNANCY OUTCOME
frsteatd 0.000816585752415 AGE (IN MOS) WHEN 1ST SUPPLEMENTED - 1ST FROM THIS PREG
rmarout6 0.000793145080913 INFORMAL MARITAL STATUS AT PREGNANCY OUTCOME - 6 CATEGORIES
infever 0.000772731734124 EVER USED INFERTILITY SERVICES OF ANY KIND
splstwk1 0.000727710547487 IF-1 H/P DOING WHAT LAST WEEK (EMPLOYMENT STATUS) 1ST MENTION
nummult41 0.000703107395067 NUMBER OF METHODS REPORTED IN (MAY 2002)
nummult34 0.000688515665856 NUMBER OF METHODS REPORTED IN (OCT 2001)
outcom02 0.00067518482234 OUTCOME OF PREGNANCY - 2ND
pmarpreg 0.000661046520124 WHETHER PREGNANCY ENDED BEFORE R'S 1ST MARRIAGE (PREMARITALLY)
brnout_r 0.000621690333737 IB-8 R BORN OUTSIDE OF US
brnout 0.000621690333737 IB-8 R BORN OUTSIDE OF US
nummult17 0.000600411677943 NUMBER OF METHODS REPORTED IN (MAY 2000)
educmom 0.000587560821584 MOTHER'S (OR MOTHER-FIGURE'S) EDUCATION
marout03 0.000573537821728 FORMAL MARITAL STATUS WHEN PREGNANCY ENDED - 3RD
numfirsm1 0.00057283427147 TOTAL NUMBER OF RESPONSES IN EB-1 FIRSMETH - PRESCRIPTION METHODS
nummult43 0.000569081526666 NUMBER OF METHODS REPORTED IN (JUL 2002)
nummult16 0.000568970901225 NUMBER OF METHODS REPORTED IN (APR 2000)
nummult39 0.000554509562327 NUMBER OF METHODS REPORTED IN (MAR 2002)
agepreg_i 0.000547750841445 AGEPREG IMPUTATION FLAG
nummult35 0.000547536020922 NUMBER OF METHODS REPORTED IN (NOV 2001)
lbw1_i 0.000540448123631 LBW1 IMPUTATION FLAG
coh1dur 0.000535508320214 DURATION (IN MONTHS) OF R'S FIRST COHABITATION
births5 0.000517297177993 NUMBER OF LIVE BIRTHS IN LAST 5 YEARS
p1yhsage 0.000514263746852 CI-6 PARTNER'S AGE AT 1ST SEX-1ST REPORTED PARTNER IN LAST 12 MOS
abort12 0.000505840942107 FA-3B RECEIVED ABORTION LAST 12 MONTHS

Eliminating variables that are not known during pregnancy and others that are fishy for various reasons, here's the best model I could find:


In [42]:
formula='boy ~ agepreg + fmarout5==5 + infever==1'
model = smf.logit(formula, data=join)
results = model.fit()
results.summary()


Optimization terminated successfully.
         Current function value: 0.691983
         Iterations 4
Out[42]:
Logit Regression Results
Dep. Variable: boy No. Observations: 9148
Model: Logit Df Residuals: 9144
Method: MLE Df Model: 3
Date: Thu, 26 Jun 2014 Pseudo R-squ.: 0.001525
Time: 16:22:43 Log-Likelihood: -6330.3
converged: True LL-Null: -6339.9
LLR p-value: 0.0002326
coef std err z P>|z| [95.0% Conf. Int.]
Intercept -0.1863 0.116 -1.606 0.108 -0.414 0.041
fmarout5 == 5[T.True] 0.1493 0.048 3.087 0.002 0.054 0.244
infever == 1[T.True] 0.2096 0.063 3.304 0.001 0.085 0.334
agepreg 0.0053 0.004 1.252 0.211 -0.003 0.014

Now let's build a model to predict the respondent's parity (number of babies born alive). I used a nonlinear model of age. The age3 term is probably overkill, but I thought I would show that it might not be a crazy choice. It doesn't have much effect on the predictions.


In [65]:
join.numbabes.replace([97], np.nan, inplace=True)
join['age2'] = join.age_r**2
join['age3'] = join.age_r**3

In [73]:
formula='numbabes ~ age_r + age2 + age3 + C(race) + totincr + educat'
model = smf.poisson(formula, data=join)
results = model.fit()
results.summary()


Optimization terminated successfully.
         Current function value: 1.677637
         Iterations 7
Out[73]:
Poisson Regression Results
Dep. Variable: numbabes No. Observations: 9148
Model: Poisson Df Residuals: 9140
Method: MLE Df Model: 7
Date: Fri, 27 Jun 2014 Pseudo R-squ.: 0.03665
Time: 10:20:25 Log-Likelihood: -15347.
converged: True LL-Null: -15931.
LLR p-value: 6.721e-248
coef std err z P>|z| [95.0% Conf. Int.]
Intercept -3.2731 0.719 -4.551 0.000 -4.683 -1.863
C(race)[T.2] -0.1403 0.014 -9.683 0.000 -0.169 -0.112
C(race)[T.3] -0.0959 0.024 -3.957 0.000 -0.143 -0.048
age_r 0.3744 0.069 5.433 0.000 0.239 0.510
age2 -0.0090 0.002 -4.158 0.000 -0.013 -0.005
age3 7.12e-05 2.2e-05 3.237 0.001 2.81e-05 0.000
totincr -0.0185 0.002 -9.858 0.000 -0.022 -0.015
educat -0.0463 0.003 -15.988 0.000 -0.052 -0.041

In [74]:
import pandas
columns = ['age_r', 'age2', 'age3', 'race', 'totincr', 'educat']
new = pandas.DataFrame([[35, 35**2, 35**3, 1, 14, 16]], columns=columns)
results.predict(new)


Out[74]:
array([ 2.47393019])

In [76]:
formula='rmarital ~ age_r + age2 + C(race) + totincr + educat'
model = smf.mnlogit(formula, data=join)
results = model.fit()
results.summary()


Optimization terminated successfully.
         Current function value: 1.092083
         Iterations 8
Out[76]:
MNLogit Regression Results
Dep. Variable: rmarital No. Observations: 9148
Model: MNLogit Df Residuals: 9113
Method: MLE Df Model: 30
Date: Fri, 27 Jun 2014 Pseudo R-squ.: 0.1661
Time: 10:22:24 Log-Likelihood: -9990.4
converged: True LL-Null: -11981.
LLR p-value: 0.000
rmarital=2 coef std err z P>|z| [95.0% Conf. Int.]
Intercept 8.9153 0.792 11.251 0.000 7.362 10.468
C(race)[T.2] -0.9260 0.087 -10.705 0.000 -1.096 -0.756
C(race)[T.3] -0.6335 0.133 -4.747 0.000 -0.895 -0.372
age_r -0.3567 0.050 -7.132 0.000 -0.455 -0.259
age2 0.0047 0.001 6.054 0.000 0.003 0.006
totincr -0.1301 0.011 -11.475 0.000 -0.152 -0.108
educat -0.1940 0.018 -10.534 0.000 -0.230 -0.158
rmarital=3 coef std err z P>|z| [95.0% Conf. Int.]
Intercept 2.9927 2.970 1.007 0.314 -2.829 8.815
C(race)[T.2] -0.3963 0.235 -1.685 0.092 -0.857 0.065
C(race)[T.3] 0.0650 0.336 0.194 0.846 -0.593 0.723
age_r -0.3141 0.174 -1.806 0.071 -0.655 0.027
age2 0.0064 0.003 2.532 0.011 0.001 0.011
totincr -0.3217 0.032 -10.135 0.000 -0.384 -0.259
educat -0.1093 0.048 -2.266 0.023 -0.204 -0.015
rmarital=4 coef std err z P>|z| [95.0% Conf. Int.]
Intercept -3.6475 1.193 -3.059 0.002 -5.985 -1.310
C(race)[T.2] -0.3303 0.091 -3.641 0.000 -0.508 -0.153
C(race)[T.3] -0.8227 0.170 -4.853 0.000 -1.155 -0.490
age_r 0.1238 0.070 1.763 0.078 -0.014 0.261
age2 -0.0008 0.001 -0.814 0.416 -0.003 0.001
totincr -0.2288 0.011 -20.058 0.000 -0.251 -0.206
educat 0.0661 0.016 4.015 0.000 0.034 0.098
rmarital=5 coef std err z P>|z| [95.0% Conf. Int.]
Intercept -2.3978 1.269 -1.889 0.059 -4.886 0.090
C(race)[T.2] -1.0493 0.101 -10.366 0.000 -1.248 -0.851
C(race)[T.3] -0.6065 0.154 -3.937 0.000 -0.908 -0.305
age_r 0.2084 0.077 2.699 0.007 0.057 0.360
age2 -0.0030 0.001 -2.619 0.009 -0.005 -0.001
totincr -0.2900 0.014 -20.314 0.000 -0.318 -0.262
educat -0.0176 0.021 -0.835 0.404 -0.059 0.024
rmarital=6 coef std err z P>|z| [95.0% Conf. Int.]
Intercept 8.1722 0.797 10.252 0.000 6.610 9.734
C(race)[T.2] -2.1628 0.079 -27.532 0.000 -2.317 -2.009
C(race)[T.3] -1.9701 0.136 -14.472 0.000 -2.237 -1.703
age_r -0.2188 0.050 -4.337 0.000 -0.318 -0.120
age2 0.0020 0.001 2.505 0.012 0.000 0.004
totincr -0.2888 0.011 -25.418 0.000 -0.311 -0.267
educat -0.0802 0.018 -4.582 0.000 -0.115 -0.046

In [80]:
columns = ['age_r', 'age2', 'race', 'totincr', 'educat']
new = pandas.DataFrame([[25, 25**2, 2, 11, 12]], columns=columns)
results.predict(new)


Out[80]:
array([[ 0.74568869,  0.12829132,  0.0016241 ,  0.03280099,  0.02188668,
         0.06970823]])

In [ ]: