# [R] Comparing two different 'survival' events for the same subject using survdiff?

Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) calum.polwart at nhs.net
Mon Apr 29 10:48:24 CEST 2013

```I have a dataset which for the sake of simplicity has two endpoints.  We would like to test if two different end-points have the same eventual meaning.  To try and take an example that people might understand better:

Lets assume we had a group of subjects who all received a treatment.  The could stop treatment for any reason (side effects, treatment stops working etc).  Getting that data is very easy.  Measuring if treatment stops working is very hard to capture... so we would like to test if duration on treatment (easy) is the same as time to treatment failure (hard).

My data might look like this:

A = c(9.77,  0.43,  0.03,  3.50,  7.07,  6.57,  8.57,  2.30,  6.17,  3.27,  2.57,  0.77)
B = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)  # 1 = yes (censored)
C = c( 9.80,  0.43,  5.93,  8.43,  6.80,  2.60,  8.93,  8.37, 12.23,  5.83, 13.17,  0.77)
D = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) # 1 = yes (censored)
myData = data.frame (TimeOnTx = A, StillOnTx = B, TimeToFailure = C, NotFailed = D)

We can do a survival analysis on those individually:
OnTxFit = survfit (Surv ( TimeOnTx, StillOnTx==0 ) ~ 1 , data = myData)

FailedFit = survfit (Surv ( TimeToFailure , NotFailed==0 ) ~ 1 , data = myData)

plot(OnTxFit)
lines(OnTxFit)

But how can I do a survdiff type of comparison between the two?  Do I have to restructure the data so that Time's are all in one column, Event in another and then a Group to indicate what type of event it is?  Seems a complex way to do it (especially as the dataset is of course more complex than I've just shown)... so I thought maybe I'm missing something...

********************************************************************************************************************

This message may contain confidential information. If yo...{{dropped:19}}

```

More information about the R-help mailing list