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: Create a proportional hazards regression model from a formula
  and dataframe.
  
  Parameters
  ----------
  formula : str or generic Formula object
      The formula specifying the model
  data : array_like
      The data for the model. See Notes.
  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.
  offset : array_like
      Array of offset values
  subset : array_like
      An array-like object of booleans, integers, or index
      values that indicate the subset of df to use in the
      model. Assumes df is a `pandas.DataFrame`
  ties : str
      The method used to handle tied times, must be either 'breslow'
      or 'efron'.
  missing : str
      The method used to handle missing data
  args : extra arguments
      These are passed to the model
  kwargs : extra keyword arguments
      These are passed to the model with one exception. The
      ``eval_env`` keyword is passed to patsy. It can be either a
      :class:`patsy:patsy.EvalEnvironment` object or an integer
      indicating the depth of the namespace to use. For example, the
      default ``eval_env=0`` uses the calling namespace. If you wish
      to use a "clean" environment set ``eval_env=-1``.
  
  Returns
  -------
  model : PHReg model instance
docstr_tok: ["Create","a","proportional","hazards","regression","model","from","a","formula","and","dataframe",".","Parameters","--","--","--","--","--","formula",":","str","or","generic","Formula","object","The","formula","specifying","the","model","data",":","array_like","The","data","for","the","model",".","See","Notes",".","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",".","offset",":","array_like","Array","of","offset","values","subset",":","array_like","An","array-like","object","of","booleans",",","integers",",","or","index","values","that","indicate","the","subset","of","df","to","use","in","the","model",".","Assumes","df","is","a","`","pandas.DataFrame","`","ties",":","str","The","method","used","to","handle","tied","times",",","must","be","either","'breslow'","or","'efron","'",".","missing",":","str","The","method","used","to","handle","missing","data","args",":","extra","arguments","These","are","passed","to","the","model","kwargs",":","extra","keyword","arguments","These","are","passed","to","the","model","with","one","exception",".","The","``","eval_env","``","keyword","is","passed","to","patsy",".","It","can","be","either","a",":","class",":","`","patsy",":","patsy.EvalEnvironment","`","object","or","an","integer","indicating","the","depth","of","the","namespace","to","use",".","For","example",",","the","default","``","eval_env=0","``","uses","the","calling","namespace",".","If","you","wish","to","use","a","``","clean","''","environment","set","``","eval_env=-1","``",".","Returns","--","--","--","-","model",":","PHReg","model","instance"]
code: def from_formula(
      cls,
      formula,
      data,
      status=None,
      entry=None,
      strata=None,
      offset=None,
      subset=None,
      ties="breslow",
      missing="drop",
      *args,
      **kwargs,
  ):
      """
      Create a proportional hazards regression model from a formula
      and dataframe.
  
      Parameters
      ----------
      formula : str or generic Formula object
          The formula specifying the model
      data : array_like
          The data for the model. See Notes.
      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.
      offset : array_like
          Array of offset values
      subset : array_like
          An array-like object of booleans, integers, or index
          values that indicate the subset of df to use in the
          model. Assumes df is a `pandas.DataFrame`
      ties : str
          The method used to handle tied times, must be either 'breslow'
          or 'efron'.
      missing : str
          The method used to handle missing data
      args : extra arguments
          These are passed to the model
      kwargs : extra keyword arguments
          These are passed to the model with one exception. The
          ``eval_env`` keyword is passed to patsy. It can be either a
          :class:`patsy:patsy.EvalEnvironment` object or an integer
          indicating the depth of the namespace to use. For example, the
          default ``eval_env=0`` uses the calling namespace. If you wish
          to use a "clean" environment set ``eval_env=-1``.
  
      Returns
      -------
      model : PHReg model instance
      """
  
      # Allow array arguments to be passed by column name.
      if isinstance(status, str):
          status = data[status]
      if isinstance(entry, str):
          entry = data[entry]
      if isinstance(strata, str):
          strata = data[strata]
      if isinstance(offset, str):
          offset = data[offset]
  
      import re
  
      terms = re.split(r"[+\-~]", formula)
      for term in terms:
          term = term.strip()
          if term in ("0", "1"):
              import warnings
  
              warnings.warn(
                  "PHReg formulas should not include any '0' or '1' terms"
              )
  
      mod = super().from_formula(
          formula,
          data,
          status=status,
          entry=entry,
          strata=strata,
          offset=offset,
          subset=subset,
          ties=ties,
          missing=missing,
          drop_cols=["Intercept"],
          *args,
          **kwargs,
      )
  
      return mod
  
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 2 for calling the PHReg obj's underlying member method code with example usage: obj.from_formula(cls, formula, data, status, entry, strata, offset, subset, ties, missing) and returns: mod