CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.34k stars 555 forks source link

clogit, probably requiring new tools #148

Open jeffalstott opened 9 years ago

jeffalstott commented 9 years ago

The Cox proportional hazard model is great. It turns out that it is actually equivalent to a conditional logistic regression, if formatted correctly. In the R package survival, there is a function clogit that does the necessary formatting to run a conditional logistic regression using its coxph function. This is described here: http://stat.ethz.ch/R-manual/R-devel/library/survival/html/clogit.html

If you run a command

cloig(event_in_question ~ predictor1 + predictor2 + strata(group_id), data = df_sample)

It ends up running a coxph command like this:

coxph(formula = Surv(rep(1, number_of_data_points_in_dataset), event_in_question) ~ predictor1 + predictor2 + strata(group_id), data = df_sample, method = "exact")

I was hoping it would be possible to do this in lifelines. However, I think we can't yet. There's the grouping by strata, which I don't think is implemented. Is that true?

Additionally, I think that the the survival object (which in R is the Surv(rep(1, number_of_data_points_in_dataset)) is currently within lifelines. That would be the times and the right censoring columns, if I understand correctly. In this case the times would all be 1 and the right censoring is the object of interest. Do I have that right?

Am I correct that this can't be done yet? How much tweaking would it require?

CamDavidsonPilon commented 9 years ago

Hey @jeffalstott,

There's the grouping by strata, which I don't think is implemented. Is that true?

Correct, there's no stratification in lifelines yet, mostly because I've never needed it! I'll keep it in mind for the next release.

In this case the times would all be 1 and the right censoring is the object of interest. Do I have that right?

Yes, I believe you have that correct.

I'm going to leave this issue open, to remind me to implement strata!

jeffalstott commented 9 years ago

Thanks! The sooner it's implemented the sooner I can leave R behind :)

On Sunday, May 3, 2015, Cameron Davidson-Pilon notifications@github.com wrote:

Hey @jeffalstott https://github.com/jeffalstott,

There's the grouping by strata, which I don't think is implemented. Is that true?

Correct, there's no stratification in lifelines yet, mostly because I've never needed it! I'll keep it in mind for the next release.

In this case the times would all be 1 and the right censoring is the object of interest. Do I have that right?

Yes, I believe you have that correct.

I'm going to leave this issue open, to remind me to implement strata!

— Reply to this email directly or view it on GitHub https://github.com/CamDavidsonPilon/lifelines/issues/148#issuecomment-98484518 .