Ussu20
Ussu20

Reputation: 199

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

Upvotes: 0

Views: 3043

Answers (1)

Josef
Josef

Reputation: 22897

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.

Upvotes: 1

Related Questions