residuals_liferegr {trtswitch} | R Documentation |
Residuals for Parametric Regression Models for Failure Time Data
Description
Obtains the response, deviance, dfbeta, and likelihood displacement residuals for a parametric regression model for failure time data.
Usage
residuals_liferegr(
object,
type = c("response", "deviance", "dfbeta", "dfbetas", "working", "ldcase", "ldresp",
"ldshape", "matrix"),
collapse = FALSE,
weighted = (type %in% c("dfbeta", "dfbetas"))
)
Arguments
object |
The output from the |
type |
The type of residuals desired, with options including
|
collapse |
Whether to collapse the residuals by |
weighted |
Whether to compute weighted residuals. |
Details
The algorithms follow the residuals.survreg
function in the
survival
package.
Value
Either a vector or a matrix of residuals, depending on the specified type:
-
response
residuals are on the scale of the original data. -
working
residuals are on the scale of the linear predictor. -
deviance
residuals are on the log-likelihood scale. -
dfbeta
residuals are returned as a matrix, where thei
-th row represents the approximate change in the model coefficients resulting from the inclusion of subjecti
. -
dfbetas
residuals are similar todfbeta
residuals, but each column is scaled by the standard deviation of the corresponding coefficient. -
matrix
residuals are a matrix of derivatives of the log-likelihood function. LetL
be the log-likelihood,p
be the linear predictor (X\beta
), ands
belog(\sigma)
. Then the resulting matrix contains six columns:L
,\partial L/\partial p
,\partial^2 L/\partial p^2
,\partial L/\partial s
,\partial^2 L/\partial s^2
, and\partial L^2/\partial p\partial s
. -
ldcase
residulas are likelihood displacement for case weight perturbation. -
ldresp
residuals are likelihood displacement for response value perturbation. -
ldshape
residuals are likelihood displacement related to the shape parameter.
Author(s)
Kaifeng Lu, kaifenglu@gmail.com
References
Escobar, L. A. and Meeker, W. Q. Assessing influence in regression analysis with censored data. Biometrics 1992; 48:507-528.
Examples
library(dplyr)
fit1 <- liferegr(
data = tobin %>% mutate(time = ifelse(durable>0, durable, NA)),
time = "time", time2 = "durable",
covariates = c("age", "quant"), dist = "normal")
resid <- residuals_liferegr(fit1, type = "response")