Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I evaluate the Kaplan Meier estimator at specific time points?

I have a Kaplan Meier object from the R package survival. I can plot it and etcetera, but I would like to evaluate it at specific time points.

How can I create a function that evaluates the KM estimator at specific time points using the KM object?

library(survival)


KM <- survfit(Surv(time, status) ~ 1,data = lung)

> KM(1)
Error in KM(1) : could not find function "KM"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use summary() with the times argument:

library(survival)

KM <- survfit(Surv(time, status) ~ 1,data = lung)
summary(KM, times = seq(0, 5) * 90)
#> Call: survfit(formula = Surv(time, status) ~ 1, data = lung)
#> 
#>  time n.risk n.event survival std.err lower 95% CI upper 95% CI
#>     0    228       0    1.000  0.0000        1.000        1.000
#>    90    201      27    0.882  0.0214        0.841        0.925
#>   180    160      36    0.722  0.0298        0.666        0.783
#>   270    108      30    0.575  0.0338        0.513        0.645
#>   360     70      24    0.434  0.0358        0.369        0.510
#>   450     48      16    0.329  0.0356        0.266        0.406
summary(KM, times = seq(0, 5) * 90)$surv
#> [1] 1.0000000 0.8815789 0.7216707 0.5753102 0.4340441 0.3287158
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading