How to calculate survival probabilities in R? -


i trying fit parametric survival model. think managed so. however, not succeed in calculating survival probabilities:

library(survival) zaman  <- c(65,156,100,134,16,108,121,4,39,143,56,26,22,1,1,5,65, 56,65,17,7,16,22,3,4,2,3,8,4,3,30,4,43) test <- c(rep(1,17),rep(0,16)) wbc <- c(2.3,0.75,4.3,2.6,6,10.5,10,17,5.4,7,9.4,32,35,100, 100,52,100,4.4,3,4,1.5,9,5.3,10,19,27,28,31,26,21,79,100,100) status <- c(rep(1,33)) data <- data.frame(zaman,test,wbc)  surv3 <- surv(zaman[test==1], status[test==1]) fit3 <- survreg( surv3 ~ log(wbc[test==1]),dist="w") 

on other hand, no problem @ while calculating survival probabilities using kaplan-meier estimation:

fit2 <- survfit(surv(zaman[test==0], status[test==0]) ~ 1) summary(fit2)$surv 

any idea why?

you can predicted probabilities survreg object predict:

predict(fit3) 

if you're interested in combining original data, , in residual , standard errors of predictions, can use augment function in broom package:

library(broom) augment(fit3) 

a full analysis might like:

library(survival) library(broom) data <- data.frame(zaman, test, wbc, status) subdata <- data[data$test == 1, ]  fit3 <- survreg( surv(zaman, status) ~ log(wbc), subdata, dist="w") augment(fit3, subdata) 

with output:

   zaman test    wbc status   .fitted    .se.fit     .resid 1     65    1   2.30      1 115.46728  43.913188 -50.467281 2    156    1   0.75      1 197.05852 108.389586 -41.058516 3    100    1   4.30      1  85.67236  26.043277  14.327641 4    134    1   2.60      1 108.90836  39.624106  25.091636 5     16    1   6.00      1  73.08498  20.029707 -57.084979 6    108    1  10.50      1  55.96298  13.989099  52.037022 7    121    1  10.00      1  57.28065  14.350609  63.719348 8      4    1  17.00      1  44.47189  11.607368 -40.471888 9     39    1   5.40      1  76.85181  21.708514 -37.851810 10   143    1   7.00      1  67.90395  17.911170  75.096054 11    56    1   9.40      1  58.99643  14.848751  -2.996434 12    26    1  32.00      1  32.88935  10.333303  -6.889346 13    22    1  35.00      1  31.51314  10.219871  -9.513136 14     1    1 100.00      1  19.09922   8.963022 -18.099216 15     1    1 100.00      1  19.09922   8.963022 -18.099216 16     5    1  52.00      1  26.09034   9.763728 -21.090343 17    65    1 100.00      1  19.09922   8.963022  45.900784 

in case, .fitted column predicted probabilities.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -