简体   繁体   English

statsmodels OLS return.params的含义

[英]Meaning of statsmodels OLS return.params

I am trying to do linear regression with OLS and Res.params has retruned me a 2x2 array. 我正在尝试使用OLS和Res.params进行线性回归,因此向我回归了2x2数组。 I know the .params[0][1] and .params[1][1] are the beta and constant of the regression. 我知道.params[0][1].params[1][1]是回归的beta和常数。 However, what's the meaning for .params[0][0] and .params[1][0] ? 但是, .params[0][0].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? 如何更改实现,使其只能返回带有beta和常量的数组?

Thanks @user2285236. 感谢@ 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.])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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