[R] Plotting K-M Curve when have several strata
p.b.pynsent at bham.ac.uk
Fri Mar 28 17:17:55 CET 2003
If you really want to get control of the colours then pick up the
relevant returned values and pass them individually to lines().
foo[] will hold time axis, foo[] and []the upper and lower ci.
I actually feed the ci values into polygon() and am then able to
produce shaded confidence intervals.
fit.r <- survfit(Surv(fuperiod, censor), data=s.data, type=
"kaplan-meier", conf.type="plain", conf.lower="peto")
x <- c(0,fit.r[]) #add at time 0
y <- c(1,fit.r[])
plot(x,y, col="blue",type="n",xlab="Time (years)",ylab="Proportion
xp <- c(x,rev(x))
yp <- c(1,fit.r[],rev(fit.r[]),1)
polygon(xp,yp,density=NULL,col="pink", border= "pink", lwd=0.5)
On Wednesday, March 26, 2003, at 12:13 pm, Ko-Kang Kevin Wang wrote:
> If I have:
> foo <- survfit(y ~ x)
> where y is a survival object and x is a n-level factor. The
> says when I plot(foo), the confidence intervals will not be plotted
> I guess is understandable as otherwise the plot will get really messy).
> I tried to plot with confidence intervals by using:
> plot(foo, conf.int = TRUE)
> and indeed the resulting plot is messy. However I'm just wondering if
> can (suppose x is a 2-level factor) use different colours and line
> for the confidence lines? If I do:
> plot(foo, conf.int = TRUE, col = 1:2)
> then I'll get two different colours. What I would like is to then plot
> the confidence lines using lty = 2 (while keeping the colour).
> Can I do this?
> /* Time is the greatest teacher, unfortunately it kills its students */
> Ko-Kang Kevin Wang
> Master of Science (MSc) Student
> SLC Tutor and Lab Demonstrator
> Department of Statistics
> University of Auckland
> New Zealand
> Homepage: http://www.stat.auckland.ac.nz/~kwan022
> Ph: 373-7599
> x88475 (City)
> x88480 (Tamaki)
> R-help at stat.math.ethz.ch mailing list
Prof. P. B. Pynsent,
Research and Teaching Centre,
Royal Orthopaedic Hospital,
Birmingham, B31 2AP, U.K.
More information about the R-help