aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/mhmkin.R39
-rw-r--r--R/status.R43
2 files changed, 43 insertions, 39 deletions
diff --git a/R/mhmkin.R b/R/mhmkin.R
index 47b84b9d..7f3ff9fa 100644
--- a/R/mhmkin.R
+++ b/R/mhmkin.R
@@ -136,45 +136,6 @@ print.mhmkin <- function(x, ...) {
print(status(x))
}
-status.mhmkin <- function(object, ...) {
- if (inherits(object[[1]], "saem.mmkin")) {
- test_func <- function(fit) {
- if (inherits(fit$so, "try-error")) {
- return("E")
- } else {
- if (!is.null(fit$FIM_failed)) {
- return_values <- c("fixed effects" = "Fth",
- "random effects and error model parameters" = "FO")
- return(paste(return_values[fit$FIM_failed], collapse = ", "))
- } else {
- return("OK")
- }
- }
- }
- } else {
- stop("Only mhmkin objects containing saem.mmkin objects currently supported")
- }
- result <- lapply(object, test_func)
- result <- unlist(result)
- dim(result) <- dim(object)
- dimnames(result) <- dimnames(object)
-
- class(result) <- "status.mhmkin"
- return(result)
-}
-
-#' @export
-print.status.mhmkin <- function(x, ...) {
- class(x) <- NULL
- print(x, quote = FALSE)
- cat("\n")
- if (any(x == "OK")) cat("OK: Fit terminated successfully\n")
- if (any(x == "Fth")) cat("Fth: Could not invert FIM for fixed effects\n")
- if (any(x == "FO")) cat("FO: Could not invert FIM for random effects and error model parameters\n")
- if (any(x == "Fth, FO")) cat("Fth, FO: Could not invert FIM for fixed effects, nor for random effects and error model parameters\n")
- if (any(x == "E")) cat("E: Error\n")
-}
-
#' @export
AIC.mhmkin <- function(object, ..., k = 2) {
if (inherits(object[[1]], "saem.mmkin")) {
diff --git a/R/status.R b/R/status.R
index 44d2a9bc..8bcd3a16 100644
--- a/R/status.R
+++ b/R/status.R
@@ -68,3 +68,46 @@ print.status.mmkin <- function(x, ...) {
if (any(x == "OK")) cat("OK: No warnings\n")
if (any(x == "E")) cat("E: Error\n")
}
+
+#' @rdname status
+#' @export
+status.mhmkin <- function(object, ...) {
+ if (inherits(object[[1]], "saem.mmkin")) {
+ test_func <- function(fit) {
+ if (inherits(fit$so, "try-error")) {
+ return("E")
+ } else {
+ if (!is.null(fit$FIM_failed)) {
+ return_values <- c("fixed effects" = "Fth",
+ "random effects and error model parameters" = "FO")
+ return(paste(return_values[fit$FIM_failed], collapse = ", "))
+ } else {
+ return("OK")
+ }
+ }
+ }
+ } else {
+ stop("Only mhmkin objects containing saem.mmkin objects currently supported")
+ }
+ result <- lapply(object, test_func)
+ result <- unlist(result)
+ dim(result) <- dim(object)
+ dimnames(result) <- dimnames(object)
+
+ class(result) <- "status.mhmkin"
+ return(result)
+}
+
+#' @rdname status
+#' @export
+print.status.mhmkin <- function(x, ...) {
+ class(x) <- NULL
+ print(x, quote = FALSE)
+ cat("\n")
+ if (any(x == "OK")) cat("OK: Fit terminated successfully\n")
+ if (any(x == "Fth")) cat("Fth: Could not invert FIM for fixed effects\n")
+ if (any(x == "FO")) cat("FO: Could not invert FIM for random effects and error model parameters\n")
+ if (any(x == "Fth, FO")) cat("Fth, FO: Could not invert FIM for fixed effects, nor for random effects and error model parameters\n")
+ if (any(x == "E")) cat("E: Error\n")
+}
+

Contact - Imprint