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","."]
code: def __init__(self, sys, indep_endog=None, instruments=None):
      if len(sys) % 2 != 0:
          raise ValueError(
              "sys must be a list of pairs of endogenous and \
  exogenous variables.  Got length %s"
              % len(sys)
          )
      M = len(sys[1::2])
      self._M = M
      # The lists are probably a bad idea
      self.endog = sys[::2]  # these are just list containers
      self.exog = sys[1::2]
      self._K = [np.linalg.matrix_rank(_) for _ in sys[1::2]]
      #        fullexog = np.column_stack((_ for _ in self.exog))
  
      self.instruments = instruments
  
      # Keep the Y_j's in a container to get IVs
      instr_endog = {}
      [instr_endog.setdefault(_, []) for _ in indep_endog.keys()]
  
      for eq_key in indep_endog:
          for varcol in indep_endog[eq_key]:
              instr_endog[eq_key].append(self.exog[eq_key][:, varcol])
              # ^ copy needed?
      #        self._instr_endog = instr_endog
  
      self._indep_endog = indep_endog
      _col_map = np.cumsum(np.hstack((0, self._K)))  # starting col no.s
      # move this check to whiten since we're not going to build a full exog?
      for eq_key in indep_endog:
          try:
              iter(indep_endog[eq_key])
          except:
              #                eq_key = [eq_key]
              raise TypeError(
                  "The values of the indep_exog dict must be "
                  "iterable. Got type %s for converter %s"
                  % (type(indep_endog[eq_key]), eq_key)
              )
      #            for del_col in indep_endog[eq_key]:
      #                fullexog = np.delete(fullexog,  _col_map[eq_key]+del_col, 1)
      #                _col_map[eq_key+1:] -= 1
  
      # Josef's example for deleting reoccuring "rows"
      #        fullexog = np.unique(fullexog.T.view([('',fullexog.dtype)]*\
      #                fullexog.shape[0])).view(fullexog.dtype).reshape(\
      #                fullexog.shape[0],-1)
      # From http://article.gmane.org/gmane.comp.python.numeric.general/32276/
      # Or Jouni' suggetsion of taking a hash:
      # http://www.mail-archive.com/numpy-discussion@scipy.org/msg04209.html
      # not clear to me how this would work though, only if they are the *same*
      # elements?
      #        self.fullexog = fullexog
      self.wexog = self.whiten(instr_endog)
  
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 1 to create a new Sem2SLS object  with example: obj = Sem2SLS(sys, indep_endog, instruments)