survfit.coxph {survival} | R Documentation |
Computes the predicted survivor function for a Cox proportional hazards model.
## S3 method for class 'coxph' survfit(formula, newdata, se.fit=TRUE, conf.int=.95, individual=FALSE, type,vartype, conf.type=c("log","log-log","plain","none"), censor=TRUE, ...)
formula |
A coxph object.
|
newdata |
a data frame with the same variable names as those that appear
in the coxph formula. It is also valid to use a vector, if
the data frame would consist of a single row.
The curve(s) produced will be representative of a cohort whose
covariates correspond to the values in |
individual |
a logical value indicating whether each row of newdata represents
a distinct individual (FALSE, the default),
or if each row of the data frame represents different
time epochs for only one individual (TRUE).
In the former case the result will have one curve for each row in
newdata , in the latter only a single curve will be produced.
|
conf.int |
the level for a two-sided confidence interval on the survival curve(s). Default is 0.95. |
se.fit |
a logical value indicating whether standard errors should be
computed. Default is TRUE .
|
type,vartype |
a character string specifying the type of survival curve.
Possible values are "aalen" , "efron" , or
"kalbfleish-prentice"
(only the first two characters are necessary).
The default is to match the computation used in the Cox model.
The Nelson-Aalen-Breslow estimate for ties='breslow' , the Efron
estimate for ties='efron' and the Kalbfleisch-Prentice
estimate for a discrete time model ties='exact' .
Variance estimates are the Aalen-Link-Tsiatis, Efron, and
Greenwood.
The default will be the Efron
estimate for ties='efron' and the Aalen estimate otherwise.
|
conf.type |
One of "none" , "plain" , "log" (the default),
or "log-log" . Only
enough of the string to uniquely identify it is necessary.
The first option causes confidence intervals not to be
generated. The second causes the standard intervals
curve +- k *se(curve) , where k is determined from
conf.int . The log option calculates intervals based on the
cumulative hazard or log(survival). The last option bases
intervals on the log hazard or log(-log(survival)).
|
censor |
if FALSE time points at which there are no events (only censoring) are not included in the result. |
... |
for future methods |
Serious thought has been given to removing the ‘default’ for
newdata
, since the resulting curve(s) almost never make sense.
It remains due to the unwarranted attachment to the option shown by
other packages and by users. Two particularly egregious examples
are factor variables and interactions. Suppose one were studying
interspecies transmission of a virus, and the data set has a factor
variable with levels ("pig", "chicken") and about equal numbers of
observations for each. The “mean” covariate level will be 1/2 –
is this a flying pig? As to interactions assume data with sex coded as 0/1,
ages ranging from 50 to 80, and a model with age*sex. The “mean”
value for the age:sex interaction term will be about 30, a value
that does not occur in the data.
Users are strongly advised to use the newdata argument. Note that this data set needs to contain values for the main effects but not for any interaction terms.
When all the coefficients are zero, the Kalbfleisch-Prentice estimator reduces to the Kaplan-Meier, the Aalen estimate to the exponential of Nelson's cumulative hazard estimate, and the Efron estimate to the Fleming-Harrington estimate of survival. The variances of the curves from a Cox model are larger, however, due to the variance of the coefficients.
See survfit
for more details about the counts (number of
events, number at risk, etc.)
The censor argument was fixed at FALSE in earlier versions of the code and not made available to the user.
an object of class "survfit"
.
See survfit.object
for
details. Methods defined for survfit objects are
print
, plot
,
lines
, and points
.
Fleming, T. H. and Harrington, D. P. (1984). Nonparametric estimation of the survival distribution in censored data. Comm. in Statistics 13, 2469-86.
Kablfleisch, J. D. and Prentice, R. L. (1980). The Statistical Analysis of Failure Time Data. New York:Wiley.
Link, C. L. (1984). Confidence intervals for the survival function using Cox's proportional hazards model with covariates. Biometrics 40, 601-610.
Therneau T and Grambsch P (2000), Modeling Survival Data: Extending the Cox Model, Springer-Verlag.
Tsiatis, A. (1981). A large sample study of the estimate for the integrated hazard function in Cox's regression model for survival data. Annals of Statistics 9, 93-108.
print
,
plot
,
lines
,
coxph
,
Surv
,
strata
.
#fit a Kaplan-Meier and plot it fit <- survfit(Surv(time, status) ~ x, data = aml) plot(fit, lty = 2:3) legend(100, .8, c("Maintained", "Nonmaintained"), lty = 2:3) #fit a Cox proportional hazards model and plot the #predicted survival for a 60 year old fit <- coxph(Surv(futime, fustat) ~ age, data = ovarian) plot(survfit(fit, newdata=data.frame(age=60)), xscale=365.25, xlab = "Years", ylab="Survival") # Here is the data set from Turnbull # There are no interval censored subjects, only left-censored (status=3), # right-censored (status 0) and observed events (status 1) # # Time # 1 2 3 4 # Type of observation # death 12 6 2 3 # losses 3 2 0 3 # late entry 2 4 2 5 # tdata <- data.frame(time =c(1,1,1,2,2,2,3,3,3,4,4,4), status=rep(c(1,0,2),4), n =c(12,3,2,6,2,4,2,0,2,3,3,5)) fit <- survfit(Surv(time, time, status, type='interval') ~1, data=tdata, weight=n) # # Time to progression/death for patients with monoclonal gammopathy # Competing risk curves (cumulative incidence) fit1 <- survfit(Surv(stop, event=='progression') ~1, data=mgus1, subset=(start==0)) fit2 <- survfit(Surv(stop, status) ~1, data=mgus1, subset=(start==0), etype=event) #competing risks # CI curves are always plotted from 0 upwards, rather than 1 down plot(fit2, fun='event', xscale=365.25, xmax=7300, mark.time=FALSE, col=2:3, xlab="Years post diagnosis of MGUS") lines(fit1, fun='event', xscale=365.25, xmax=7300, mark.time=FALSE, conf.int=FALSE) text(10, .4, "Competing Risk: death", col=3) text(16, .15,"Competing Risk: progression", col=2) text(15, .30,"KM:prog")