Skip to content
Advertisement

Print ‘std err’ value from statsmodels OLS results

(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?

Advertisement

Answer

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”)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement