class_docstr: Short Panel with general intertemporal within correlation
  
  assumes data is stacked by individuals, panel is balanced and
  within correlation structure is identical across individuals.
  
  It looks like this can just inherit GLS and overwrite whiten
class_docstr_tok: ["Short","Panel","with","general","intertemporal","within","correlation","assumes","data","is","stacked","by","individuals",",","panel","is","balanced","and","within","correlation","structure","is","identical","across","individuals",".","It","looks","like","this","can","just","inherit","GLS","and","overwrite","whiten"]
docstr: Perform an iterative two-step procedure to estimate the GLS model.
  
  Parameters
  ----------
  maxiter : int, optional
      the number of iterations
  
  Notes
  -----
  maxiter=1: returns the estimated based on given weights
  maxiter=2: performs a second estimation with the updated weights,
             this is 2-step estimation
  maxiter>2: iteratively estimate and update the weights
  
  TODO: possible extension stop iteration if change in parameter
      estimates is smaller than x_tol
  
  Repeated calls to fit_iterative, will do one redundant pinv_wexog
  calculation. Calling fit_iterative(maxiter) once does not do any
  redundant recalculations (whitening or calculating pinv_wexog).
docstr_tok: ["Perform","an","iterative","two-step","procedure","to","estimate","the","GLS","model",".","Parameters","--","--","--","--","--","maxiter",":","int",",","optional","the","number","of","iterations","Notes","--","--","-","maxiter=1",":","returns","the","estimated","based","on","given","weights","maxiter=2",":","performs","a","second","estimation","with","the","updated","weights",",","this","is","2-step","estimation","maxiter",">","2",":","iteratively","estimate","and","update","the","weights","TODO",":","possible","extension","stop","iteration","if","change","in","parameter","estimates","is","smaller","than","x_tol","Repeated","calls","to","fit_iterative",",","will","do","one","redundant","pinv_wexog","calculation",".","Calling","fit_iterative","(","maxiter",")","once","does","not","do","any","redundant","recalculations","(","whitening","or","calculating","pinv_wexog",")","."]
code: def fit_iterative(self, maxiter=3):
      """
      Perform an iterative two-step procedure to estimate the GLS model.
  
      Parameters
      ----------
      maxiter : int, optional
          the number of iterations
  
      Notes
      -----
      maxiter=1: returns the estimated based on given weights
      maxiter=2: performs a second estimation with the updated weights,
                 this is 2-step estimation
      maxiter>2: iteratively estimate and update the weights
  
      TODO: possible extension stop iteration if change in parameter
          estimates is smaller than x_tol
  
      Repeated calls to fit_iterative, will do one redundant pinv_wexog
      calculation. Calling fit_iterative(maxiter) once does not do any
      redundant recalculations (whitening or calculating pinv_wexog).
      """
      # Note: in contrast to GLSHet, we do not have an auxiliary regression here
      #      might be needed if there is more structure in cov_i
  
      # because we only have the loop we are not attaching the ols_pooled
      # initial estimate anymore compared to original version
  
      if maxiter < 1:
          raise ValueError("maxiter needs to be at least 1")
  
      import collections
  
      self.history = collections.defaultdict(
          list
      )  # not really necessary
  
      for i in range(maxiter):
          # pinv_wexog is cached, delete it to force recalculation
          if hasattr(self, "pinv_wexog"):
              del self.pinv_wexog
  
          # fit with current cov, GLS, i.e. OLS on whitened endog, exog
          results = self.fit()
          self.history["self_params"].append(results.params)
  
          if (
              not i == maxiter - 1
          ):  # skip for last iteration, could break instead
              # print 'ols',
              self.results_old = (
                  results  # store previous results for debugging
              )
  
              # get cov from residuals of previous regression
              sigma_i = self.get_within_cov(results.resid)
              self.cholsigmainv_i = np.linalg.cholesky(
                  np.linalg.pinv(sigma_i)
              ).T
  
              # calculate new whitened endog and exog
              self.initialize()
  
      # note results is the wrapper, results._results is the results instance
      # results._results.results_residual_regression = res_resid
      return results
  
imports: import numpy
  from statsmodels.regression.linear_model import OLS, GLS
  from statsmodels.tools.grouputils import GroupSorted
label_desc: Use image node_id 7 for calling the ShortPanelGLS obj's underlying member method code with example usage: obj.fit_iterative(maxiter) and returns: results