############## Log-rank tests ############ #### Example I: Motor Data (Part II) library(survival) library(MASS) data(motors) attach(motors) # The figure of the Kaplan-Meier estimators (with 95% confidence # intervals) shows that there may be difference in survival # experiences for temperature = 170 and 190, so we only focus # on these two cases. motors2 <- motors[motors$temp==170 | motors$temp==190,] # log-rank test survdiff(Surv(time, cens)~temp, data=motors2) Call: survdiff(formula = Surv(time, cens) ~ temp, data = motors2) N Observed Expected (O-E)^2/E (O-E)^2/V temp=170 10 7 9.74 0.769 6.38 temp=190 10 5 2.26 3.307 6.38 Chisq= 6.4 on 1 degrees of freedom, p= 0.0115 # So there is a significant difference between two survival # experiences for temperature = 170 and 190 at 5% level but not # at 1% level (p-value = 0.0115). #### Example II: VA data (Part II) data(VA) attach(VA) # The figure of the Kaplan-Meier estimators (with 95% confidence # intervals) shows that there may be no difference in survival # experiences for the two treatments because the two confidence # bands overlap substantially, but let's perform a formal test # to confirm this. survdiff(Surv(stime, status)~treat) Call: survdiff(formula = Surv(stime, status) ~ treat) N Observed Expected (O-E)^2/E (O-E)^2/V treat=1 69 64 64.5 0.00388 0.00823 treat=2 68 64 63.5 0.00394 0.00823 Chisq= 0 on 1 degrees of freedom, p= 0.928 # So there is no significant difference between two survival # experiences for the two treatments (p-value = 0.928), as expected.