R: Calculate residuals for flexible survival models

residuals.flexsurvreg {flexsurv} | R Documentation

## Calculate residuals for flexible survival models

### Description

Calculates residuals for `flexsurvreg` or `flexsurvspline` model fits.

### Usage

    ## S3 method for class 'flexsurvreg'
    residuals(object, type = "response", ...)

### Arguments

`object` | Output from `flexsurvreg` or `flexsurvspline`, representing a fitted survival model object.
`type` | Character string for the type of residual desired. Currently only `"response"` is supported. More residual types may become available in future versions.
`...` | Not currently used.

### Details

Residuals of `type = "response"` are calculated as the naive difference between the observed survival and the covariate-specific predicted mean survival from `predict.flexsurvreg`, ignoring whether the event time is observed or censored.

### Value

Numeric vector with the same length as `nobs(object)`.

### See Also

`predict.flexsurvreg`

### Examples

    fitg <- flexsurvreg(formula = Surv(futime, fustat) ~ age, data = ovarian, dist = "gengamma")
    residuals(fitg)

[Package flexsurv version 2.1 Index]