我正在尝试进行简单的OLS回归。它工作了很长时间,但现在突然间没有任何作用。
我的数据集看起来像这样(只是一个施加):
然后我尝试这种回归:
m1 = smf.ols(formula='crashes ~holiday', data=data).fit()
m1.summary()
产生了此错误消息:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-60-4909b8de1974> in <module>()
----> 1 m1.summary()
/Users/masb/anaconda/lib/python3.4/site-packages/statsmodels/regression/linear_model.py in summary(self, yname, xname, title, alpha)
1948 top_left.append(('Covariance Type:', [self.cov_type]))
1949
-> 1950 top_right = [('R-squared:', ["%#8.3f" % self.rsquared]),
1951 ('Adj. R-squared:', ["%#8.3f" % self.rsquared_adj]),
1952 ('F-statistic:', ["%#8.4g" % self.fvalue] ),
/Users/masb/anaconda/lib/python3.4/site-packages/statsmodels/tools/decorators.py in __get__(self, obj, type)
92 if _cachedval is None:
93 # Call the "fget" function
---> 94 _cachedval = self.fget(obj)
95 # Set the attribute in obj
96 # print("Setting %s in cache to %s" % (name, _cachedval))
/Users/masb/anaconda/lib/python3.4/site-packages/statsmodels/regression/linear_model.py in rsquared(self)
1179 def rsquared(self):
1180 if self.k_constant:
-> 1181 return 1 - self.ssr/self.centered_tss
1182 else:
1183 return 1 - self.ssr/self.uncentered_tss
/Users/masb/anaconda/lib/python3.4/site-packages/statsmodels/tools/decorators.py in __get__(self, obj, type)
92 if _cachedval is None:
93 # Call the "fget" function
---> 94 _cachedval = self.fget(obj)
95 # Set the attribute in obj
96 # print("Setting %s in cache to %s" % (name, _cachedval))
/Users/masb/anaconda/lib/python3.4/site-packages/statsmodels/regression/linear_model.py in ssr(self)
1151 def ssr(self):
1152 wresid = self.wresid
-> 1153 return np.dot(wresid, wresid)
1154
1155 @cache_readonly
ValueError: shapes (8766,1335) and (8766,1335) not aligned: 1335 (dim 1) != 8766 (dim 0)
我看不出自己做错了什么,我怀疑是否存在某些我无法控制的错误。
我非常感谢任何帮助