R: Predictions for a Cox model

predict.coxph {survival} | R Documentation

## Predictions for a Cox model

### Description

Compute fitted values and regression terms for a model fitted by `coxph`

### Usage

    ## S3 method for class 'coxph'
    predict(object, newdata,
    type=c("lp", "risk", "expected", "terms"),
    se.fit=FALSE, na.action=na.pass, terms=names(object$assign), collapse,
    reference=c("strata", "sample"),  ...)

### Arguments

`object` | the results of a coxph fit.
`newdata` | Optional new data at which to do predictions. If absent predictions are for the data frame used in the original fit.
`type` | the type of predicted value. Choices are the linear predictor (`"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"`).
`se.fit` | if TRUE, pointwise standard errors are produced for the predictions.
`na.action` | applies only when the `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.
`terms` | if type="terms", this argument can be used to specify which terms should be included; the default is all.
`collapse` | optional vector of subject identifiers. If specified, the output will contain one entry per subject rather than one entry per observation.
`reference` | reference for centering predictions
`...` | For future methods

### Details

The Cox model is a relative risk model; predictions of type "linear predictor", "risk", and "terms" are all relative to the sample from which they came. By default, the reference value for each of these is the mean covariate within strata. The primary underlying reason is statistical: a Cox model only predicts relative risks between pairs of subjects within the same strata, and hence the addition of a constant to any covariate, either overall or only within a particular stratum, has no effect on the fitted results. Using the `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 "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.

### Value

a vector or matrix of predictions, or a list containing the predictions (element "fit") and their standard errors (element "se.fit") if the se.fit option is TRUE.

### See Also

`predict`,`coxph`,`termplot`

### Examples

    fit <- coxph(Surv(time, status) ~ age + ph.ecog + strata(inst), lung)
    mresid <- lung$status - 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)

[Package survival version 2.36-14 Index]