Replaces the p-values of a regression table with one p-value per
variable: a type III test of the hypothesis that all the coefficients of
the variable are zero, which is what car::Anova(type = "III") computes
and what gtsummary reports. The default anova_fun, global_pvalue_fun(),
computes the tests in base R:
lm: Wald F test on the variable's coefficients, equal to the F test from refitting without the variable's columns;glm: likelihood-ratio test from refitting without the variable (drop1()with the deviance scaled by the dispersion);coxph: likelihood-ratio test from refitting without the variable (survival::coxph()on the model matrix).
Usage
add_global_p(
x,
include = everything(),
keep = FALSE,
anova_fun = global_pvalue_fun,
type = "III",
...
)Arguments
- x
(
tbl_regression,tbl_uvregression)
A regression table. Fortbl_uvregression, the table must have been built withy.- include
(selector)
Variables to compute a global p-value for. Default iseverything().- keep
(
scalar logical)
Whether to keep the p-values of the individual levels. Default isFALSE, which blanks them.- anova_fun
(
function)
Function that takes a model andtypeand returns a data frame with atermcolumn naming the variables and ap.valuecolumn. Default isglobal_pvalue_fun().- type
(
string)
Passed toanova_fun. Default is"III"; the built-in function accepts"III"and"II"("II"drops each term from the model formula withstats::drop1(), which respects marginality).- ...
Passed to
anova_fun.
See also
Other regression tables:
add_glance_table(),
add_n_regression,
add_nevent(),
add_significance_stars(),
add_vif(),
combine_terms(),
glance_fun_s3(),
global_pvalue_fun(),
tbl_regression(),
tbl_uvregression()
Examples
# Example 1 ----------------------------------
glm(response ~ age + grade + trt, trial, family = binomial) |>
tbl_regression(exponentiate = TRUE) |>
add_global_p()
# Example 2 ----------------------------------
# keep the level p-values as well
lm(marker ~ age + grade, trial) |>
tbl_regression() |>
add_global_p(keep = TRUE)