问题描述
如何在 Python 中为所有 303 个观测值生成残差:
from statsmodels.stats.outliers_influence import OLSInfluence
OLSInfluence(resid)
或
res.resid()
res$resid
解决方法
statsmodels 没有 resid
的默认 GLM
,但它有以下内容
resid_anscombe Anscombe 残差。
resid_anscombe_scaled 缩放 Anscombe 残差。
resid_anscombe_unscaled Unscaled Anscombe 残差。
resid_deviance 偏差残差。
resid_pearson Pearson 残差。
resid_response 响应残差。
resid_working 工作残差。
残差 y - E(y|x)
是响应残差 resid_response
这些残差可用作 fit
方法返回的结果实例的属性。