residuals.survreg {survival} | R Documentation |

This is a method for the function `residuals`

for objects
inheriting from class `survreg`

.

```
## S3 method for class 'survreg'
residuals(object, type=c("response", "deviance","dfbeta","dfbetas",
"working","ldcase","ldresp","ldshape", "matrix"), rsigma=TRUE,
collapse=FALSE, weighted=FALSE, ...)
```

`object` |
an object inheriting from class |

`type` |
type of residuals, with choices of |

`rsigma` |
include the scale parameters in the variance matrix, when doing computations. (I can think of no good reason not to). |

`collapse` |
optional vector of subject groups. If given, this must be of the same length as the residuals, and causes the result to be per group residuals. |

`weighted` |
give weighted residuals? Normally residuals are unweighted. |

`...` |
other unused arguments |

A vector or matrix of residuals is returned. Response residuals are on the scale of the original data, working residuals are on the scale of the linear predictor, and deviance residuals are on log-likelihood scale. The dfbeta residuals are a matrix, where the ith row gives the approximate change in the coefficients due to the addition of subject i. The dfbetas matrix contains the dfbeta residuals, with each column scaled by the standard deviation of that coefficient.

The matrix type produces a matrix based on derivatives of the log-likelihood
function. Let `L`

be the log-likelihood, `p`

be the linear predictor `X\beta`

,
and `s`

be `\log(\sigma)`

. Then the 6 columns of the matrix are
`L`

, `dL/dp`

,`\partial^2L/\partial p^2`

,
`dL/ds`

, `\partial^2L/\partial s^2`

and
`\partial^2L/\partial p\partial s`

.
Diagnostics based on these quantities
are discussed in the book and article by Escobar and Meeker.
The main ones are the likelihood displacement residuals for perturbation
of a case weight (`ldcase`

), the response value (`ldresp`

),
and the `shape`

.

For a transformed distribution such as the log-normal or Weibull,
matrix residuals are based on the log-likelihood of the transformed data
log(y).
For a monotone function f the density of f(X) is the density of X
divided by the derivative of f (the Jacobian), so subtract log(derivative) from
each uncensored observation's loglik value in order to match the
`loglik`

component of the result. The other colums of the matrix
residual are unchanged by the transformation.

Escobar, L. A. and Meeker, W. Q. (1992).
Assessing influence in regression analysis with censored data.
*Biometrics*
**48**, 507-528.

Escobar, L. A. and Meeker, W. Q. (1998). Statistical Methods for Reliablilty Data. Wiley.

```
fit <- survreg(Surv(futime, death) ~ age + sex, mgus2)
summary(fit) # age and sex are both important
rr <- residuals(fit, type='matrix')
sum(rr[,1]) - with(mgus2, sum(log(futime[death==1]))) # loglik
plot(mgus2$age, rr[,2], col= (1+mgus2$death)) # ldresp
```

[Package *survival* version 3.5-5 Index]