def partial_resids(results, focus_exog):
 model = results.model
 resid = (model.endog - results.predict())
 if isinstance(model, (GLM, GEE)):
  resid *= model.family.link.deriv(results.fittedvalues)
 elif isinstance(model, (OLS, GLS, WLS)):
  pass
 else:
  raise ValueError(("Partial residuals for '%s' not implemented." % type(model)))
 if (type(focus_exog) is str):
  focus_col = model.exog_names.index(focus_exog)
 else:
  focus_col = focus_exog
 focus_val = (results.params[focus_col] * model.exog[:, focus_col])
 return (focus_val + resid)

def partial_resids ( results , focus_exog ) : model = results . model resid = ( model . endog - results . predict ( ) ) if isinstance ( model , ( GLM , GEE ) ) : resid *= model . family . link . deriv ( results . fittedvalues ) elif isinstance ( model , ( OLS , GLS , WLS ) ) : pass else : raise ValueError ( ( "Partial residuals for '%s' not implemented." % type ( model ) ) ) if ( type ( focus_exog ) is str ) : focus_col = model . exog_names . index ( focus_exog ) else : focus_col = focus_exog focus_val = ( results . params [ focus_col ] * model . exog [ : , focus_col ] ) return ( focus_val + resid )
returns partial residuals for a fitted model with respect to a focus predictor .