docstr: diagonal of hat matrix
  
  diag(X' xpxi X)
  
  where xpxi = (X'X + sigma2_e * lambd * sigma_prior)^{-1}
  
  Notes
  -----
  
  uses wexog, so this includes weights or sigma - check this case
  
  not clear whether I need to multiply by sigmahalf, i.e.
  
  (W^{-0.5} X) (X' W X)^{-1} (W^{-0.5} X)'  or
  (W X) (X' W X)^{-1} (W X)'
  
  projection y_hat = H y    or in terms of transformed variables (W^{-0.5} y)
  
  might be wrong for WLS and GLS case
docstr_tok: ["diagonal","of","hat","matrix","diag","(","X","'","xpxi","X",")","where","xpxi","=","(","X","'","X","+","sigma2_e","*","lambd","*","sigma_prior",")","^","{","-1","}","Notes","--","--","-","uses","wexog",",","so","this","includes","weights","or","sigma","-","check","this","case","not","clear","whether","I","need","to","multiply","by","sigmahalf",",","i.e",".","(","W^","{","-0.5","}","X",")","(","X","'","W","X",")","^","{","-1","}","(","W^","{","-0.5","}","X",")","'","or","(","W","X",")","(","X","'","W","X",")","^","{","-1","}","(","W","X",")","'","projection","y_hat","=","H","y","or","in","terms","of","transformed","variables","(","W^","{","-0.5","}","y",")","might","be","wrong","for","WLS","and","GLS","case"]
code: def hatmatrix_diag(self):
      """diagonal of hat matrix
  
      diag(X' xpxi X)
  
      where xpxi = (X'X + sigma2_e * lambd * sigma_prior)^{-1}
  
      Notes
      -----
  
      uses wexog, so this includes weights or sigma - check this case
  
      not clear whether I need to multiply by sigmahalf, i.e.
  
      (W^{-0.5} X) (X' W X)^{-1} (W^{-0.5} X)'  or
      (W X) (X' W X)^{-1} (W X)'
  
      projection y_hat = H y    or in terms of transformed variables (W^{-0.5} y)
  
      might be wrong for WLS and GLS case
      """
      # TODO is this still correct with sandwich normalized_cov_params, I guess not
      xpxi = self.model.normalized_cov_params
      # something fishy with self.normalized_cov_params in result, does not update
      # print(self.model.wexog.shape, np.dot(xpxi, self.model.wexog.T).shape
      return (
          self.model.wexog * np.dot(xpxi, self.model.wexog.T).T
      ).sum(1)
  
imports: from statsmodels.compat.python import lrange
  import numpy
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.regression.linear_model import OLS, GLS, RegressionResults
  from statsmodels.regression.feasible_gls import atleast_2dcols
label_desc: Use image node_id 2 for calling the TheilRegressionResults obj's underlying member method code with example usage: obj.hatmatrix_diag() and returns: unknown