1

I am trying to fit a generalized gamma parametric function on a survival curve via flexsurv package (restricted mean t = 365):

library(dplyr)
library(ggplot2)
library(survival)
library(survminer)
library(survRM2)
library(flexsurv)

DD = c(1:365)
CNSR = rbinom(365, 1, 0.5)
data = as.data.frame(cbind(DD,CNSR))

data$SurvObj <- with(data, Surv(DD, CNSR == 0))
res.ggamma <- tryCatch(flexsurvreg(SurvObj ~ 1, data=data, dist="gengamma"), error = function(e) NA)

I then try to find the restricted mean and the lower and upper confidence intervals:

mean.predicted <- round(rmst_gengamma(365, mu = res.ggamma$res[1, 1], sigma = res.ggamma$res[2, 1], Q = res.ggamma$res[3, 1], start = 0)*12/365, 1)
mean.l95 <- round(rmst_gengamma(365, mu = res.ggamma$res[1, 2], sigma = res.ggamma$res[2, 2], Q = res.ggamma$res[3, 1], start = 0)*12/365, 1)
mean.u95 <- round(rmst_gengamma(365, mu = res.ggamma$res[1, 3], sigma = res.ggamma$res[2, 3], Q = res.ggamma$res[3, 1],  start = 0)*12/365, 1)
summary <- paste(mean.predicted, " (", mean.l95, " - ", mean.u95, ")", sep = "")

For some of the summary outputs with certain data sets, I get something normal looking such as the below:

7.5 (6.3 - 8.2)

But some of the outputs on confidence intervals look really wacky:

7.7 (9.9 - 2.8) [this one I get from the randomly generated dataset in the code above]

I am wondering what's going on here? Does it have to do with the shape parameter? It doesn't happen with any other parametric fitting function (exp, gompertz, etc). When I look at the survival curve raw data, it looks fine (all the lower bound and upper bound points contain the mean number).

somethingstrang
  • 1,079
  • 2
  • 14
  • 29
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Dec 04 '18 at 17:47
  • Ive updated my code to be able to generate a randomly generated input data frame. Please try it – somethingstrang Dec 04 '18 at 18:39
  • Is calculation of upper and lower bound around the mean using the upper and lower bounds of the parameters. something that you can provide theoretic justification for. Looks pretty sketchy to me. – IRTFM Dec 04 '18 at 22:18
  • @42- I don't have theoretical justification. Just trying to figure out how to use GenGamma fitting. I can't find any decent documentation on how this works. For my Q parameter I just use the mean value. But for mu and sigma, wouldn't it make sense to use the corresponding upper and lower parameters? Otherwise how would I even get an upper or lower bound estimate? Or perhaps do you think my sigma parameter should be using the mean estimate everytime as well? Any input is appreciated – somethingstrang Dec 05 '18 at 02:00
  • 1
    Well the first place to start would typically be carefully reading the vignettes that accompany the `flexsurv`-package. – IRTFM Dec 05 '18 at 03:03
  • Hi, I mentioned that I couldn't find good documentation on it. The documentation that is available is very mathematical and kind of goes over my head, https://cran.r-project.org/web/packages/flexsurv/flexsurv.pdf (see page 22). I read some information on wikipedia on generalized gamma, but again it kind of goes over my head. Do you have a good understanding of it? If so, perhaps you can help me break it down? – somethingstrang Dec 05 '18 at 16:46

0 Answers0