简体   繁体   中英

GLM Residual in Python statsmodel

How to generate residuals for all 303 observations in Python:

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

or

res.resid()

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

res$resid

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

resid_anscombe Anscombe residuals.

resid_anscombe_scaled Scaled Anscombe residuals.

resid_anscombe_unscaled Unscaled Anscombe residuals.

resid_deviance Deviance residuals.

resid_pearson Pearson residuals.

resid_response Response residuals.

resid_working Working residuals.

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

The residual y - E(y|x) are the response residuals resid_response

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM