Python回归给出2个不同的结果

时间:2016-08-11 16:28:07

标签: python linear-regression seaborn

所以我有以下数据:

1995    0.379769  
1996    0.384967  
1997    0.344343  
1998    0.384179  
1999    0.282823  
2000    0.337774  
2001    0.298339  
2002    0.351266  
2003    0.338709  
2004    0.390772  
2005    0.410985  
2006    0.378565  
2007    0.383554  
2008    0.387875  
2009    0.471277  
2010    0.407915  
2011    0.400196  
2012    0.458957  
2013    0.478453  
2014    0.564311
2015    0.459423  

当我运行statsmodel OLS回归

lm = smf.ols(formula='Values ~ Year', data=v).fit()
print lm.summary()

我得到-15.0747的截距和0.0077的系数。然而,这对我来说很特别,当我把它与数据对比时。

enter image description here

正如您所看到的那样,当我根据数据/ seaborn回归线绘制最佳拟合线时,我得到一条看似平行但在视觉上低于所需位置的线,

我用它来制作那个图

ax = sns.regplot(x = "X", y = "y", data = test)
ax.plot([0, 2016], [-15.0747, 0.4485], c='r')
ax.set_xlim(1990,2016)
ax.set_ylim(0,1)

有人能告诉我这个错误发生在哪里以及它发生的原因吗?

修改

所以我注意到我把错误的数据子集给了Excel,但是这仍然没有改变这样一个事实:当我从SMF绘制回归线时它与seaborn不同

0 个答案:

没有答案