Skip to contents

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

Daniel D. Sjoberg

Examples

# Example 1 ----------------------------------
lm(marker ~ age + grade, trial) |>
  tbl_regression() |>
  add_global_p()
Characteristic Beta 95% CI1 p-value
Age 0.00 -0.01, 0.01 >0.9
Grade

0.047
    I
    II -0.38 -0.69, -0.07
    III -0.12 -0.43, 0.19
1 CI = Confidence Interval
# Example 2 ---------------------------------- trial[c("response", "age", "trt", "grade")] |> tbl_uvregression( method = glm, y = response, method.args = list(family = binomial), exponentiate = TRUE ) |> add_global_p()
Characteristic N OR1 95% CI1 p-value
Age 183 1.02 1.00, 1.04 0.091
Chemotherapy Treatment 193

0.5
    Drug A

    Drug B
1.21 0.66, 2.24
Grade 193

>0.9
    I

    II
0.95 0.45, 2.00
    III
1.10 0.52, 2.29
1 OR = Odds Ratio, CI = Confidence Interval