def partial_project(endog, exog):
 (x1, x2) = (endog, exog)
 params = np.linalg.pinv(x2).dot(x1)
 predicted = x2.dot(params)
 residual = (x1 - predicted)
 res = Bunch(params=params, fittedvalues=predicted, resid=residual)
 return res

def partial_project ( endog , exog ) : ( x1 , x2 ) = ( endog , exog ) params = np . linalg . pinv ( x2 ) . dot ( x1 ) predicted = x2 . dot ( params ) residual = ( x1 - predicted ) res = Bunch ( params = params , fittedvalues = predicted , resid = residual ) return res
helper function to get linear projection or partialling out of variables endog variables are projected on exog variables parameters endog : ndarray array of variables where the effect of exog is partialled out .