Closed hfrick closed 2 years ago
Thanks - I think this is now fixed in https://github.com/chjackson/flexsurv-dev/commit/bf7a19bd2a91e426fca707858768786492f2d3e5
Thanks so much! 🙌
@chjackson I think there is still an issue with missing data for predictions of type = "rmst"
:
library(flexsurv)
#> Loading required package: survival
fitw <- flexsurvreg(Surv(futime, fustat) ~ age, data = ovarian, dist = "weibull")
ovarian_miss <- ovarian
ovarian_miss$age[[5]] <- NA
summary(fitw, ovarian_miss, type = 'rmst', t = 500)
#> Error in integrate(fn, start[i], t[i]): non-finite function value
More generally, it seems like the same issue arises for other distributions that have check.{dist}
functions (e.g. check.exp()
).
The post above reveals an issue with missing data being passed on to integrate()
here:
https://github.com/chjackson/flexsurv-dev/blob/bf7a19bd2a91e426fca707858768786492f2d3e5/R/utils.R#L158
Have a go with https://github.com/chjackson/flexsurv-dev/commit/01a79b31e42d0b5fe24a8c81d5ff314ffdffbbe9 - I think I've solved the mentioned problems. Let me know if any others - haven't thoroughly swept all uses of summary functions for NA handling.
I'm working with the current devel version of
flexsurv
and have encountered an error withsummary.flexsurvreg(type = "hazard")
when thenewdata
containsNA
. The error occurs incheck.weibull()
which does not expectNA
in either the shape or scale parameters (and thus theif()
statement fails).https://github.com/chjackson/flexsurv-dev/blob/1a7795ec0b670cff9b8b158d9a47084403e2a403/R/Weibull.R#L31-L36
Created on 2022-02-15 by the reprex package (v2.0.1)