你如何从statsmodels.WLS.fit.summary中提取价值?

时间:2016-10-24 19:05:32

标签: python statsmodels

这是我到目前为止的代码。我正在执行加权最小二乘运算,并打印出结果。我想使用摘要中的结果,但摘要显然不可迭代。有没有办法从摘要中提取值?

self.b = np.linalg.lstsq(self.G,self.d)
w = np.asarray(self.dw)
mod_wls = sm.WLS(self.d,self.G,weights=1./np.asarray(w))
res_wls = mod_wls.fit()
report = res_wls.summary()
print report

以下是打印出的摘要。

      WLS Regression Results                            
==============================================================================
Dep. Variable:                      y   R-squared:                       0.955
Model:                            WLS   Adj. R-squared:                  0.944
Method:                 Least Squares   F-statistic:                     92.82
Date:                Mon, 24 Oct 2016   Prob (F-statistic):           4.94e-14
Time:                        11:38:16   Log-Likelihood:                 138.19
No. Observations:                  28   AIC:                            -264.4
Df Residuals:                      22   BIC:                            -256.4
Df Model:                           5                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
x1            -0.0066      0.001    -12.389      0.000        -0.008    -0.006
x2             0.0072      0.000     15.805      0.000         0.006     0.008
x3          1.853e-08   2.45e-08      0.756      0.457     -3.23e-08  6.93e-08
x4         -4.402e-09   6.58e-09     -0.669      0.511     -1.81e-08  9.25e-09
x5         -3.595e-08   1.42e-08     -2.528      0.019     -6.55e-08 -6.45e-09
x6          4.402e-09   6.58e-09      0.669      0.511     -9.25e-09  1.81e-08
x7         -6.759e-05   4.17e-05     -1.620      0.120        -0.000   1.9e-05
==============================================================================
Omnibus:                        4.421   Durbin-Watson:                   1.564
Prob(Omnibus):                  0.110   Jarque-Bera (JB):                2.846
Skew:                           0.729   Prob(JB):                        0.241
Kurtosis:                       3.560   Cond. No.                     2.22e+16
==============================================================================

编辑:为了澄清,我想提取“标准错误”。每个x1,x2 ...... x7行的值。我似乎无法找到代表他们的属性或他们所在的行。有人知道怎么做吗?

1 个答案:

答案 0 :(得分:1)

操作完成后,res_wls的类型为statsmodels.regression.linear_model.RegressionResults,其中包含您可能感兴趣的每个值的各个属性。有关这些值的详细信息,请参阅the documentation。例如,res_wls.rsquared应该为您提供$ R ^ 2 $。