我想计算Cooks_d和DFFITS使用Python中statsmodel。
这是我在 Python 中的代码:
X = your_str_cleaned[param]
y = your_str_cleaned['Visitor']
X = sm.add_constant(X)
model = sm.OLS(y, X)
results = model.fit()
Run Code Online (Sandbox Code Playgroud)
我尝试使用它来获取Cooks Distance和DFFITS:
import statsmodels.stats.outliers_influence as st_inf
st_inf.OLSInfluence.summary_frame(results)
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
'OLSResults' 对象没有属性 'results'。
有人可以帮我找出我哪里出错了吗?