Solved – log-rank test in R

logrank-testrsurvival

I need to use the survdiff function to statistically compare (using log-rank test) the following survival functions:
(1) Male (Sex=1) and Female (Sex=2)
(2) Patients <= 65 years-old and Patients > 65 years-old

I used the following command

Male <- survdiff(Surv(time,Status)~sex==1,data=myeloma)
Female <- survdiff(Surv(time,Status)~sex==2,data=myeloma)

is that correct ?

Best Answer

The examples provided in ?survdiff are pretty clear. Using some example data included in survival, this

survdiff(Surv(futime, fustat) ~ rx,data=ovarian)

Is testing for a difference in survival between individuals with rx = 1 and rx = 2. For your data, this will compare survival for males versus females

survdiff(Surv(time, Status) ~ sex, data=myeloma)

And this will compare survival for <= 65 versus >65.

survdiff(Surv(time, Status) ~ age, data=myeloma)
Related Question