R/print_gwrf_fit.R

Defines functions print.gwrf_fit

Documented in print.gwrf_fit

#' Print a gwrf_fit object
#'
#' @param x A gwrf_fit object.
#' @param ... Unused.
#'
#' @return Invisibly returns `x`, the input object of class `"gwrf_fit"`.
#' The function is primarily called for its side effect of printing a concise
#' summary of the fitted model, including the model specification and global
#' diagnostic statistics.
#'
#' @examples
#' example_fit <- structure(
#'   list(
#'     formula = y ~ x,
#'     kernel = "bisquare",
#'     adaptive = TRUE,
#'     bandwidth = 10,
#'     num.trees = 50,
#'     diagnostics = list(
#'       rmse = 0.25,
#'       mae = 0.18,
#'       r2 = 0.80,
#'       n_focal = 3
#'     )
#'   ),
#'   class = "gwrf_fit"
#' )
#'
#' print(example_fit)
#'
#' @export
print.gwrf_fit <- function(x, ...) {
  cat("Geographically Weighted Random Forest\n")
  cat("-------------------------------------\n")
  cat("Formula: ")
  print(x$formula)
  cat("Kernel:", x$kernel, "\n")
  cat("Adaptive:", x$adaptive, "\n")
  cat("Bandwidth:", x$bandwidth, "\n")
  cat("Trees:", x$num.trees, "\n")
  cat("Focal fits:", x$diagnostics$n_focal, "\n")
  cat("RMSE:", round(x$diagnostics$rmse, 4), "\n")
  cat("MAE :", round(x$diagnostics$mae, 4), "\n")
  cat("R^2 :", round(x$diagnostics$r2, 4), "\n")
  invisible(x)
}

Try the gwrf package in your browser

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

gwrf documentation built on Aug. 24, 2026, 5:15 p.m.