【问题标题】:To which value in the statsmodels summary relates the error bar size in the plot?statsmodels 摘要中的哪个值与图中的误差条大小相关?
【发布时间】:2022-05-01 00:36:06
【问题描述】:

通过以下代码,我得到了一个图,我的数据是如何进行回归的。

图中还显示了垂直(错误?)条。

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.

剧情:

【问题讨论】:

    标签: python statistics regression linear-regression statsmodels


    【解决方案1】:

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

    它们不是“误差线”。它们是预测区间,不能从摘要输出中计算出来。

    【讨论】:

      猜你喜欢
      • 2021-03-04
      • 2021-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多