x=TRUE, y=TRUE were specified to
cph,
confidence limits use the correct formula for any combination of
predictors. Otherwise, if
surv=TRUE was specified to
cph,
confidence limits are based only on standard errors of
log(-log
S(t)) at the mean value of X beta. If the model
contained only stratification factors, or if predictions are being
requested near the mean of each covariable, this approximation will be
accurate. Unless
times is given, at most one observation may be
predicted.
survest(fit, ...)
## S3 method for class 'cph':
survest(fit, newdata, linear.predictors, x, times,
fun, loglog=FALSE, conf.int=0.95, type, vartype,
conf.type=c("log-log", "log", "plain", "none"), se.fit=TRUE,
what=c('survival','parallel'),
individual=FALSE, ...)
cph
newdata,
linear.predictors, or
x may be specified. If none is
specified, but
times is specified, you will get survival
predictions at all subjects' linear predictor and strata values.
TRUE to make the
log-log transformation of survival estimates
and confidence limits.
loglog
is a special case)
FALSE or
0 to suppress confidence limits, or e.g.
.95 to
cause 0.95 confidence limits to be computed
survfit.coxph
survfit.coxph
"log-log",
the default, is the most natural basis.
TRUE to get standard errors of log-log predicted survival
(no matter what
conf.type is).
If
FALSE, confidence limits are suppressed.
TRUE to have
survfit interpret
newdata as
specifying a covariable path for a single individual (represented by
multiple records).
what="survival" to estimate survival probabilities at
times that may not correspond to the subjects' own times.
what="parallel" assumes that the length of
times is the number of
subjects (or one), and causes
survest to estimate the ith subject's survival
probability at the ith value of
times (or at the scalar value of
times).
what="parallel" is used by
val.surv for example.
The result is passed through
naresid if
newdata,
linear.predictors
, and
x are not specified, to restore
placeholders for
NAs.
times is omitted, returns a list with the elements
time
,
n.risk,
n.event,
surv,
call
(calling statement), and optionally
std.err,
upper,
lower
,
conf.type,
conf.int. The estimates in this
case correspond to one subject. If
times is specified, the
returned list has possible components
time,
surv,
std.err
,
lower, and
upper. These will be matrices
(except for
time) if more than one subject is being predicted,
with rows representing subjects and columns representing
times.
If
times has only one time, these are reduced to vectors with
the number of elements equal to the number of subjects.
Frank Harrell
Department of Biostatistics
Vanderbilt University
f.harrell@vanderbilt.edu
# Simulate data from a population model in which the log hazard
# function is linear in age and there is no age x sex interaction
# Proportional hazards holds for both variables but we
# unnecessarily stratify on sex to see what happens
n <- 1000
set.seed(731)
age <- 50 + 12*rnorm(n)
label(age) <- "Age"
sex <- factor(sample(c('Male','Female'), n, TRUE))
cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt <- -log(runif(n))/h
label(dt) <- 'Follow-up Time'
e <- ifelse(dt <= cens,1,0)
dt <- pmin(dt, cens)
units(dt) <- "Year"
dd <- datadist(age, sex)
options(datadist='dd')
Srv <- Surv(dt,e)
f <- cph(Srv ~ age*strat(sex), x=TRUE, y=TRUE) #or surv=T
survest(f, expand.grid(age=c(20,40,60),sex=c("Male","Female")),
times=c(2,4,6), conf.int=.9)
f <- update(f, surv=TRUE)
lp <- c(0, .5, 1)
f$strata # check strata names
attr(lp,'strata') <- rep(1,3) # or rep('sex=Female',3)
survest(f, linear.predictors=lp, times=c(2,4,6))
options(datadist=NULL)