Residuals for Accelerated failure time model models
Source:R/residual.survreg.R
residual.survreg.RdCompute several types of residuals (censored Z-residuals, Cox–Snell,
martingale, and deviance) for accelerated failure time models fitted
with survreg.
Usage
residual.survreg(
survreg_fit,
newdata,
residual.type = c("censored Z-residual", "Cox-Snell", "martingale", "deviance")
)Arguments
- survreg_fit
A fitted
survregmodel object. The model should be a right-censored survival regression model (i.e., with aSurv(time, status)response), using one of the supported distributions.- newdata
A
data.framecontaining the variables required bysurvreg_fit$terms, including theSurv()response and all covariates. Residuals are evaluated for the observations innewdata.- residual.type
Character string specifying the type of residual to compute. Must be one of
"censored Z-residual","Cox-Snell","martingale", or"deviance". The default is the full vectorc("censored Z-residual", "Cox-Snell", "martingale", "deviance"), but in practice a single value should be supplied.
Value
A numeric matrix of dimension \(n \times 1\), where \(n\) is
the number of observations in newdata. The single column is named
according to residual.type. Several attributes are attached:
Survival.Prob: vector of survival probabilities \(S_i(t_i)\).linear.pred: vector of linear predictors \(\eta_i\).covariates: model matrix of covariates used in the linear predictor.censored.status: event indicator (1 = event, 0 = censored).object.model.frame: themodel.frameconstructed fromsurvreg_fit$termsandnewdata.
Examples
if (FALSE) { # \dontrun{
library(survival)
data(lung)
## Weibull survival regression
fit_weib <- survreg(Surv(time, status) ~ age + sex,
data = lung, dist = "weibull")
## Censored Z-residuals
r_z <- residual.survreg(fit_weib, newdata = lung,
residual.type = "censored Z-residual")
## Cox–Snell residuals
r_cs <- residual.survreg(fit_weib, newdata = lung,
residual.type = "Cox-Snell")
## Martingale residuals
r_m <- residual.survreg(fit_weib, newdata = lung,
residual.type = "martingale")
## Deviance residuals
r_d <- residual.survreg(fit_weib, newdata = lung,
residual.type = "deviance")
} # }