I have a (probably quite basic) question about survival analysis in R. Let's assume I want to know how long an event typically takes but the process of measurement automatically removes individuals from the trial. I set up a study including 8 participants and measure 4 after 5 years and 4 more after 10 years (this is a hypothetical study - please ignore sample sizes etc). The event has occurred in two of the individuals sampled after five years, and in all the individuals sampled after ten years. So they are right-censored; we will never know how long the event would have taken in the ones which I measure and turn out to be negative.

In R I am coding this as follows:

tStart = c(0, 0, 0, 0, 0, 0, 0, 0) 
tEnd = c(5, 5, 5, 5, 10, 10, 10, 10) 
event = c(0, 0, 1, 1, 1, 1, 1, 1)
sample = data.frame(tStart, tEnd, event)

I want to fit the data to a parametric survival analysis model assuming a Weibull distribution. How do I do this in R? Based on my research so far I assumed I should be using the function survreg in the R package survival.

I thought I would be using:

model_sample <- survfit(Surv(tStart, tEnd,event, type='right')~1,data=sample)

But this throws the error

Error in Surv(tStart, tEnd, event, type = "right") : 
  Wrong number of args for this type of survival data

The example in the help documentation for survreg includes the example (page 6, section 4.2):

Surv(time=2,time2=3, event=3, type = "interval")

...which to me looks identical. Firstly what am I doing wrong currently, and secondly how should I be analysing a dataset of this type?

  • $\begingroup$ Your time-to-event is not continuous. Something you should pay attention to. $\endgroup$
    – ocram
    Aug 17, 2018 at 5:34

1 Answer 1


You are trying to provide data of the 'interval' censoring type (i.e. you have values for the start and end of an interval), yet you specify 'right' censoring in your call to the Surv function, which would only require one time value.

Either specify type = 'interval', or just provide a single vector of times and specify type = 'right', depending on the actual structure of your data and the censoring that is occurring.

Note that the event variable also needs to be coded differently to correspond to the type of censoring being employed. From the documentation for the Surv function:

The status indicator, normally 0=alive, 1=dead... For interval censored data, the status indicator is 0=right censored, 1=event at time, 2=left censored, 3=interval censored.


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.