This function uses car::Anova with argument type = "III" to calculate global p-values for categorical variables.

# S3 method for tbl_regression
add_global_p(
  x,
  include = x$table_body$variable[x$table_body$var_type %in% c("categorical",
    "interaction")],
  type = NULL,
  keep = FALSE,
  quiet = NULL,
  ...,
  terms = NULL
)

Arguments

x

Object with class tbl_regression from the tbl_regression function

include

Variables to calculate global p-value for. Input may be a vector of quoted or unquoted variable names. tidyselect and gtsummary select helper functions are also accepted. Default is NULL, which adds global p-values for all categorical and interaction terms.

type

Type argument passed to car::Anova. Default is "III"

keep

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

quiet

Logical indicating whether to print messages in console. Default is FALSE

...

Additional arguments to be passed to car::Anova

terms

DEPRECATED. Use include= argument instead.

Value

A tbl_regression object

Note

If a needed class of model is not supported by car::Anova, please create a GitHub Issue to request support.

Example Output

See also

Author

Daniel D. Sjoberg

Examples

tbl_lm_global_ex1 <- lm(marker ~ age + grade, trial) %>% tbl_regression() %>% add_global_p()
#> Global p-values for variable(s) `include = "grade"` were calculated with #> `car::Anova(x$model_obj, type = "III")`