class_docstr: Two-Stage Least Squares for Simultaneous equations
  
  Parameters
  ----------
  sys : list
      [endog1, exog1, endog2, exog2,...] It will be of length 2 x M,
      where M is the number of equations endog = exog.
  indep_endog : dict
      A dictionary mapping the equation to the column numbers of the
      the independent endogenous regressors in each equation.
      It is assumed that the system is entered as broken up into
      LHS and RHS. For now, the values of the dict have to be sequences.
      Note that the keys for the equations should be zero-indexed.
  instruments : ndarray
      Array of the exogenous independent variables.
  
  Notes
  -----
  This is unfinished, and the design should be refactored.
  Estimation is done by brute force and there is no exploitation of
  the structure of the system.
class_docstr_tok: ["Two-Stage","Least","Squares","for","Simultaneous","equations","Parameters","--","--","--","--","--","sys",":","list","[","endog1",",","exog1",",","endog2",",","exog2",",","...","]","It","will","be","of","length","2","x","M",",","where","M","is","the","number","of","equations","endog","=","exog",".","indep_endog",":","dict","A","dictionary","mapping","the","equation","to","the","column","numbers","of","the","the","independent","endogenous","regressors","in","each","equation",".","It","is","assumed","that","the","system","is","entered","as","broken","up","into","LHS","and","RHS",".","For","now",",","the","values","of","the","dict","have","to","be","sequences",".","Note","that","the","keys","for","the","equations","should","be","zero-indexed",".","instruments",":","ndarray","Array","of","the","exogenous","independent","variables",".","Notes","--","--","-","This","is","unfinished",",","and","the","design","should","be","refactored",".","Estimation","is","done","by","brute","force","and","there","is","no","exploitation","of","the","structure","of","the","system","."]
docstr: Runs the first stage of the 2SLS.
  
  Returns the RHS variables that include the instruments.
docstr_tok: ["Runs","the","first","stage","of","the","2SLS",".","Returns","the","RHS","variables","that","include","the","instruments","."]
code: def whiten(self, Y):
      """
      Runs the first stage of the 2SLS.
  
      Returns the RHS variables that include the instruments.
      """
      wexog = []
      indep_endog = self._indep_endog  # this has the col mapping
      #        fullexog = self.fullexog
      instruments = self.instruments
      for eq in range(
          self._M
      ):  # need to go through all equations regardless
          instr_eq = Y.get(
              eq, None
          )  # Y has the eq to ind endog array map
          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
              # this might fail if there is a one variable column (nobs,)
              # in exog
          wexog.append(newRHS)
      return wexog
  
file_path: statsmodels/statsmodels/sandbox/sysreg.py
imports: from statsmodels.regression.linear_model import GLS
  import numpy
  from statsmodels.base.model import LikelihoodModelResults
  from scipy import sparse
label_desc: Use image node_id 2 for calling the Sem2SLS obj's underlying member method code with example usage: obj.whiten(Y) and returns: wexog