aboutsummaryrefslogtreecommitdiff
path: root/R/llhist.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-09-28 16:34:57 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-09-28 16:34:57 +0200
commit3529f5ff498d7d054c7b1911ddfc4b242902b85d (patch)
tree4c642bfddcc68e353fe75e8037d39ad8f269d56e /R/llhist.R
parent75f361bed527b91bec205c5452add13247760d61 (diff)
Fix handling of multistart fits with failures
Diffstat (limited to 'R/llhist.R')
-rw-r--r--R/llhist.R11
1 files changed, 10 insertions, 1 deletions
diff --git a/R/llhist.R b/R/llhist.R
index b7f6de21..9ddf5b10 100644
--- a/R/llhist.R
+++ b/R/llhist.R
@@ -16,7 +16,16 @@ llhist <- function(object, breaks = "Sturges", lpos = "topleft", main = "", ...)
oldpar <- par(no.readonly = TRUE)
on.exit(par(oldpar, no.readonly = TRUE))
- ll <- sapply(object, logLik)
+ if (inherits(object, "multistart.saem.mmkin")) {
+ llfunc <- function(object) {
+ if (inherits(object$so, "try-error")) return(NA)
+ else return(logLik(object$so))
+ }
+ } else {
+ stop("llhist is only implemented for multistart.saem.mmkin objects")
+ }
+
+ ll <- stats::na.omit(sapply(object, llfunc))
kde <- KernSmooth::bkde(ll)
par(las = 1)

Contact - Imprint