从statsmodels OLS结果中打印'std err'值 [英] Print 'std err' value from statsmodels OLS results
问题描述
(抱歉, http://statsmodels.sourceforge.net/目前已关闭,我可以无法访问文档)
基本上,我正在使用statsmodels
进行线性回归:
import statsmodels.api as sm
model = sm.OLS(y,x)
results = model.fit()
我知道我可以使用以下方法打印出整套结果:
print results.summary()
其输出类似于:
OLS Regression Results
==============================================================================
Dep. Variable: y R-squared: 0.952
Model: OLS Adj. R-squared: 0.951
Method: Least Squares F-statistic: 972.9
Date: Mon, 20 Jul 2015 Prob (F-statistic): 5.55e-34
Time: 15:35:22 Log-Likelihood: -78.843
No. Observations: 50 AIC: 159.7
Df Residuals: 49 BIC: 161.6
Df Model: 1
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [95.0% Conf. Int.]
------------------------------------------------------------------------------
x1 1.0250 0.033 31.191 0.000 0.959 1.091
==============================================================================
Omnibus: 16.396 Durbin-Watson: 2.166
Prob(Omnibus): 0.000 Jarque-Bera (JB): 3.480
Skew: -0.082 Prob(JB): 0.175
Kurtosis: 1.718 Cond. No. 1.00
==============================================================================
Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
我需要一种仅打印 coef
和std err
值的方法.
我可以通过以下方式访问coef
:
print results.params
但是我找不到打印出std err
的方法.
我该怎么做?
在此处应用给出的答案我使用了 dir()来打印results
对象的所有属性.>
此后,我搜索了包含std err
值的那个,结果是:
print results.bse
(不确定b
在bse
中代表什么,但是我猜se
代表标准错误")
(Sorry to ask but http://statsmodels.sourceforge.net/ is currently down and I can't access the docs)
I'm doing a linear regression using statsmodels
, basically:
import statsmodels.api as sm
model = sm.OLS(y,x)
results = model.fit()
I know that I can print out the full set of results with:
print results.summary()
which outputs something like:
OLS Regression Results
==============================================================================
Dep. Variable: y R-squared: 0.952
Model: OLS Adj. R-squared: 0.951
Method: Least Squares F-statistic: 972.9
Date: Mon, 20 Jul 2015 Prob (F-statistic): 5.55e-34
Time: 15:35:22 Log-Likelihood: -78.843
No. Observations: 50 AIC: 159.7
Df Residuals: 49 BIC: 161.6
Df Model: 1
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [95.0% Conf. Int.]
------------------------------------------------------------------------------
x1 1.0250 0.033 31.191 0.000 0.959 1.091
==============================================================================
Omnibus: 16.396 Durbin-Watson: 2.166
Prob(Omnibus): 0.000 Jarque-Bera (JB): 3.480
Skew: -0.082 Prob(JB): 0.175
Kurtosis: 1.718 Cond. No. 1.00
==============================================================================
Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
I need a way to print out only the values of coef
and std err
.
I can access coef
with:
print results.params
but I've found no way to print out std err
.
How can I do this?
Applying the answer given here I used dir() to print all the attributes of the results
object.
After that I searched for the one that contained the std err
value and it turned out to be:
print results.bse
(Not sure what the b
stands for in bse
, but I guess the se
stands for "standard error")
这篇关于从statsmodels OLS结果中打印'std err'值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!