statsmodels.graphics.regressionplots.added_variable_resids#

statsmodels.graphics.regressionplots.added_variable_resids(results, focus_exog, resid_type=None, use_glm_weights=True, fit_kwargs=None)[source]#

Residualize the endog variable and a ‘focus’ exog variable in a regression model with respect to the other exog variables

Parameters:
resultsregression results instance

A fitted model including the focus exog and all other predictors of interest.

focus_exogint or str

The column of results.model.exog or a variable name that is to be residualized against the other predictors.

resid_typestr, optional

The type of residuals to use for the dependent variable. If None, uses resid_deviance for GLM/GEE and resid otherwise.

use_glm_weightsbool, optional

Only used if the model is a GLM or GEE. If True, the residuals for the focus predictor are computed using WLS, with the weights obtained from the IRLS calculations for fitting the GLM. If False, unweighted regression is used.

fit_kwargsdict, optional

Keyword arguments to be passed to fit when refitting the model.

Returns:
endog_residndarray

The residuals for the original exog

focus_exog_residndarray

The residuals for the focus predictor

Notes

The ‘focus variable’ residuals are always obtained using linear regression.

Currently only GLM, GEE, and OLS models are supported.