I can't find a way to reproduce the third part of the following link with the lifelines package in python: https://stayconsistent.wordpress.com/2009/01/25/cox-model-and-conditional-logistic-model-back-and-forth/ I have tried with both the Coxph with strata and with a WeibullAFTFitter using interval censor but I couldn't get the expected outcome.

Any intuition on how to calibrate lifelines regression models to reproduce the conditional logistic model in python?



1 Answer 1


I coded up a replica, but I must ask why you are doing this? It's very complicated.

The differences are most likely a result of how the programs handles ties: lifelines only uses Efron-handling of ties, whereas this method requires Exact-handling of ties.

df_ = pd.read_csv("https://gist.githubusercontent.com/CamDavidsonPilon/40c548eadc5c0eb6ad130fac87e2de46/raw/2543730b0e4556d1e59aeaad5d035e1774f8d3c5/test.csv")
df_ = df_.drop(['idcode', 'mygroup', 't0'], axis=1).reset_index(0)

cph = CoxTimeVaryingFitter().fit(df_, id_col='index', start_col='enter', stop_col='_t', event_col='union')

  • $\begingroup$ You are correct. I have created another file this time with only 1 success per group and the result of CoxTimeVaryingFitter match the expected conditional logistic coefficients. Thanks $\endgroup$
    – aiedu
    Dec 12, 2019 at 10:55
  • $\begingroup$ If I may ask an additional question, would it be valid to use a Log Logistic or Weibull AFT with that type of data? $\endgroup$
    – aiedu
    Dec 19, 2019 at 12:42
  • $\begingroup$ Yes, but your new question has nothing to do with the conditional logistic model, right? $\endgroup$ Dec 19, 2019 at 16:07
  • $\begingroup$ Thanks, I guess you are answering the question. It wouldn't then be a conditional Log Logistic model for example? $\endgroup$
    – aiedu
    Dec 20, 2019 at 18:52
  • $\begingroup$ That’s right. They have different likelihoods. $\endgroup$ Dec 20, 2019 at 22:06

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.