1

This is the code I have so far. I am performing a weighted least squares operation, and am printing the results out. I want to use the results from the summary, but the summary is apparently not iterable. Is there a way to pull the values from the summary?

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

Here is the summary as it prints out.

      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
==============================================================================

edit: To clarify, I want to extract the 'std err' values from each of the x1,x2...x7 rows. I can't seem to find the attribute that represents them or the rows they are in. Anyone know how to do this?

noggy
  • 149
  • 1
  • 2
  • 10

1 Answers1

1

After your operations, res_wls is of type statsmodels.regression.linear_model.RegressionResults, which contains individual attributes for each of the values that you might be interested in. See the documentation for the names of those. For instance, res_wls.rsquared should give you your $R^2$.

fuglede
  • 17,388
  • 2
  • 54
  • 99
  • That makes sense. Only thing is i'm trying to extract from the std err column, which I should have clarified before. I can't seem to find the attribute that represents them or the rows they are in. – noggy Oct 24 '16 at 20:32
  • They're in `params`, IIRC. – fuglede Oct 26 '16 at 11:04