From 75f361bed527b91bec205c5452add13247760d61 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 26 Sep 2022 12:46:21 +0200 Subject: Make BIC.mhmkin work with failed fits --- R/mhmkin.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/mhmkin.R b/R/mhmkin.R index 61d67204..b72ae318 100644 --- a/R/mhmkin.R +++ b/R/mhmkin.R @@ -177,7 +177,10 @@ AIC.mhmkin <- function(object, ..., k = 2) { #' @export BIC.mhmkin <- function(object, ...) { - res <- sapply(object, function(x) BIC(x$so)) + res <- sapply(object, function(x) { + if (inherits(x, "try-error")) return(NA) + else return(BIC(x$so, k = k)) + }) dim(res) <- dim(object) dimnames(res) <- dimnames(object) return(res) -- cgit v1.2.1