在statsmodels中使用公式和负二项式拟合模型0.6

时间:2014-10-13 22:52:23

标签: python statsmodels

我正在尝试使用python 3.4在statsmodels 0.6模块中使用负二项分析数据集。

import pandas as pd
import statsmodels.formula.api as smf
import statsmodels.api as sm
model2=smf.glm("an_darlingi ~ trat", data=dados,
             family=sm.families.NegativeBinomial()).fit()

输出:

                 Generalized Linear Model Regression Results                  
==============================================================================
Dep. Variable:            an_darlingi   No. Observations:                  363
Model:                            GLM   Df Residuals:                      352
Model Family:        NegativeBinomial   Df Model:                           10
Link Function:                    log   Scale:                   1.52662855632
Method:                          IRLS   Log-Likelihood:                -1404.7
Date:                Mon, 13 Oct 2014   Deviance:                       578.37
Time:                        19:34:45   Pearson chi2:                     537.
No. Iterations:                     7                                         
=================================================================================
                    coef    std err          t      P>|t|      [95.0% Conf. Int.]
---------------------------------------------------------------------------------
Intercept         2.9988      0.220     13.607      0.000         2.567     3.431
trat[T.CO2]      -0.3070      0.313     -0.981      0.327        -0.920     0.306
trat[T.ML]       -0.1709      0.312     -0.547      0.584        -0.783     0.441
trat[T.SFPF]     -0.3215      0.313     -1.027      0.304        -0.935     0.292
trat[T.SFPM]     -0.4085      0.314     -1.303      0.193        -1.023     0.206
trat[T.SFTF]     -0.0448      0.312     -0.144      0.886        -0.656     0.566
trat[T.SFTM]     -0.1835      0.312     -0.587      0.557        -0.796     0.429
trat[T.SIPF]     -0.3905      0.313     -1.246      0.213        -1.005     0.224
trat[T.SIPM]     -0.1799      0.312     -0.576      0.565        -0.792     0.432
trat[T.SIPTM]     0.0700      0.311      0.225      0.822        -0.540     0.680
trat[T.SITF]      0.1968      0.311      0.633      0.527        -0.413     0.806
=================================================================================

在输出中,我得到了t和p的值,我喜欢得到z的值和P>(z),就像在R中一样。我怎么能用smf.glm代替sm.NegativeBinomial。因为如果我尝试使用sm.NegativeBinomial,我会收到错误信息,因为它无法将字符串SIPTM转换为浮点数。

0 个答案:

没有答案
相关问题