3

I'm estimating accelerated failure time survival models with time-varying covariates and would like to compute the deviance residuals for my estimated models.

For fixed-time covariates this is easy to achieve with survival::survreg and stats::residuals. Here's an example taken from this webpage (the data is the ovarian dataset included in the survival package):

survregLogLogistic <- survreg(Surv(futime, fustat) ~ ecog.ps + rx, data=ovarian, dist = "loglogistic") devRes <- residuals(survregLogLogistic, type="deviance")

However, survival::survreg cannot handle time-varying covariates (see here for an example of how this type of data can be formatted for survival analysis in R). Because of this I need to use either flexsurv::flexsurvreg or eha::aftreg, as follows (without time-varying covariates but this is enough to reproduce the issue):

flexsurvregLogLogistic <- flexsurvreg(Surv(futime, fustat) ~ ecog.ps + rx, data=ovarian, dist = "llogis")

The estimation works fine but the residuals command does not work (looking closely at the survival::residuals function using methods(residuals) one can see that there is no sub-function for either the flexsurv::flexsurvreg or the eha::aftreg functions). This is the output of the residuals function:

> residuals(flexsurvregLogLogistic, type="deviance")

NULL

And now for eha::aftreg:

aftregLogLogistic <- aftreg(Surv(futime, fustat) ~ ecog.ps + rx, data=ovarian, dist = "loglogistic")

> residuals(aftregLogLogistic, type="deviance")

NULL

How can I compute deviance (or potentially martingale) residuals from either flexsurv::flexsurvreg or eha::aftreg objects?

Lino Ferreira
  • 435
  • 4
  • 13
  • 1
    I have the same problem and I do not know how to solve it. So far, If you write names(aftregLogLogistic), you will see there is no 'residuals' vector. Therefore, the residuals function does not work. – Adrian del rio rodriguez Mar 14 '19 at 14:42

0 Answers0