简体   繁体   中英

Meaning of statsmodels OLS return.params

I am trying to do linear regression with OLS and Res.params has retruned me a 2x2 array. I know the .params[0][1] and .params[1][1] are the beta and constant of the regression. However, what's the meaning for .params[0][0] and .params[1][0] ?

My implementation:

import statsmodels.api as sm
X = np.arange(0, 20)
X = sm.add_constant(X)
Y = (X * 3) + 8
Res = sm.OLS(Y, X).fit()
Res.params
array([[  1.10000000e+01,   8.00000000e+00],
       [  5.37764278e-17,   3.00000000e+00]])

Questions:

  1. What is the meaning of those values?
  2. How can I change my implementation, so it can return the array with beta and constant only?

Thanks @user2285236. It seems I messed up the order of the implementation. It works now:)

import statsmodels.api as sm
X = np.arange(0, 20)
Y = (X * 3) + 8
X = sm.add_constant(X)
Res = sm.OLS(Y, X).fit()
Res.params
array([ 8.,  3.])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM