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
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?