python求不确定度_用python求线性回归中的不确定性值

import statsmodels.api as sm

import numpy as np

y=[];x=[]

for item in arr:

x.append(item[0])

y.append(item[1])

# include constant in ols models, which is not done by default

x = sm.add_constant(x)

model = sm.OLS(y,x)

results = model.fit()

然后,您可以访问所需的值,如下所示。截距和斜率由下式给出:

^{pr2}$

我想你指的是标准误差,当你提到不确定度时,它们可以这样得到:results.bse # standard errors of the parameter estimates

# array([ 1.03372221e-03, 2.38463106e-05])

可以通过运行>>> print results.summary()

OLS Regression Results

==============================================================================

Dep. Variable: y R-squared: 0.997

Model: OLS Adj. R-squared: 0.996

Method: Least Squares F-statistic: 8029.

Date: Fri, 26 Sep 2014 Prob (F-statistic): 5.61e-36

Time: 05:47:08 Log-Likelihood: 162.43

No. Observations: 30 AIC: -320.9

Df Residuals: 28 BIC: -318.0

Df Model: 1

Covariance Type: nonrobust

==============================================================================

coef std err t P>|t| [95.0% Conf. Int.]

const -0.0369 0.001 -35.719 0.000 -0.039 -0.035

x1 0.0021 2.38e-05 89.607 0.000 0.002 0.002

==============================================================================

Omnibus: 7.378 Durbin-Watson: 0.569

Prob(Omnibus): 0.025 Jarque-Bera (JB): 2.079

Skew: 0.048 Prob(JB): 0.354

Kurtosis: 1.714 Cond. No. 220.

==============================================================================

Warnings:

[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

This也可能对结果模型的属性摘要感兴趣。在

我没有与Excel中的LINEST进行比较。我也不知道这是否可能只使用googlechartsapi。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值