diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-11-04 19:06:27 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-11-04 19:06:27 +0100 |
commit | ba737d366f62460b7ff4702cc6702322ef850027 (patch) | |
tree | bc58072ac61090456d96c1fc4bcae86724f1c655 /R/anova.saem.mmkin.R | |
parent | 9d013773edc0dc30a98c6218655726d3ad944e3f (diff) |
Fix anova.saem.mmkin for unavailable likelihoods
Diffstat (limited to 'R/anova.saem.mmkin.R')
-rw-r--r-- | R/anova.saem.mmkin.R | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/R/anova.saem.mmkin.R b/R/anova.saem.mmkin.R index 00ddc0c3..7e5fc80a 100644 --- a/R/anova.saem.mmkin.R +++ b/R/anova.saem.mmkin.R @@ -56,13 +56,19 @@ anova.saem.mmkin <- function(object, ..., model.names <- paste0("MODEL",seq_along(model.names)) } names(mods) <- model.names + mods <- mods[successful] - llks <- lapply(model.names[successful], function(x) { - llk <- try(logLik(mods[[x]], method = method)) - if (inherits(llk, "try-error")) - stop("Could not obtain log likelihood with '", method, "' method for ", x) + llks <- lapply(names(mods), function(x) { + llk <- try(logLik(mods[[x]], method = method), silent = TRUE) + if (inherits(llk, "try-error")) { + warning("Could not obtain log likelihood with '", method, "' method for ", x) + llk <- NA + } return(llk) }) + available <- !sapply(llks, is.na) + llks <- llks[available] + mods <- mods[available] # Order models by increasing degrees of freedom: npar <- vapply(llks, attr, FUN.VALUE=numeric(1), "df") |