aboutsummaryrefslogtreecommitdiff
path: root/R/aw.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-09-16 10:12:54 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-09-16 10:12:54 +0200
commit03e1598a3c79911a497758fe382461f288bf05e6 (patch)
tree9b6476bc8e6d2fc9d3a70ad73f20a4ea5d75735b /R/aw.R
parentaf24cde56a49b532d7f65dd199d176e0ce3cac09 (diff)
Diagnostic plots for multistart method
Diffstat (limited to 'R/aw.R')
-rw-r--r--R/aw.R36
1 files changed, 31 insertions, 5 deletions
diff --git a/R/aw.R b/R/aw.R
index f46b20ec..b3992f94 100644
--- a/R/aw.R
+++ b/R/aw.R
@@ -30,6 +30,14 @@
#' @export
aw <- function(object, ...) UseMethod("aw")
+.aw <- function(all_objects) {
+ AIC_all <- sapply(all_objects, AIC)
+ delta_i <- AIC_all - min(AIC_all)
+ denom <- sum(exp(-delta_i/2))
+ w_i <- exp(-delta_i/2) / denom
+ return(w_i)
+}
+
#' @export
#' @rdname aw
aw.mkinfit <- function(object, ...) {
@@ -43,11 +51,7 @@ aw.mkinfit <- function(object, ...) {
}
}
all_objects <- list(object, ...)
- AIC_all <- sapply(all_objects, AIC)
- delta_i <- AIC_all - min(AIC_all)
- denom <- sum(exp(-delta_i/2))
- w_i <- exp(-delta_i/2) / denom
- return(w_i)
+ .aw(all_objects)
}
#' @export
@@ -56,3 +60,25 @@ aw.mmkin <- function(object, ...) {
if (ncol(object) > 1) stop("Please supply an mmkin column object")
do.call(aw, object)
}
+
+#' @export
+#' @rdname aw
+aw.mixed.mmkin <- function(object, ...) {
+ oo <- list(...)
+ data_object <- object$data[c("ds", "name", "time", "value")]
+ for (i in seq_along(oo)) {
+ if (!inherits(oo[[i]], "mixed.mmkin")) stop("Please supply objects inheriting from mixed.mmkin")
+ data_other_object <- oo[[i]]$data[c("ds", "name", "time", "value")]
+ if (!identical(data_object, data_other_object)) {
+ stop("It seems that the mixed.mmkin objects have not all been fitted to the same data")
+ }
+ }
+ all_objects <- list(object, ...)
+ .aw(all_objects)
+}
+
+#' @export
+#' @rdname aw
+aw.multistart <- function(object, ...) {
+ do.call(aw, object)
+}

Contact - Imprint