【问题标题】:Python 2.7- statsmodels - result.conf_int()Python 2.7- statsmodels - result.conf_int()
【发布时间】:2013-05-25 10:04:03
【问题描述】:

此帖子是对此处找到的帖子的补充:Python 2.7 - statsmodels - formatting and writing summary output

我得到了我需要的所有格式,除了置信区间给我带来了问题。

我尝试了很多不同的方法,包括:

low, high = result.conf_int()

打印时返回:

 low
 Out[260]: 0

 high
 Out[261]: 1

同样,我试过了:

low, up = result.conf_int().T

但得到错误:

 ValueError: too many values to unpack

我尝试时也是这样:

for item in result.conf_int().T:
     low, high = item
     print low
     print high

ValueError: too many values to unpack

我还尝试同时查找 here(我有 0.4.3,但找不到此版本的页面)和 here。两者都没有帮助解决这个问题。

【问题讨论】:

    标签: python python-2.7 statsmodels


    【解决方案1】:

    我认为您已将 pandas 对象放入模型中,因此 conf_int 将返回一个 DataFrame。尝试类似

    conf_int = results.conf_int()
    print conf_int[0]
    print conf_int[1]
    

    【讨论】:

    • 是的!做到了!谢谢!
    【解决方案2】:

    使用以下内容:

    print('confidence interval of cofficients: \n', Results.conf_int())
    

    【讨论】:

      猜你喜欢
      • 2013-05-18
      • 2014-06-14
      • 1970-01-01
      • 2016-02-13
      • 2016-01-08
      • 1970-01-01
      • 2016-12-12
      • 2018-01-19
      • 2018-07-25
      相关资源
      最近更新 更多