Cox Proportional Hazards
Hypothesis
The Cox model relies on multiple hypotheses that need to be verified for it to be valid. There are multiple ways to verify each of them. While the solutions to verify these assumptions range from quick approximate checks to sophisticated statistical tests, none are implemented in this library at the moment. Here, you will find an extensive list of these hypotheses along with existing solutions to test them.
Example Notebook
You’ll find here an example notebook displaying how you could use the Cox model using the SurviavlAnalysis class.
Model
- class PyBH.SurvivalAnalysis.pymc_models.Cox(cutpoints, priors=None)[source]
This class defines the Bayesian Cox Proportional Hazard model using the Poisson equivalence (Piecewise Exponential Model).
It models the survival process as a set of Poisson distributions where the expected number of events \(\mu_{ij}\) for patient i in interval j is:
\[\mu_{ij} = \Delta t_{ij} \cdot \lambda_j \cdot \exp(X_i \beta)\]where:
\(\Delta t_{ij}\) is the time (exposure) patient i spent in interval j.
\(\lambda_j\) is the baseline hazard for the interval j.
\(X_i\) is the vector of covariates for patient i.
\(\beta\) is the vector of coefficients (log-hazard ratios) associated
with the covariates.
- Parameters:
cutpoints (list or np.array) – Ordered timepoints defining the intervals for the piecewise constant baseline hazard.
Examples
>>> import pymc >>> import pandas >>> from PyBH.SurvivalAnalysis.SurvivalAnalysis import SurvivalAnalysis >>> from PyBH.SurvivalAnalysis.pymc_models import Cox
>>> # Typical dataset for survival analysis >>> data = pandas.read_csv(pymc.get_data("mastectomy.csv"))
# Define intervals: 0-10, 10-20, 20+ model = Cox(cutpoints=[10, 20])
# Launch analysis analysis = SurvivalAnalysis(model=model,
data=data, time_col=”time”, event_col=”event”,)
# Plot obtained survival function analysis.plot_survival_function()