0
$\begingroup$

I am trying to test for the proportional hazards assumption on a time-varying dataset in Python specifically. The lifelines library currently doesn't support this for time-varying data.

How could I test for proportional hazards? What is the difference in how the test is performed with respect to time-varying data vs. non-time-varying data?

Thanks in advance!

$\endgroup$
1
  • $\begingroup$ Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. $\endgroup$
    – Community Bot
    Commented Jul 5, 2023 at 15:46

1 Answer 1

0
$\begingroup$

The author of the Python lifelines package does not allow for predictions from models when there are time-varying covariates. See this answer for his rationale. I'm not sure if that rationale carries over to the evaluation of proportional hazards, too.

The R survival package does allow for PH evaluation via Schoenfeld residuals when there are time-varying covariates. As those residuals are only calculated at event times, in a situation with at most 1 event per individual there should be no theoretical problem with calculating those residuals based on the covariate values in place for each individual at risk at each event time. If there might be more than 1 event per individual then you have to decide whether to treat separate events in the same individual separately or to combine them with the collapse argument to the residuals.coxph() function.

Even the R survival package won't provide a formal test of proportional hazards when you have time-varying coefficients in the model. (As I recall, some early versions did claim to perform such tests, but the results were eventually found to be incorrect.) In that situation, the best you can do is to document that the shape of the time-varying coefficient matches the shape of the estimated pattern of residuals over time.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.