class_docstr: Cox Proportional Hazards Regression Model
  
  The Cox PH Model is for right censored data.
  
  Parameters
  ----------
  endog : array_like
      The observed times (event or censoring)
  exog : 2D array_like
      The covariates or exogeneous variables
  status : array_like
      The censoring status values; status=1 indicates that an
      event occurred (e.g. failure or death), status=0 indicates
      that the observation was right censored. If None, defaults
      to status=1 for all cases.
  entry : array_like
      The entry times, if left truncation occurs
  strata : array_like
      Stratum labels.  If None, all observations are taken to be
      in a single stratum.
  ties : str
      The method used to handle tied times, must be either 'breslow'
      or 'efron'.
  offset : array_like
      Array of offset values
  missing : str
      The method used to handle missing data
  
  Notes
  -----
  Proportional hazards regression models should not include an
  explicit or implicit intercept.  The effect of an intercept is
  not identified using the partial likelihood approach.
  
  `endog`, `event`, `strata`, `entry`, and the first dimension
  of `exog` all must have the same length
class_docstr_tok: ["Cox","Proportional","Hazards","Regression","Model","The","Cox","PH","Model","is","for","right","censored","data",".","Parameters","--","--","--","--","--","endog",":","array_like","The","observed","times","(","event","or","censoring",")","exog",":","2D","array_like","The","covariates","or","exogeneous","variables","status",":","array_like","The","censoring","status","values",";","status=1","indicates","that","an","event","occurred","(","e.g",".","failure","or","death",")",",","status=0","indicates","that","the","observation","was","right","censored",".","If","None",",","defaults","to","status=1","for","all","cases",".","entry",":","array_like","The","entry","times",",","if","left","truncation","occurs","strata",":","array_like","Stratum","labels",".","If","None",",","all","observations","are","taken","to","be","in","a","single","stratum",".","ties",":","str","The","method","used","to","handle","tied","times",",","must","be","either","'breslow'","or","'efron","'",".","offset",":","array_like","Array","of","offset","values","missing",":","str","The","method","used","to","handle","missing","data","Notes","--","--","-","Proportional","hazards","regression","models","should","not","include","an","explicit","or","implicit","intercept",".","The","effect","of","an","intercept","is","not","identified","using","the","partial","likelihood","approach",".","`","endog","`",",","`","event","`",",","`","strata","`",",","`","entry","`",",","and","the","first","dimension","of","`","exog","`","all","must","have","the","same","length"]
docstr: Returns a covariance matrix for the proportional hazards model
  regresion coefficient estimates that is robust to certain
  forms of model misspecification.
  
  Parameters
  ----------
  params : ndarray
      The parameter vector at which the covariance matrix is
      calculated.
  
  Returns
  -------
  The robust covariance matrix as a square ndarray.
  
  Notes
  -----
  This function uses the `groups` argument to determine groups
  within which observations may be dependent.  The covariance
  matrix is calculated using the Huber-White "sandwich" approach.
docstr_tok: ["Returns","a","covariance","matrix","for","the","proportional","hazards","model","regresion","coefficient","estimates","that","is","robust","to","certain","forms","of","model","misspecification",".","Parameters","--","--","--","--","--","params",":","ndarray","The","parameter","vector","at","which","the","covariance","matrix","is","calculated",".","Returns","--","--","--","-","The","robust","covariance","matrix","as","a","square","ndarray",".","Notes","--","--","-","This","function","uses","the","`","groups","`","argument","to","determine","groups","within","which","observations","may","be","dependent",".","The","covariance","matrix","is","calculated","using","the","Huber-White","``","sandwich","''","approach","."]
code: def robust_covariance(self, params):
      """
      Returns a covariance matrix for the proportional hazards model
      regresion coefficient estimates that is robust to certain
      forms of model misspecification.
  
      Parameters
      ----------
      params : ndarray
          The parameter vector at which the covariance matrix is
          calculated.
  
      Returns
      -------
      The robust covariance matrix as a square ndarray.
  
      Notes
      -----
      This function uses the `groups` argument to determine groups
      within which observations may be dependent.  The covariance
      matrix is calculated using the Huber-White "sandwich" approach.
      """
  
      if self.groups is None:
          raise ValueError(
              "`groups` must be specified to calculate the robust covariance matrix"
          )
  
      hess = self.hessian(params)
  
      score_obs = self.score_residuals(params)
  
      # Collapse
      grads = {}
      for i, g in enumerate(self.groups):
          if g not in grads:
              grads[g] = 0.0
          grads[g] += score_obs[i, :]
      grads = np.asarray(list(grads.values()))
  
      mat = grads[None, :, :]
      mat = mat.T * mat
      mat = mat.sum(1)
  
      hess_inv = np.linalg.inv(hess)
      cmat = np.dot(hess_inv, np.dot(mat, hess_inv))
  
      return cmat
  
imports: import numpy
  from statsmodels.base import model
  import statsmodels.base.model
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.compat.pandas import Appender
label_desc: Use image node_id 14 for calling the PHReg obj's underlying member method code with example usage: obj.robust_covariance(params) and returns: cmat