class_docstr: Class to contain results of fitting a Cox proportional hazards
  survival model.
  
  PHregResults inherits from statsmodels.LikelihoodModelResults
  
  Parameters
  ----------
  See statsmodels.LikelihoodModelResults
  
  Attributes
  ----------
  model : class instance
      PHreg model instance that called fit.
  normalized_cov_params : ndarray
      The sampling covariance matrix of the estimates
  params : ndarray
      The coefficients of the fitted model.  Each coefficient is the
      log hazard ratio corresponding to a 1 unit difference in a
      single covariate while holding the other covariates fixed.
  bse : ndarray
      The standard errors of the fitted parameters.
  
  See Also
  --------
  statsmodels.LikelihoodModelResults
class_docstr_tok: ["Class","to","contain","results","of","fitting","a","Cox","proportional","hazards","survival","model",".","PHregResults","inherits","from","statsmodels.LikelihoodModelResults","Parameters","--","--","--","--","--","See","statsmodels.LikelihoodModelResults","Attributes","--","--","--","--","--","model",":","class","instance","PHreg","model","instance","that","called","fit",".","normalized_cov_params",":","ndarray","The","sampling","covariance","matrix","of","the","estimates","params",":","ndarray","The","coefficients","of","the","fitted","model",".","Each","coefficient","is","the","log","hazard","ratio","corresponding","to","a","1","unit","difference","in","a","single","covariate","while","holding","the","other","covariates","fixed",".","bse",":","ndarray","The","standard","errors","of","the","fitted","parameters",".","See","Also","--","--","--","--","statsmodels.LikelihoodModelResults"]
docstr: A matrix containing the Schoenfeld residuals.
  
  Notes
  -----
  Schoenfeld residuals for censored observations are set to zero.
docstr_tok: ["A","matrix","containing","the","Schoenfeld","residuals",".","Notes","--","--","-","Schoenfeld","residuals","for","censored","observations","are","set","to","zero","."]
code: def schoenfeld_residuals(self):
      """
      A matrix containing the Schoenfeld residuals.
  
      Notes
      -----
      Schoenfeld residuals for censored observations are set to zero.
      """
  
      surv = self.model.surv
      w_avg = self.weighted_covariate_averages
  
      # Initialize at NaN since rows that belong to strata with no
      # events have undefined residuals.
      sch_resid = np.nan * np.ones(
          self.model.exog.shape, dtype=np.float64
      )
  
      # Loop over strata
      for stx in range(surv.nstrat):
          uft = surv.ufailt[stx]
          exog_s = surv.exog_s[stx]
          time_s = surv.time_s[stx]
          strat_ix = surv.stratum_rows[stx]
  
          ii = np.searchsorted(uft, time_s)
  
          # These subjects are censored after the last event in
          # their stratum, so have empty risk sets and undefined
          # residuals.
          jj = np.flatnonzero(ii < len(uft))
  
          sch_resid[strat_ix[jj], :] = (
              exog_s[jj, :] - w_avg[stx][ii[jj], :]
          )
  
      jj = np.flatnonzero(self.model.status == 0)
      sch_resid[jj, :] = np.nan
  
      return sch_resid
  
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 11 for calling the PHRegResults obj's underlying member method code with example usage: obj.schoenfeld_residuals() and returns: sch_resid