1

I'm using flexsurv to compute expected lifetime for a given population by fitting a weibull curve to the data.

library(survival)
library(flexsurv)
data <- read.csv(file)
survival_col = data[["survival"]]
duration_col = data[["duration"]]
w <- flexsurvreg(Surv(duration_col,survival_col) ~ 1,data=data, dist="weibull")

Given w, how can I compute the area under the curve, so to speak, to get the expected lifetime?

Sanatani
  • 61
  • 1
  • 4
  • Try reading this post on [how to make a great r reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), and you may get more helpful answers – De Novo Mar 19 '18 at 22:01
  • You might also take some time going through the vignette included in the package if you haven't done this already. It is well-written and fairly extensive. – lmo Mar 19 '18 at 22:17

1 Answers1

0

You can calculate the expected life time by doing:

lifetimes <- predict(w, type = "response")

See here the documentation for the predict method for flexsurvreg

Iyar Lin
  • 581
  • 4
  • 13