class_docstr: Seemingly Unrelated Regression
  
  Parameters
  ----------
  sys : list
      [endog1, exog1, endog2, exog2,...] It will be of length 2 x M,
      where M is the number of equations endog = exog.
  sigma : array_like
      M x M array where sigma[i,j] is the covariance between equation i and j
  dfk : None, 'dfk1', or 'dfk2'
      Default is None.  Correction for the degrees of freedom
      should be specified for small samples.  See the notes for more
      information.
  
  Attributes
  ----------
  cholsigmainv : ndarray
      The transpose of the Cholesky decomposition of `pinv_wexog`
  df_model : ndarray
      Model degrees of freedom of each equation. p_{m} - 1 where p is
      the number of regressors for each equation m and one is subtracted
      for the constant.
  df_resid : ndarray
      Residual degrees of freedom of each equation. Number of observations
      less the number of parameters.
  endog : ndarray
      The LHS variables for each equation in the system.
      It is a M x nobs array where M is the number of equations.
  exog : ndarray
      The RHS variable for each equation in the system.
      It is a nobs x sum(p_{m}) array.  Which is just each
      RHS array stacked next to each other in columns.
  history : dict
      Contains the history of fitting the model. Probably not of interest
      if the model is fit with `igls` = False.
  iterations : int
      The number of iterations until convergence if the model is fit
      iteratively.
  nobs : float
      The number of observations of the equations.
  normalized_cov_params : ndarray
      sum(p_{m}) x sum(p_{m}) array
      :math:`\left[X^{T}\left(\Sigma^{-1}\otimes\boldsymbol{I}\right)X\right]^{-1}`
  pinv_wexog : ndarray
      The pseudo-inverse of the `wexog`
  sigma : ndarray
      M x M covariance matrix of the cross-equation disturbances. See notes.
  sp_exog : CSR sparse matrix
      Contains a block diagonal sparse matrix of the design so that
      exog1 ... exogM are on the diagonal.
  wendog : ndarray
      M * nobs x 1 array of the endogenous variables whitened by
      `cholsigmainv` and stacked into a single column.
  wexog : ndarray
      M*nobs x sum(p_{m}) array of the whitened exogenous variables.
  
  Notes
  -----
  All individual equations are assumed to be well-behaved, homoskedastic
  iid errors.  This is basically an extension of GLS, using sparse matrices.
  
  .. math:: \Sigma=\left[\begin{array}{cccc}
            \sigma_{11} & \sigma_{12} & \cdots & \sigma_{1M}\\
            \sigma_{21} & \sigma_{22} & \cdots & \sigma_{2M}\\
            \vdots & \vdots & \ddots & \vdots\\
            \sigma_{M1} & \sigma_{M2} & \cdots & \sigma_{MM}\end{array}\right]
  
  References
  ----------
  Zellner (1962), Greene (2003)
