R/methods_summary.R

Defines functions print.summary.jsd_ci summary.jsd_ci summary.jsd_estimate

#' @export
summary.jsd_estimate <- function(object, ...) {
  object
}


#' @export
summary.jsd_ci <- function(object, ...) {
  stats <- list(
    estimate = object$estimate,
    conf_int = object$conf_int,
    conf_level = object$conf_level,
    boot_mean = object$boot_mean,
    boot_median = object$boot_median,
    boot_se = object$boot_se,
    boot_bias = object$boot_bias,
    boot_valid_n = object$boot_valid_n,
    type = object$type,
    method = object$method,
    base = object$base
  )

  class(stats) <- "summary.jsd_ci"
  stats
}


#' @export
print.summary.jsd_ci <- function(x, ...) {
  cat("Summary of bootstrap JSD\n")
  cat("Type: ", x$type, "\n", sep = "")
  cat("Method: ", x$method, "\n", sep = "")
  cat("Base: ", x$base, "\n", sep = "")
  cat("Estimate: ", formatC(x$estimate, digits = 6, format = "f"), "\n", sep = "")
  cat(
    sprintf("%d%% CI: [%s, %s]\n",
            round(100 * x$conf_level),
            formatC(x$conf_int["lower"], digits = 6, format = "f"),
            formatC(x$conf_int["upper"], digits = 6, format = "f"))
  )
  cat("Bootstrap mean: ", formatC(x$boot_mean, digits = 6, format = "f"), "\n", sep = "")
  cat("Bootstrap median: ", formatC(x$boot_median, digits = 6, format = "f"), "\n", sep = "")
  cat("Bootstrap SE: ", formatC(x$boot_se, digits = 6, format = "f"), "\n", sep = "")
  cat("Bootstrap bias: ", formatC(x$boot_bias, digits = 6, format = "f"), "\n", sep = "")
  cat("Valid bootstrap replicates: ", x$boot_valid_n, "\n", sep = "")

  invisible(x)
}

Try the jsdtools package in your browser

Any scripts or data that you put into this service are public.

jsdtools documentation built on March 31, 2026, 1:06 a.m.