survHE icon indicating copy to clipboard operation
survHE copied to clipboard

Possibility to fit "all" models even if they do not converge

Open fthielen opened this issue 1 year ago • 2 comments

Dear Gianluca,

I would love to use survHE::fit.models() to estimate "all possible" models in one go. Similar to:

all_distributions <- c("exponential", "gamma","genf","gengamma","gompertz",
"weibull", "weibullPH","loglogistic","lognormal")

x <- survHE::fit.models(formula=Surv(time,status)~ph.ecog,data=lung,
 distr = all_distributions)

This example works fine, but for some data, some distribution cannot be estimated, resulting in an error. This interrupts the computation, although not being able to fit could as well be a valid outcome of the analysis. Is there a way to not let the estimation stop with an error but instead proceed and leave the place in the result list for the not estimated model empty? (e.g., x$models$exponential "Not estimated").

I wrote my own function using tryCatch(error = function(e) NULL). In this way, the execution is not interrupted.

Best, Frederick

fthielen avatar Jul 14 '22 16:07 fthielen