[R] Show number at risk on Kaplan Meier curve

Charles C. Berry cberry at tajo.ucsd.edu
Sat Dec 9 21:56:54 CET 2006


On Sat, 9 Dec 2006, Mark Wardle wrote:

> Dear all,
>
> I'm using the "survival" package with R 2.4.0 on Mac OS X 10.4.8.
>
> I have two core statistics books (one of which is Altman's medical stats
> book) which suggest showing the number of individuals at risk at
> different time intervals on the Kaplan-Meier curve.
>
> My plot shows two curves that later cross, because of one significant
> outlier.
>
> I have two queries:
>
> Is there an easy way of displaying number of individuals at risk at a
> specific time interval?
>
> Is there a way to stop plotting when the number of individuals at risk
> reaches a certain minimum threshold to reduce the risk of such an
> outlier problem?

The R questions are easily answered.

-------------
Look at

 	?survfit.object

These commands will plot while the risk set exceeds 5 and indicate at the 
bottom what the risk set sizes are at each step.

> fit <- survfit(Surv(time, status) ~ 1, data = aml)
> plot(fit, xlim=c(0, max(fit$time[fit$n.risk>=5])-0.5 ) )
> text( fit$time, 0, format(fit$n.risk), cex = 0.7 )

-------------

However, as to whether this 'reduces the risk of an outlier problem', 
failing to show what you think of as an 'outlier' may not be good 
statistical practice. Some treatments do indeed have crossing survival 
curves, and your 'outlier' may be the tip of an unexpected, emerging 
(albeit dimly perceived) iceberg.

HTH

> 
>
> If there is no easy solution, then I suppose I shall have to perform the
> logic myself, calculating when individuals "drop out", and overlaying
> that onto the plot?
>
> Many thanks,
>
> Mark
>
> -- 
> Specialist Registrar and Clinical Research Fellow,
> Department of Neurology, Cardiff University, UK
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                        (858) 534-2098
                                          Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	         UC San Diego
http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0717




More information about the R-help mailing list