add_global_p: Add the global p-values

View source: R/add_global_p.R

add_global_pR Documentation

Add the global p-values

Description

This function uses car::Anova() (by default) to calculate global p-values for model covariates. Output from tbl_regression and tbl_uvregression objects supported.

Usage

add_global_p(x, ...)

## S3 method for class 'tbl_regression'
add_global_p(
  x,
  include = everything(),
  keep = FALSE,
  anova_fun = global_pvalue_fun,
  type = "III",
  quiet,
  ...
)

## S3 method for class 'tbl_uvregression'
add_global_p(
  x,
  include = everything(),
  keep = FALSE,
  anova_fun = global_pvalue_fun,
  type = "III",
  quiet,
  ...
)

Arguments

x

(tbl_regression, tbl_uvregression)
Object with class 'tbl_regression' or 'tbl_uvregression'

...

Additional arguments to be passed to car::Anova, aod::wald.test() or anova_fun (if specified)

include

(tidy-select)
Variables to calculate global p-value for. Default is everything()

keep

(scalar logical)
Logical argument indicating whether to also retain the individual p-values in the table output for each level of the categorical variable. Default is FALSE.

anova_fun

(function)
Function used to calculate global p-values. Default is generic global_pvalue_fun(), which wraps car::Anova() for most models. The type argument is passed to this function. See help file for details.

To pass a custom function, it must accept as its first argument is a model. Note that anything passed in ... will be passed to this function. The function must return an object of class 'cards' (see cardx::ard_car_anova() as an example), or a tibble with columns 'term' and 'p.value' (e.g. ⁠\(x, type, ...) car::Anova(x, type, ...) |> broom::tidy()⁠).

type

Type argument passed to anova_fun. Default is "III"

quiet

[Deprecated]

Author(s)

Daniel D. Sjoberg

Examples


# Example 1 ----------------------------------
lm(marker ~ age + grade, trial) |>
  tbl_regression() |>
  add_global_p()

# Example 2 ----------------------------------
trial[c("response", "age", "trt", "grade")] |>
  tbl_uvregression(
    method = glm,
    y = response,
    method.args = list(family = binomial),
    exponentiate = TRUE
  ) |>
  add_global_p()


ddsjoberg/gtsummary documentation built on Sept. 16, 2024, 4:15 a.m.