R/nested_model_fit.R

Defines functions print.nested_model_fit required_pkgs.nested_model_fit new_nested_model_fit

#' nested_model_fit objects
#'
#' Create a `nested_model_fit` object.
#'
#' @param fit A tibble of model fits.
#' @param spec The original model specification.
#' @param inner_names A character vector of names
#' @param ... Passed on to [structure()]
#'
#' @returns An object with class `nested_model_fit`
#'
#' @noRd
new_nested_model_fit <- function(fit, spec, inner_names, ...) {
  list(spec = spec, fit = fit, inner_names = inner_names) %>%
    structure(class = c("nested_model_fit", "model_fit"), ...)
}

#' @export
required_pkgs.nested_model_fit <- function(x, ...) {
  c("nestedmodels", required_pkgs(x$spec, ...))
}

#' @export
print.nested_model_fit <- function(x, ...) {
  des <- paste("Nested model fit, with", nrow(x$fit), "inner models\n")
  cat(des)
  print(x$fit, ...)
  invisible(x)
}

Try the nestedmodels package in your browser

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

nestedmodels documentation built on Sept. 30, 2023, 5:06 p.m.