## S3 method for class 'coxph':
residuals(object,
type=c("martingale", "deviance", "score", "schoenfeld",
"dfbeta", "dfbetas", "scaledsch","partial"),
collapse=FALSE, weighted=FALSE, ...)
## S3 method for class 'coxph.null':
residuals(object,
type=c("martingale", "deviance","score","schoenfeld"),
collapse=FALSE, weighted=FALSE, ...)
coxph
, representing a fitted Cox
regression model.
Typically this is the output from the coxph
function."martingale"
, "deviance"
, "score"
, "schoenfeld"
,
"dfbeta"', "dfbetas"
, and "scaledsch"
.
Only enoughcollapse=c(1,1,1, 2, 3,
TRUE
and the model was fit with case weights, then the weighted
residuals are returned.collapse
).
For score residuals it is a matrix
with one row per subject and one column per variable.
The row order will match the input data for the original fit.
For Schoenfeld residuals, the returned object is a matrix with one row
for each event and one column per variable. The rows are ordered by time
within strata, and an attribute strata
is attached that contains the
number of observations in each strata.
The scaled Schoenfeld residuals are used in the cox.zph
function.
The score residuals are each individual's contribution to the score vector.
Two transformations of
this are often more useful: dfbeta
is the approximate change in the
coefficient vector if that observation were dropped,
and dfbetas
is the approximate change in the coefficients, scaled by
the standard error for the coefficients.
coxph
data(heart)
fit <- coxph(Surv(start, stop, event) ~ (age + surgery)* transplant,
data=heart)
mresid <- resid(fit, collapse=heart$id)
Run the code above in your browser using DataLab