chjackson / flexsurv

The flexsurv R package for flexible parametric survival and multi-state modelling
http://chjackson.github.io/flexsurv/
53 stars 28 forks source link

`coxsnell_flexsurvreg` error when calculating cox-snell residuals for generalized gamma `flexsurvreg` model #157

Closed hezht3 closed 1 year ago

hezht3 commented 1 year ago

Hi Chris,

I would like to reach out for an issue on post-modeling cox-snell residuals for generalized gamma parametric survival model.

I tried several cases, and whenever the model has later entries, I will get the following errors below:

> model <- flexsurvreg(formula = Surv(entry, exit, event) ~ exposure, dist = "gengamma", data = data)
> coxsnell_flexsurvreg(model1)
Error in `[.default`(mf[, 1], , "time") : subscript out of bounds

Checking the source code, the error seems coming from this line:

t <- mf[, 1][, "time"]

Thanks very much!

chjackson commented 1 year ago

Thanks for the report, I think this is now fixed in https://github.com/chjackson/flexsurv-dev/commit/dc2dbabca9b1bfda948641893758163bf170e29e .

hezht3 commented 1 year ago

Thank you so much! This works perfect for my model.