Greg Whittier
Greg Whittier

Reputation: 3185

R survival package survfit function doesn't use conf.int if conf.int != 0.95 and type = 'interval' or 'interval2'

I can't get survfit to calculate anything other the 95% confidence limits when type='interval' or type='interval2'. I also can't seem to find any bug reports on this issue. Am I using the conf.int argument correctly? I can calculate quantiles with quantile(fit), but would like to be able to use plot(fit) to plot an 80% confidence interval.

> library(survival)
> tdata <- data.frame(time  =c(1,1,1,2,2,2,3,3,3,4,4,4),
+                     status=rep(c(1,0,2),4))
> fit  <- survfit(Surv(time, time, status, type='interval') ~1, 
+               data=tdata, conf.int=0.80)
> fit
Call: survfit(formula = Surv(time, time, status, type = "interval") ~ 
    1, data = tdata, conf.int = 0.8)

records   n.max n.start  events  median 0.95LCL 0.95UCL 
     12      12      12       8       3       2      NA 
> plot(fit) # plots 95% confidence intervals
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] survival_2.37-7

Upvotes: 1

Views: 1257

Answers (1)

S_Hartley
S_Hartley

Reputation: 11

Agreed that type = "interval" requires values for "time" and "time2" whenever status = 3. Nonetheless, the original observation and question is valid. When type = "interval" the survfit function does not respond to the argument conf.int. It returns 95% confidence intervals even when supplied with conf.int = 0.80 ?

Here is example code

tdata <- data.frame(time  =c(1,0,1,0,2,0,3,0,3,1,4,2),
                           time2  =c(1,1,1,2,2,2,3,3,3,4,4,4),
                           status =c(0,3,0,3,0,3,0,3,0,3,0,3)) 
fit  <- survfit(Surv(time, time2, status, type='interval') ~1, 
                           data=tdata, conf.int=0.80)    # requests to calculate 80% confidence intervals 
fit             # returns 95% confidence interval
plot(fit)       # plots 95% confidence intervals

sessionInfo()

R version 4.0.2 (2020-06-22)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] survminer_0.4.9 ggpubr_0.4.0    ggplot2_3.3.5   survival_3.1-12

Upvotes: 1

Related Questions