Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPH Model full likelihood estimation #812

Closed
sursu opened this issue Aug 27, 2019 · 2 comments
Closed

CPH Model full likelihood estimation #812

sursu opened this issue Aug 27, 2019 · 2 comments
Labels

Comments

@sursu
Copy link

@sursu sursu commented Aug 27, 2019

As I understand, CPH Models are estimated in 2 steps:

  1. Estimation of the regression parameters from the partial likelihood
  2. Compute the baseline hazard rates [using Breslow (1974) or Kaplan&Meier(1958)]

Alternatively, this can be done in one step using a full likelihood estimation if the baseline hazard function can be parameterized. Popular examples are the exponential, Weibull, and Gompertz distributions.

This is a suggestion to include these distributions in the CoxPHFitter, and add a new argument which would specify the distribution of the baseline hazard function. If passed then use the full likelihood estimation approach, else do it in 2 steps.


This statement may be used to test the implementation:

CPH models are identical to AFT models if the baseline hazard rate is Weibull distributied in a full likelihood estimation.

@CamDavidsonPilon

This comment has been minimized.

Copy link
Owner

@CamDavidsonPilon CamDavidsonPilon commented Aug 27, 2019

Yea, I really like this addition!

@CamDavidsonPilon

This comment has been minimized.

Copy link
Owner

@CamDavidsonPilon CamDavidsonPilon commented Nov 19, 2019

I believe this is already available in lifelines, using custom models: https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Custom%20Regression%20Models.html

For example, here's a Weibull baseline:

class CPHWeibull(ParametricRegressionFitter):

    _fitted_parameter_names = ["lambda_", "rho_", "beta_"]

    def _cumulative_hazard(self, params, T, Xs):

        lambda_ = np.exp(np.dot(Xs["lambda_"], params["lambda_"]))
        rho_ = np.exp(np.dot(Xs["rho_"], params["rho_"]))
        weibull_baseline = (T / lambda_)**rho_ 

        ph = np.exp(np.dot(Xs["beta_"], params["beta_"]))

        return weibull_baseline * ph


cph = CPHWeibull(penalizer=.1)

rossi = load_rossi()
rossi["intercept"] = 1.0

covariates = {"beta_": rossi.columns, "rho_": ["intercept"], "lambda_": rossi.columns[1::2]}

cph.fit(rossi, "week", event_col="arrest", regressors=covariates, timeline=np.arange(250))
cph.print_summary(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.