From 7ec1454c0a0c89987644bbe1981716595d4f1f4b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 4 Nov 2022 20:45:52 +0100 Subject: Further improvement of robustness of anova method --- R/anova.saem.mmkin.R | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'R/anova.saem.mmkin.R') 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")) { -- cgit v1.2.1