class_docstr_tok: ["Seemingly","Unrelated","Regression","Parameters","--","--","--","--","--","sys",":","list","[","endog1",",","exog1",",","endog2",",","exog2",",","...","]","It","will","be","of","length","2","x","M",",","where","M","is","the","number","of","equations","endog","=","exog",".","sigma",":","array_like","M","x","M","array","where","sigma","[","i",",","j","]","is","the","covariance","between","equation","i","and","j","dfk",":","None",",","'dfk1","'",",","or","'dfk2'","Default","is","None",".","Correction","for","the","degrees","of","freedom","should","be","specified","for","small","samples",".","See","the","notes","for","more","information",".","Attributes","--","--","--","--","--","cholsigmainv",":","ndarray","The","transpose","of","the","Cholesky","decomposition","of","`","pinv_wexog","`","df_model",":","ndarray","Model","degrees","of","freedom","of","each","equation",".","p_","{","m","}","-","1","where","p","is","the","number","of","regressors","for","each","equation","m","and","one","is","subtracted","for","the","constant",".","df_resid",":","ndarray","Residual","degrees","of","freedom","of","each","equation",".","Number","of","observations","less","the","number","of","parameters",".","endog",":","ndarray","The","LHS","variables","for","each","equation","in","the","system",".","It","is","a","M","x","nobs","array","where","M","is","the","number","of","equations",".","exog",":","ndarray","The","RHS","variable","for","each","equation","in","the","system",".","It","is","a","nobs","x","sum","(","p_","{","m","}",")","array",".","Which","is","just","each","RHS","array","stacked","next","to","each","other","in","columns",".","history",":","dict","Contains","the","history","of","fitting","the","model",".","Probably","not","of","interest","if","the","model","is","fit","with","`","igls","`","=","False",".","iterations",":","int","The","number","of","iterations","until","convergence","if","the","model","is","fit","iteratively",".","nobs",":","float","The","number","of","observations","of","the","equations",".","normalized_cov_params",":","ndarray","sum","(","p_","{","m","}",")","x","sum","(","p_","{","m","}",")","array",":","math",":","`","\\left","[","X^","{","T","}","\\left","(","\\Sigma^","{","-1","}","\\otimes\\boldsymbol","{","I","}","\\right",")","X\\right","]","^","{","-1","}","`","pinv_wexog",":","ndarray","The","pseudo-inverse","of","the","`","wexog","`","sigma",":","ndarray","M","x","M","covariance","matrix","of","the","cross-equation","disturbances",".","See","notes",".","sp_exog",":","CSR","sparse","matrix","Contains","a","block","diagonal","sparse","matrix","of","the","design","so","that","exog1","...","exogM","are","on","the","diagonal",".","wendog",":","ndarray","M","*","nobs","x","1","array","of","the","endogenous","variables","whitened","by","`","cholsigmainv","`","and","stacked","into","a","single","column",".","wexog",":","ndarray","M","*","nobs","x","sum","(","p_","{","m","}",")","array","of","the","whitened","exogenous","variables",".","Notes","--","--","-","All","individual","equations","are","assumed","to","be","well-behaved",",","homoskedastic","iid","errors",".","This","is","basically","an","extension","of","GLS",",","using","sparse","matrices",".","..","math",":",":","\\Sigma=\\left","[","\\begin","{","array","}","{","cccc","}","\\sigma_","{","11","}","&","\\sigma_","{","12","}","&","\\cdots","&","\\sigma_","{","1M","}","\\\\","\\sigma_","{","21","}","&","\\sigma_","{","22","}","&","\\cdots","&","\\sigma_","{","2M","}","\\\\","\\vdots","&","\\vdots","&","\\ddots","&","\\vdots\\\\","\\sigma_","{","M1","}","&","\\sigma_","{","M2","}","&","\\cdots","&","\\sigma_","{","MM","}","\\end","{","array","}","\\right","]","References","--","--","--","--","--","Zellner","(","1962",")",",","Greene","(","2003",")"]
docstr: igls : bool
      Iterate until estimates converge if sigma is None instead of
      two-step GLS, which is the default is sigma is None.
  
  tol : float
  
  maxiter : int
  
  Notes
  -----
  This ia naive implementation that does not exploit the block
  diagonal structure. It should work for ill-conditioned `sigma`
  but this is untested.
docstr_tok: ["igls",":","bool","Iterate","until","estimates","converge","if","sigma","is","None","instead","of","two-step","GLS",",","which","is","the","default","is","sigma","is","None",".","tol",":","float","maxiter",":","int","Notes","--","--","-","This","ia","naive","implementation","that","does","not","exploit","the","block","diagonal","structure",".","It","should","work","for","ill-conditioned","`","sigma","`","but","this","is","untested","."]
code: def fit(self, igls=False, tol=1e-5, maxiter=100):
      """
      igls : bool
          Iterate until estimates converge if sigma is None instead of
          two-step GLS, which is the default is sigma is None.
  
      tol : float
  
      maxiter : int
  
      Notes
      -----
      This ia naive implementation that does not exploit the block
      diagonal structure. It should work for ill-conditioned `sigma`
      but this is untested.
      """
  
      if not np.any(self.sigma):
          self.sigma = self._compute_sigma(self.endog, self.exog)
      M = self._M
      beta = np.dot(self.pinv_wexog, self.wendog)
      self._update_history(beta)
      self.iterations += 1
      if not igls:
          sur_fit = SysResults(self, beta, self.normalized_cov_params)
          return sur_fit
  
      conv = self.history["params"]
      while (
          igls
          and (np.any(np.abs(conv[-2] - conv[-1]) > tol))
          and (self.iterations < maxiter)
      ):
          fittedvalues = (self.sp_exog * beta).reshape(M, -1)
          resids = (
              self.endog - fittedvalues
          )  # do not attach results yet
          self.sigma = self._compute_sigma(
              resids
          )  # need to attach for compute?
          self.wendog = self.whiten(self.endog)
          self.wexog = self.whiten(self.sp_exog)
          self.pinv_wexog = np.linalg.pinv(self.wexog)
          self.normalized_cov_params = np.dot(
              self.pinv_wexog, np.transpose(self.pinv_wexog)
          )
          beta = np.dot(self.pinv_wexog, self.wendog)
          self._update_history(beta)
          self.iterations += 1
      sur_fit = SysResults(self, beta, self.normalized_cov_params)
      return sur_fit
  
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 6 for calling the SUR obj's underlying member method code with example usage: obj.fit(igls, tol, maxiter) and returns: sur_fit, sur_fit