0

This is my model:

library(eha)
fit.aft <- aftreg(formula = Surv(time, status) ~ age + sex, data = kidney,
                  dist = "lognormal")

however this is what I see if I want to use predict:

predict(fit.aft)

Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "c('aftreg', 'phreg')"

Could someone let me know how to predict in using survival models.

RaphaelS
  • 839
  • 4
  • 14
David
  • 1
  • 1

1 Answers1

0

The survreg function in {survival} fits accelerated failure time models, so:

library(survival)
fit.aft <- survreg(formula = Surv(time, status) ~ age + sex, data = kidney,
                  dist = "lognormal")
predict(fit.aft, type = "lp")

Will predict the linear predictor. If you want survival probability predictions then you have to use other packages, like {pec} or {mlr3proba}.

RaphaelS
  • 839
  • 4
  • 14
  • so, instead of aftreg() i should use survreg, how about proportional hazard? is there another function I should use instead of phreg? Because I am having problem to apply predict to phreg as well. – David Dec 17 '20 at 02:19
  • First of all the problem you have is {eha} doesn't provide a `predict` function, which isn't ideal. What do you want to predict? Probabilities, linear predictors, etc. If you want probabilities then you can use `predictSurvProb` from {ldatools} which only works with `aftreg`. If you want linear predictor then `predict` from {survival}, which also affects the model specification. {eha} is problematic because it lets you fit `phreg` with non PH distributions, e.g. "loglogistic". I suspect they use a similar implementation to my {mlr3proba}, which allows predictions of probs *and* lps. – RaphaelS Dec 17 '20 at 09:32