prop_diff_test | R Documentation |
The analyze function test_proportion_diff()
creates a layout element to test the difference between two
proportions. The primary analysis variable, vars
, indicates whether a response has occurred for each record. See
the method
parameter for options of methods to use to calculate the p-value. Additionally, a stratification
variable can be supplied via the strata
element of the variables
argument.
test_proportion_diff(
lyt,
vars,
variables = list(strata = NULL),
method = c("chisq", "schouten", "fisher", "cmh"),
na_str = default_na_str(),
nested = TRUE,
...,
var_labels = vars,
show_labels = "hidden",
table_names = vars,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_test_proportion_diff(
df,
.var,
.ref_group,
.in_ref_col,
variables = list(strata = NULL),
method = c("chisq", "schouten", "fisher", "cmh")
)
a_test_proportion_diff(
df,
.var,
.ref_group,
.in_ref_col,
variables = list(strata = NULL),
method = c("chisq", "schouten", "fisher", "cmh")
)
lyt |
( |
vars |
( |
variables |
(named |
method |
( |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
var_labels |
( |
show_labels |
( |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
.ref_group |
( |
.in_ref_col |
( |
test_proportion_diff()
returns a layout object suitable for passing to further layouting functions,
or to rtables::build_table()
. Adding this function to an rtable
layout will add formatted rows containing
the statistics from s_test_proportion_diff()
to the table layout.
s_test_proportion_diff()
returns a named list
with a single item pval
with an attribute label
describing the method used. The p-value tests the null hypothesis that proportions in two groups are the same.
a_test_proportion_diff()
returns the corresponding list with formatted rtables::CellValue()
.
test_proportion_diff()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_test_proportion_diff()
: Statistics function which tests the difference between two proportions.
a_test_proportion_diff()
: Formatted analysis function which is used as afun
in test_proportion_diff()
.
h_prop_diff_test
dta <- data.frame(
rsp = sample(c(TRUE, FALSE), 100, TRUE),
grp = factor(rep(c("A", "B"), each = 50)),
strata = factor(rep(c("V", "W", "X", "Y", "Z"), each = 20))
)
# With `rtables` pipelines.
l <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
test_proportion_diff(
vars = "rsp",
method = "cmh", variables = list(strata = "strata")
)
build_table(l, df = dta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.