| 1 |
#' @templateVar class Gam |
| 2 |
#' @template title_desc_tidy |
| 3 |
#' |
| 4 |
#' @param x A `Gam` object returned from a call to [gam::gam()]. |
| 5 |
#' @template param_unused_dots |
| 6 |
#' |
| 7 |
#' @evalRd return_tidy( |
| 8 |
#' "term", |
| 9 |
#' "df", |
| 10 |
#' "sumsq", |
| 11 |
#' "meansq", |
| 12 |
#' "statistic", |
| 13 |
#' "p.value" |
| 14 |
#' ) |
| 15 |
#' |
| 16 |
#' @details Tidy `gam` objects created by calls to [mgcv::gam()] with |
| 17 |
#' [tidy.gam()]. |
| 18 |
#' |
| 19 |
#' @examplesIf rlang::is_installed("gam") |
| 20 |
#' |
| 21 |
#' # load libraries for models and data |
| 22 |
#' library(gam) |
| 23 |
#' |
| 24 |
#' # fit model |
| 25 |
#' g <- gam(mpg ~ s(hp, 4) + am + qsec, data = mtcars) |
| 26 |
#' |
| 27 |
#' # summarize model fit with tidiers |
| 28 |
#' tidy(g) |
| 29 |
#' glance(g) |
| 30 |
#' |
| 31 |
#' @export |
| 32 |
#' @family gam tidiers |
| 33 |
#' @aliases Gam_tidiers |
| 34 |
#' @seealso [tidy()], [gam::gam()], [tidy.anova()], [tidy.gam()] |
| 35 |
#' @rdname tidy_gam_hastie |
| 36 |
tidy.Gam <- function(x, ...) { |
| 37 |
tidy(summary(x)$parametric.anova) |
| 38 |
} |
| 39 |
|
| 40 |
#' @templateVar class Gam |
| 41 |
#' @template title_desc_glance |
| 42 |
#' |
| 43 |
#' @inheritParams tidy.Gam |
| 44 |
#' |
| 45 |
#' @evalRd return_glance( |
| 46 |
#' "df", |
| 47 |
#' "logLik", |
| 48 |
#' "AIC", |
| 49 |
#' "BIC", |
| 50 |
#' "deviance", |
| 51 |
#' "df.residual", |
| 52 |
#' "nobs" |
| 53 |
#' ) |
| 54 |
#' |
| 55 |
#' @details Glance at `gam` objects created by calls to [mgcv::gam()] with |
| 56 |
#' [glance.gam()]. |
| 57 |
#' |
| 58 |
#' @family gam tidiers |
| 59 |
#' @export |
| 60 |
#' @seealso [glance()], [gam::gam()] |
| 61 |
#' @rdname glance_gam_hastie |
| 62 |
glance.Gam <- function(x, ...) { |
| 63 |
s <- summary(x) |
| 64 |
|
| 65 |
as_glance_tibble( |
| 66 |
df = s$df[1], |
| 67 |
logLik = as.numeric(stats::logLik(x)), |
| 68 |
AIC = stats::AIC(x), |
| 69 |
BIC = stats::BIC(x), |
| 70 |
deviance = stats::deviance(x), |
| 71 |
df.residual = stats::df.residual(x), |
| 72 |
nobs = stats::nobs(x), |
| 73 |
na_types = "irrrrii" |
| 74 |
) |
| 75 |
} |