How can I add the number at risk along the x axis on the Kaplan-Meier
survival curve plots?
The statistical packages that I have at my disposal are SPSS and
MedCalc. Both don't seem to have this proviso and I'll be very
grateful if someone could prove me wrong or point me in the right
direction
Thanks.
Fahim Jafary, MD
Aga Khan University Hospital
Karachi, Pakistan
SPSS can do a lot more than it seems if you program it with Syntax. There is
an SPSS list which busily addresses such questions using Syntax. You can
join it at
http://listserv.uga.edu/cgi-bin/wa?SUBED1=spssx-l&A=1
- beware though, it is a busy list !
I bet R addresses this - confirmation anyone ?
Best Wishes,
Martin
Thanks for your replies. Will check out the listserv you mentioned.
Hope someone else on this group can come up with some more suggestions.
Regards
It is possible to do this within Stata using the -stsatrisk- command.
It is an extension of the -sts- survival command and is one of the free
add-ins, I believe, though was kindly put together last year by Jean
Marie Linhart at Stata Corp after we nagged them. The layout it
provides requires some rejigging and the numbers at risk (and events)
appear within the graph area rather than under the axis, but it can
usually be made to look okay.
Alternatively, I sometimes use the package SCHARP which was written for
meta-analysis, primarily, and produces very nice forest plots. However,
the graphics for survival curves are very good. It can be tricky to
use sometimes and requires very precisely formatted data files. It
needs to be run in conjunction with SAS (it quietly opens SAS).
Finally, many people I now choose to do this manually - list out the
number of patients patients at risk at set timepoints, reshape the list
to be wide and present as a table under a picture of a KM plot from a
stats package of their choice. I find this a little cumbersome, but
many who haven't got used to either of the methods above have
semi-automated themselves this way.
Hope this is may be of some help.
Matt
Matt Sydes
Medical Statistician
MRC Clinical Trials Unit
London, UK
it is also very easy to do with S-plus/R. For example
fits1<-survfit(Surv(stime, primout),type="kaplan-meier")
nrisk1<-c(0,0,0,0,0)
nrisk1[1]<-fits1$n.risk[1]
for(i in 2:length(fits1$n.risk))
{
if(fits1$time[i]<=90) nrisk1[2]<-fits1$n.risk[i]
if(fits1$time[i]<=180) nrisk1[3]<-fits1$n.risk[i]
if(fits1$time[i]<=365) nrisk1[4]<-fits1$n.risk[i]
if(fits1$time[i]<=545) nrisk1[5]<-fits1$n.risk[i]
}
then use
text(0,.2,"# at Risk",cex=.8,adj=0)
text(90,.2,"Day 90",cex=.8,adj=0)
text(1,.19,nrisk1[1],cex=.8,adj=0)
text(90,.19,nrisk1[2],cex=.8,adj=0)
after your plot statement.
if u prefer, one of Dr. Harrell's libraries Hmisc/Design have a
function called survplot() that will do it as well.
Cheers
Peter