R-ers! Referees demand that the line in the KM-curve should be changed to dotted at the point where standarerror is <= 10 %. I don't think it's a good habit but I urgently need to implement such a thing in R with survfit, survplot or another program. They also want numbers at risk below the curve Some help, please.... Fredrik ######################## Fredrik Lundgren fredrik.bg.lundgren at gmail.com Engelbrektsgatan 31 582 21 Link?ping tel 013 - 47 30 117 mob 0706 - 86 39 29 Sommarhus: Ljungn?s 158 380 30 Rockneby 0480 - 650 98
Fredrik Lundgren wrote:> R-ers! > > Referees demand that the line in the KM-curve should be changed to > dotted at the point where standarerror is <= 10 %. I don't think it's > a good habit but I urgently need to implement such a thing in R with > survfit, survplot or another program. They also want numbers at risk > below the curve > > Some help, please.... > > > FredrikNumbers at risk can be done with library(Design) f <- cph(Surv( ) ~ ..., surv=TRUE) survplot(f, n.risk=TRUE, ...) Frank> > > > ######################## > > Fredrik Lundgren > fredrik.bg.lundgren at gmail.com > > Engelbrektsgatan 31 > 582 21 Link?ping > tel 013 - 47 30 117 > mob 0706 - 86 39 29 > > Sommarhus: Ljungn?s 158 > 380 30 Rockneby > 0480 - 650 98 > > ______________________________________________ > R-help at r-project.org 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. >-- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University
> Referees demand that the line in the KM-curve should be changed to > dotted at the point where standarerror is <= 10 %. I don't think it's > a good habit but I urgently need to implement such a thing in R with > survfit, survplot or another program. They also want numbers at risk > below the curveTo get such behaviour you have to "build your own". Here is an example.> fit <- survfit(Surv(time, status) ~1, data=lung) > plot(range(fit$time), range(fit$surv), type='n', xlab="Days") > sum(fit$time < 600)[1] 162> lines(fit$time[1:162], fit$surv[1:162], type='s')> length(fit$time)[1] 186> lines(fit$time[162:186], fit$surv[162:186], type='s', col=2)If you need confidence bands add more lines() for fit$upper and fit$lower. If you have more than one curve to overlay, do the fits separately and add even more lines commands. Now to add number at risk every 200 days:> temp <- summary(fit, times=c(0, 200, 400, 600, 800, 1000)) > text(c(0, 200, 400, 600, 800, 1000), .02, temp$n.risk) > text(c(0, 200, 400, 600, 800, 1000), temp$surv-.05, temp$n.risk) # AlternateI don't see a need to make a fancy function for this, as I expect you will only do it once. Just for my information: which journal came up with this `interesting' idea? Terry Therneau