- class surpyval.univariate.regression.proportional_hazards.cox_ph.CoxPH_
Bases:
object- fit(x: ArrayLike, Z: ArrayLike, c: ArrayLike | None = None, n: ArrayLike | None = None, tl: ArrayLike | None = None, method: str = 'breslow', tol: float = 1e-10) SemiParametricRegressionModel
Fits Cox Proportional Hazards model to the provided data.
- Parameters
x (array-like) – The observed times of the events.
Z (array-like) – The covariates of the model.
c (array-like, optional) – The censoring indicator. 0 if observed (event), 1 if right-censored.
n (array-like, optional) – The number of observations at each time point.
tl (array-like, optional) – The left-truncation times of the observations.
method (str, optional) – The method to use for tie handling. Either ‘efron’ or ‘breslow’.
tol (float, optional) – The tolerance for the root finding algorithm.
- Returns
model – The fitted model.
- Return type
SemiParametricProportionalHazardsModel
- fit_from_df(df: pd.DataFrame, x_col: str, Z_cols: str | list[str] | None = None, c_col: str | None = None, n_col: str | None = None, formula: str | None = None, method: str = 'efron') SemiParametricRegressionModel
Fits a Cox PH model using a pandas dataframe as the input.
- Parameters
df (pandas.DataFrame) – The dataframe containing the data.
x_col (str) – The column name of the observed times.
Z_cols (list, optional) – The column names of the covariates.
c_col (str, optional) – The column name of the censoring indicator.
n_col (str, optional) – The column name of the number of observations at each time point.
formula (str, optional) – The formula to use for the model. If not provided, the column names will be used.
method (str, optional) – The method to use for tie handling. Either ‘efron’ or ‘breslow’.
- Returns
model – The fitted model.
- Return type
SemiParametricProportionalHazardsModel