aboutsummaryrefslogtreecommitdiff
path: root/R/summary.mmkin.R
blob: 06472e186e02ac02a95e061fbd7f8e7e713678e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#' Summary method for class "mmkin"
#'
#' Shows status 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),
    status = status(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("\nStatus:\n")
  print(x$status)

  if (any(x$illparms != "")) {
    cat("\nIll-defined parameters:\n")
    print(x$illparms)
  }

  invisible(x)
}

Contact - Imprint