Display Survfit survival probabilities by group

I am new to survival analysis and survived in R. I want to extract the probability of survival for 4 groups (diseases) at certain time periods (0.10,20.30 years from the time of diagnosis) in the table. Here is the setup:

fit <- survfit((time=time,event=death)~group) surv.prob <- summary(fit,time=c(0,10,20,30))$surv 

surv.prob contains 16 probabilities, i.e. probability of survival for 4 groups, evaluated in 4 different time periods listed above. I want to create a table as follows:

 Group time.period prob 1 0 0.9 1 10 0.8 1 20 0.7 1 30 0.6 

etc. for all 4 groups.

Any suggestions on how to easily create such a table? I will introduce this command in a loop to evaluate the results using various combinations of covariates. I looked at the $ table in survival, but it looks like only events, medians, etc. Appreciate any help with this.

SC

+6
source share
1 answer

I can do this quite easily with the 'rms' package, which has a survest function:

 install.packages(rms, dependencies=TRUE);require(rms) cfit <- cph(Surv(time, status) ~ x, data = aml, surv=TRUE) survest(cfit, newdata=expand.grid(x=levels(aml$x)) , times=seq(0,50,by=10) )$surv 0 10 20 30 40 50 1 1 0.8690765 0.7760368 0.6254876 0.4735880 0.21132505 2 1 0.7043047 0.5307801 0.3096943 0.1545671 0.02059005 Warning message: In survest.cph(cfit, newdata = expand.grid(x = levels(aml$x)), times = seq(0, : SE and confidence intervals are approximate except at predictor means. Use cph(...,x=TRUE,y=TRUE) (and don't use linear.predictors=) for better estimates. 

With a package excerpt, you can find the processed example on pages 264-265 of Therneau and Grambsch books, but it will still require code to output the values ​​at a specific time.

  fit <- coxph(Surv(time, status) ~ x, data = aml) temp=data.frame(x=levels(aml$x)) expfit <- survfit(fit, temp) plot(expfit, xscale=365.25, ylab="Expected") 

enter image description here

 > expfit$surv 1 2 [1,] 0.9508567 0.88171694 [2,] 0.8975825 0.76343993 [3,] 0.8690765 0.70430463 [4,] 0.8405707 0.64800519 [5,] 0.8105393 0.59170883 [6,] 0.8105393 0.59170883 [7,] 0.7760369 0.53078004 [8,] 0.7057873 0.41876588 [9,] 0.6686309 0.36584513 [10,] 0.6686309 0.36584513 [11,] 0.6254878 0.30969426 [12,] 0.5773770 0.25357160 [13,] 0.5292685 0.20403922 [14,] 0.4735881 0.15456706 [15,] 0.4179153 0.11309373 [16,] 0.3484162 0.07179820 [17,] 0.2113251 0.02059003 [18,] 0.2113251 0.02059003 > expfit$time [1] 5 8 9 12 13 16 18 23 27 28 30 31 33 34 43 [16] 45 48 161 
+4
source

Source: https://habr.com/ru/post/977443/


All Articles