diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-09-29 08:37:25 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-09-29 08:40:14 +0200 |
commit | 65319a145f12fc76e4f3bffb5f699ec21ba3bccd (patch) | |
tree | ef03d1baa55538203c7240bb194d9505eae69e28 /R | |
parent | 9fd2aaf94d15f5b11dc28f469909496a361fad71 (diff) |
More adaptations to deal with failed saem fits
Diffstat (limited to 'R')
-rw-r--r-- | R/mhmkin.R | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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) |