简体   繁体   English

Python 2.7- statsmodels-result.conf_int()

[英]Python 2.7- statsmodels - result.conf_int()

This post is an addition to the post found here: Python 2.7 - statsmodels - formatting and writing summary output 这篇文章是在这里找到的文章的补充: Python 2.7-statsmodels-格式化和编写摘要输出

I got everything formatted how I need, except the confidence interval is giving me problems. 除了置信区间给我带来了问题外,我已经按照自己的需要格式化了一切。

I have tried a number of different things including: 我尝试了许多不同的方法,包括:

low, high = result.conf_int()

Which, when printed, returns: 打印时返回以下内容:

 low
 Out[260]: 0

 high
 Out[261]: 1

Similarly, I've tried: 同样,我尝试过:

low, up = result.conf_int().T

But get the error: 但是得到错误:

 ValueError: too many values to unpack

Same thing when I try: 当我尝试时也是一样:

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

ValueError: too many values to unpack

I also tried looking it up both here (I have 0.4.3 and couldn't find a page for this version) and here . 我也试图寻找它都在这里 (我有0.4.3,找不到此版本的页面),并在这里 Neither were helpful in solving this problem. 都没有帮助解决这个问题。

I think you've put in pandas object to the model, so conf_int will return a DataFrame. 我认为您已将pandas对象放入模型中,因此conf_int将返回一个DataFrame。 Try something like 尝试类似

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

使用以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM