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()
oranova_fun
(if specified)- include
(
tidy-select
)
Variables to calculate global p-value for. Default iseverything()
- 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 isFALSE
.- anova_fun
(
function
)
Function used to calculate global p-values. Default is genericglobal_pvalue_fun()
, which wrapscar::Anova()
for most models. Thetype
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'
(seecardx::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
Examples
# Example 1 ----------------------------------
lm(marker ~ age + grade, trial) |>
tbl_regression() |>
add_global_p()
Characteristic
Beta
95% CI
p-value
Abbreviation: 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
OR
95% CI
p-value
Abbreviations: CI = Confidence Interval, OR = Odds Ratio