statsmodels摘要中的哪个值与图中的误差线大小相关?

时间:2019-04-18 08:58:02

标签: python statistics regression linear-regression statsmodels

使用以下代码,我得到了一个图,该图显示了如何对数据进行回归。

在图中还显示了垂直( error ?)条。

summary中哪个数字分别表示这些条的长度:如何从摘要(或从模型中可以获取的任何数量)中得出条的大小?

代码:

import random
random.seed(42)
import statsmodels.api as smapi
from statsmodels.formula.api import ols
import statsmodels.graphics as smgraphics
# Make data #
x = list(range(30))
y = [y*(10+random.random())+200 for y in x]
# Add outlier #
x.insert(6,15)
y.insert(6,220)
x.insert(6,16)
y.insert(6,295)
# Make fit #
regression = ols("data ~ x", data=dict(data=y, x=x)).fit()
# Find outliers #
test = regression.outlier_test()

outliers = ((x[i],y[i]) for i,t in enumerate(test.iloc[:,2]) if t < 0.5)

print(regression.summary())

figure = smgraphics.regressionplots.plot_fit(regression, 1)
figure.show()

摘要:

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   data   R-squared:                       0.913
Model:                            OLS   Adj. R-squared:                  0.910
Method:                 Least Squares   F-statistic:                     314.1
Date:                Thu, 18 Apr 2019   Prob (F-statistic):           1.92e-17
Time:                        10:47:19   Log-Likelihood:                -150.87
No. Observations:                  32   AIC:                             305.7
Df Residuals:                      30   BIC:                             308.7
Df Model:                           1                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
Intercept    193.8136      9.880     19.618      0.000     173.637     213.990
x             10.4202      0.588     17.724      0.000       9.219      11.621
==============================================================================
Omnibus:                       57.423   Durbin-Watson:                   1.316
Prob(Omnibus):                  0.000   Jarque-Bera (JB):              379.511
Skew:                          -3.901   Prob(JB):                     3.89e-83
Kurtosis:                      17.958   Cond. No.                         33.8
==============================================================================
Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

剧情:

plot

0 个答案:

没有答案