Adds p-values to tables created by tbl_svysummary
by comparing values across groups.
# S3 method for tbl_svysummary
add_p(
x,
test = NULL,
pvalue_fun = NULL,
include = everything(),
test.args = NULL,
...
)
A tbl_svysummary
object
Object with class tbl_svysummary
from the tbl_svysummary function
List of formulas specifying statistical tests to perform,
e.g. list(all_continuous() ~ "svy.t.test", all_categorical() ~ "svy.wald.test")
.
Options include
"svy.t.test"
for a t-test adapted to complex survey samples (cf. survey::svyttest
),
"svy.wilcox.test"
for a Wilcoxon rank-sum test for complex survey samples (cf. survey::svyranktest
),
"svy.kruskal.test"
for a Kruskal-Wallis rank-sum test for complex survey samples (cf. survey::svyranktest
),
"svy.vanderwaerden.test"
for a van der Waerden's normal-scores test for complex survey samples (cf. survey::svyranktest
),
"svy.median.test"
for a Mood's test for the median for complex survey samples (cf. survey::svyranktest
),
"svy.chisq.test"
for a Chi-squared test with Rao & Scott's second-order correction (cf. survey::svychisq
),
"svy.adj.chisq.test"
for a Chi-squared test adjusted by a design effect estimate (cf. survey::svychisq
),
"svy.wald.test"
for a Wald test of independence for complex survey samples (cf. survey::svychisq
),
"svy.adj.wald.test"
for an adjusted Wald test of independence for complex survey samples (cf. survey::svychisq
),
"svy.lincom.test"
for a test of independence using the exact asymptotic distribution for complex survey samples (cf. survey::svychisq
),
"svy.saddlepoint.test"
for a test of independence using a saddlepoint approximation for complex survey samples (cf. survey::svychisq
),
Tests default to "svy.wilcox.test"
for continuous variables and "svy.chisq.test"
for categorical variables.
Function to round and format p-values.
Default is style_pvalue.
The function must have a numeric vector input (the numeric, exact p-value),
and return a string that is the rounded/formatted p-value (e.g.
pvalue_fun = function(x) style_pvalue(x, digits = 2)
or equivalently,
purrr::partial(style_pvalue, digits = 2)
).
Variables to include in output. Input may be a vector of
quoted variable names, unquoted variable names, or tidyselect select helper
functions. Default is everything()
.
List of formulas containing additional arguments to pass to
tests that accept arguments. For example, add an argument for all t-tests,
use test.args = all_tests("t.test") ~ list(var.equal = TRUE)
Not used
Example 1
Example 2
Example 3
Joseph Larmarange
Other tbl_svysummary tools:
add_n.tbl_summary()
,
add_overall()
,
add_q()
,
add_stat_label()
,
modify
,
separate_p_footnotes()
,
tbl_merge()
,
tbl_split()
,
tbl_stack()
,
tbl_strata()
,
tbl_svysummary()