aboutsummaryrefslogtreecommitdiff
path: root/R/anova.saem.mmkin.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-11-04 19:06:27 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2022-11-04 19:06:27 +0100
commitba737d366f62460b7ff4702cc6702322ef850027 (patch)
treebc58072ac61090456d96c1fc4bcae86724f1c655 /R/anova.saem.mmkin.R
parent9d013773edc0dc30a98c6218655726d3ad944e3f (diff)
Fix anova.saem.mmkin for unavailable likelihoods
Diffstat (limited to 'R/anova.saem.mmkin.R')
-rw-r--r--R/anova.saem.mmkin.R14
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")

Contact - Imprint