aboutsummaryrefslogtreecommitdiff
path: root/R/anova.saem.mmkin.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-11-04 20:45:52 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2022-11-04 20:45:52 +0100
commit7ec1454c0a0c89987644bbe1981716595d4f1f4b (patch)
treef5194785fb7b0502d80c755043a9e970a1765088 /R/anova.saem.mmkin.R
parentba737d366f62460b7ff4702cc6702322ef850027 (diff)
Further improvement of robustness of anova method
Diffstat (limited to 'R/anova.saem.mmkin.R')
-rw-r--r--R/anova.saem.mmkin.R18
1 files changed, 9 insertions, 9 deletions
diff --git a/R/anova.saem.mmkin.R b/R/anova.saem.mmkin.R
index 7e5fc80a..e2715aa3 100644
--- a/R/anova.saem.mmkin.R
+++ b/R/anova.saem.mmkin.R
@@ -32,15 +32,6 @@ anova.saem.mmkin <- function(object, ...,
mods <- c(list(object), dots[is_model])
successful <- sapply(mods, function(x) !inherits(x$so, "try-error"))
- # Ensure same data, ignoring covariates
- same_data <- sapply(mods[successful], function(x) {
- identical(object$data[c("ds", "name", "time", "value")],
- x$data[c("ds", "name", "time", "value")])
- })
- if (!all(same_data)) {
- stop(sum(!same_data), " objects have not been fitted to the same data")
- }
-
if (is.null(model.names))
model.names <- vapply(as.list(mCall)[c(FALSE, TRUE, is_model)], deparse1, "")
@@ -58,6 +49,15 @@ anova.saem.mmkin <- function(object, ...,
names(mods) <- model.names
mods <- mods[successful]
+ # Ensure same data, ignoring covariates
+ same_data <- sapply(mods[-1], function(x) {
+ identical(mods[[1]]$data[c("ds", "name", "time", "value")],
+ x$data[c("ds", "name", "time", "value")])
+ })
+ if (!all(same_data)) {
+ stop(sum(!same_data), " objects have not been fitted to the same data")
+ }
+
llks <- lapply(names(mods), function(x) {
llk <- try(logLik(mods[[x]], method = method), silent = TRUE)
if (inherits(llk, "try-error")) {

Contact - Imprint