plot.survfit
.## S3 method for class 'survfit':
lines(x, type="s", mark=3, col=1, lty=1,
lwd=1, mark.time=TRUE , xscale=1, firstx=0, firsty=1, xmax, fun, conf.int=FALSE, ...)
## S3 method for class 'survfit':
points(x, ...)
survfit
or survexp
functions.lines
. The default is a step function
for survfit
objects, and a connected line for survexp
objects.FALSE
, no labeling is done.
If TRUE
, then curves are marked at each censoring time.
If mark.time
is a numeric vector, then curves are marked at
the specified time pointsNA
or lines
xlim
graphical parameter, warning messages about out of bounds points are
not generated.fun=log
is an alternative way to draw a log-survival curve
(but with the axis labeled with log(S) values).
Four often used transformations can be specified wit"only"
, then only the CI bands are plotted, and the curve
itself is left off.
This can be useful for fine control over the colors or line types of a plot.x
and y
, containing the coordinates of the
last point on each of the curves (but not of the confidence limits).
This may be useful for labeling.lines
, par
, plot.survfit
, survfit
, survexp
.fit <- survfit(Surv(time, status) ~ sex, pbc,subset=1:312)
plot(fit, mark.time=FALSE, xscale=365.24,
xlab='Years', ylab='Survival')
lines(fit[1], lwd=2, xscale=365.24) #darken the first curve and add marks
# add expected survival curves for the two groups,
# based on the US census data
tdata <- data.frame(age=pbc$age*365.24, sex=pbc$sex +1,
year= rep(mdy.date(1,1,1976), nrow(pbc)))
tdata<-tdata[1:312,] ## only the randomised people, with no missing data
efit <- survexp(~ sex+ratetable(sex=sex,age=age,year=year), data=tdata, ratetable=survexp.us, times=(0:24)*182)
temp <- lines(efit, lty=2, xscale=365.24, lwd=2:1)
text(temp, c("Male", "Female"), adj= -.1) #labels just past the ends
title(main="Primary Biliary Cirrhosis, Observed and Expected")
Run the code above in your browser using DataLab