aboutsummaryrefslogtreecommitdiff
path: root/R/summary.mmkin.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-07-21 17:15:12 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-07-21 17:43:16 +0200
commitb703ee38ffc8877be843cf5a557dd9c32c54f977 (patch)
tree4da8adf610a1e431f514efc256f44bb7abdec4ca /R/summary.mmkin.R
parentad6ef5013dce7ef1ef9bbcadbd278b71da9b6f72 (diff)
Summary method for mmkin objects
Also, add a method for gathering convergence information and a method for gathering information on ill-defined parameters
Diffstat (limited to 'R/summary.mmkin.R')
-rw-r--r--R/summary.mmkin.R56
1 files changed, 56 insertions, 0 deletions
diff --git a/R/summary.mmkin.R b/R/summary.mmkin.R
new file mode 100644
index 00000000..5f4a048b
--- /dev/null
+++ b/R/summary.mmkin.R
@@ -0,0 +1,56 @@
+#' Summary method for class "mmkin"
+#'
+#' Shows convergence information on the [mkinfit] objects contained in the object
+#' and gives an overview of ill-defined parameters calculated by [illparms].
+#'
+#' @param object an object of class [mmkin]
+#' @param x an object of class \code{summary.mmkin}.
+#' @param conf.level confidence level for testing parameters
+#' @param digits number of digits to use for printing
+#' @param \dots optional arguments passed to methods like \code{print}.
+#' @examples
+#'
+#' fits <- mmkin(
+#' c("SFO", "FOMC"),
+#' list("FOCUS A" = FOCUS_2006_A,
+#' "FOCUS C" = FOCUS_2006_C),
+#' quiet = TRUE, cores = 1)
+#' summary(fits)
+#'
+#' @export
+summary.mmkin <- function(object, conf.level = 0.95, ...) {
+
+ ans <- list(
+ err_mod = object[[1, 1]]$err_mod,
+ time = attr(object, "time"),
+ illparms = illparms(object),
+ convergence = convergence(object)
+ )
+
+ class(ans) <- c("summary.mmkin")
+ return(ans)
+}
+
+#' @rdname summary.mmkin
+#' @export
+print.summary.mmkin <- function(x, digits = max(3, getOption("digits") - 3), ...) {
+ if (!is.null(x$err_mod)) {
+ cat("Error model: ")
+ cat(switch(x$err_mod,
+ const = "Constant variance",
+ obs = "Variance unique to each observed variable",
+ tc = "Two-component variance function"), "\n")
+ }
+ cat("Fitted in", x$time[["elapsed"]], "s\n")
+
+ cat("\nConvergence:\n")
+ print(x$convergence)
+
+ if (any(x$illparms != "")) {
+ cat("\nIll-defined parameters:\n")
+ print(x$illparms)
+ }
+
+ invisible(x)
+}
+

Contact - Imprint