'Runs the first stage of the 2SLS.
Returns the RHS variables that include the instruments.'

def whiten(self, Y):

    wexog = []
    indep_endog = self._indep_endog
    instruments = self.instruments
    for eq in range(self._M):
        instr_eq = Y.get(eq, None)
        newRHS = self.exog[eq].copy()
        if instr_eq:
            for (i, LHS) in enumerate(instr_eq):
                yhat = GLS(LHS, self.instruments).fit().fittedvalues
                newRHS[:, indep_endog[eq][i]] = yhat
        wexog.append(newRHS)
    return wexog
