aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-09-29 08:37:25 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-09-29 08:40:14 +0200
commit65319a145f12fc76e4f3bffb5f699ec21ba3bccd (patch)
treeef03d1baa55538203c7240bb194d9505eae69e28 /R
parent9fd2aaf94d15f5b11dc28f469909496a361fad71 (diff)
More adaptations to deal with failed saem fits
Diffstat (limited to 'R')
-rw-r--r--R/mhmkin.R10
1 files changed, 8 insertions, 2 deletions
diff --git a/R/mhmkin.R b/R/mhmkin.R
index 17c8a1f7..15c92f3c 100644
--- a/R/mhmkin.R
+++ b/R/mhmkin.R
@@ -168,8 +168,11 @@ print.convergence.mhmkin <- function(x, ...) {
#' @export
AIC.mhmkin <- function(object, ..., k = 2) {
+ if (inherits(object[[1]], "saem.mmkin")) {
+ check_failed <- function(x) if (inherits(x$so, "try-error")) TRUE else FALSE
+ }
res <- sapply(object, function(x) {
- if (inherits(x, "try-error")) return(NA)
+ if (check_failed(x)) return(NA)
else return(AIC(x$so, k = k))
})
dim(res) <- dim(object)
@@ -179,8 +182,11 @@ AIC.mhmkin <- function(object, ..., k = 2) {
#' @export
BIC.mhmkin <- function(object, ...) {
+ if (inherits(object[[1]], "saem.mmkin")) {
+ check_failed <- function(x) if (inherits(x$so, "try-error")) TRUE else FALSE
+ }
res <- sapply(object, function(x) {
- if (inherits(x, "try-error")) return(NA)
+ if (check_failed(x)) return(NA)
else return(BIC(x$so))
})
dim(res) <- dim(object)

Contact - Imprint