coxph
# S3 method for coxph
predict(object, newdata,
type=c("lp", "risk", "expected", "terms", "survival"),
se.fit=FALSE, na.action=na.pass, terms=names(object$assign), collapse,
reference=c("strata", "sample"), ...)
"lp"
), the risk score exp(lp)
("risk"
),
the expected number of events given the covariates and follow-up time
("expected"
), and the terms of the linear predictor
("terms"
).
The survival probability for a subject is equal to exp(-expected).
newdata
argument is present, and defines
the missing value action for the new data. The default is to include
all observations.
When there is no newdata, then the behavior of missing is dictated by
the na.action option of the original fit.reference="strata"
option causes this to be true for
predictions as well. When the results of predict
are used in further calculations it
may be desirable to use a fixed reference level.
Use of reference="sample"
will use the overall means, and agrees
with the linear.predictors
component of the coxph object (which
uses the overall mean for backwards compatability with older code).
Predictions of type="terms"
are almost invariably passed
forward to further calculation, so for these we default to using
the sample as the reference. Predictions of type "expected" incorporate the baseline hazard and are
thus absolute instead of relative; the
reference
option has no effect on these. Models that contain a frailty
term are a special case: due
to the technical difficulty, when there is a newdata
argument the
predictions will always be for a random effect of zero.predict
,coxph
,termplot
options(na.action=na.exclude) # retain NA in predictions
fit <- coxph(Surv(time, status) ~ age + ph.ecog + strata(inst), lung)
#lung data set has status coded as 1/2
mresid <- (lung$status-1) - predict(fit, type='expected') #Martingale resid
predict(fit,type="lp")
predict(fit,type="expected")
predict(fit,type="risk",se.fit=TRUE)
predict(fit,type="terms",se.fit=TRUE)
Run the code above in your browser using DataLab