Python statsmodel中的GLM残差 [英] GLM Residual in Python statsmodel

查看:146
本文介绍了Python statsmodel中的GLM残差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Python中为所有303个观测值生成残差:

How to generate residuals for all 303 observations in Python:

from statsmodels.stats.outliers_influence import OLSInfluence
OLSInfluence(resid)

res.resid()

我正在尝试生成类似于我们使用R在R中生成的残差:

I am trying to generate residual similar to what we generate in R using:

res$resid

推荐答案

statsmodels没有用于 GLM 的默认 resid ,但是具有以下内容

statsmodels does not have a default resid for GLM, but it has the following

resid_anscombe Anscombe残差.

resid_anscombe Anscombe residuals.

resid_anscombe_scaled缩放后的Anscombe残差.

resid_anscombe_scaled Scaled Anscombe residuals.

resid_anscombe_unscaled未缩放的Anscombe残差.

resid_anscombe_unscaled Unscaled Anscombe residuals.

resid_deviance偏差残差.

resid_deviance Deviance residuals.

resid_pearson皮尔逊残差.

resid_pearson Pearson residuals.

resid_response响应残差.

resid_response Response residuals.

resid_working工作残差.

resid_working Working residuals.

https://www.statsmodels.org/stable/generation/statsmodels.genmod.generalized_linear_model.GLMResults.html

残差 y-E(y | x)是响应残差 resid_response

这些残差可用作 fit 方法返回的结果实例的属性.

Those residuals are available as attributes of the results instance that is returned by the fit method.

这篇关于Python statsmodel中的GLM残差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