Skip to content

Instantly share code, notes, and snippets.

@emredjan
Created April 23, 2018 17:18
Show Gist options
  • Save emredjan/4c2d5d93cbe3223489e18dab6f318709 to your computer and use it in GitHub Desktop.
Save emredjan/4c2d5d93cbe3223489e18dab6f318709 to your computer and use it in GitHub Desktop.
# fitted values (need a constant term for intercept)
model_fitted_y = model_fit.fittedvalues
# model residuals
model_residuals = model_fit.resid
# normalized residuals
model_norm_residuals = model_fit.get_influence().resid_studentized_internal
# absolute squared normalized residuals
model_norm_residuals_abs_sqrt = np.sqrt(np.abs(model_norm_residuals))
# absolute residuals
model_abs_resid = np.abs(model_residuals)
# leverage, from statsmodels internals
model_leverage = model_fit.get_influence().hat_matrix_diag
# cook's distance, from statsmodels internals
model_cooks = model_fit.get_influence().cooks_distance[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment