prop_diff | R Documentation |
The analysis function estimate_proportion_diff()
creates a layout element to estimate the difference in proportion
of responders within a studied population. The primary analysis variable, vars
, is a logical variable indicating
whether a response has occurred for each record. See the method
parameter for options of methods to use when
constructing the confidence interval of the proportion difference. A stratification variable can be supplied via the
strata
element of the variables
argument.
estimate_proportion_diff(
lyt,
vars,
variables = list(strata = NULL),
conf_level = 0.95,
method = c("waldcc", "wald", "cmh", "ha", "newcombe", "newcombecc", "strat_newcombe",
"strat_newcombecc"),
weights_method = "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_proportion_diff(
df,
.var,
.ref_group,
.in_ref_col,
variables = list(strata = NULL),
conf_level = 0.95,
method = c("waldcc", "wald", "cmh", "ha", "newcombe", "newcombecc", "strat_newcombe",
"strat_newcombecc"),
weights_method = "cmh"
)
a_proportion_diff(
df,
.var,
.ref_group,
.in_ref_col,
variables = list(strata = NULL),
conf_level = 0.95,
method = c("waldcc", "wald", "cmh", "ha", "newcombe", "newcombecc", "strat_newcombe",
"strat_newcombecc"),
weights_method = "cmh"
)
lyt |
( |
vars |
( |
variables |
(named |
conf_level |
( |
method |
( |
weights_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 |
( |
estimate_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_proportion_diff()
to the table layout.
s_proportion_diff()
returns a named list of elements diff
and diff_ci
.
a_proportion_diff()
returns the corresponding list with formatted rtables::CellValue()
.
estimate_proportion_diff()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_proportion_diff()
: Statistics function estimating the difference
in terms of responder proportion.
a_proportion_diff()
: Formatted analysis function which is used as afun
in estimate_proportion_diff()
.
When performing an unstratified analysis, methods "cmh"
, "strat_newcombe"
, and "strat_newcombecc"
are
not permitted.
d_proportion_diff()
## "Mid" case: 4/4 respond in group A, 1/2 respond in group B.
nex <- 100 # Number of example rows
dta <- data.frame(
"rsp" = sample(c(TRUE, FALSE), nex, TRUE),
"grp" = sample(c("A", "B"), nex, TRUE),
"f1" = sample(c("a1", "a2"), nex, TRUE),
"f2" = sample(c("x", "y", "z"), nex, TRUE),
stringsAsFactors = TRUE
)
l <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "B") %>%
estimate_proportion_diff(
vars = "rsp",
conf_level = 0.90,
method = "ha"
)
build_table(l, df = dta)
s_proportion_diff(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
conf_level = 0.90,
method = "ha"
)
# CMH example with strata
s_proportion_diff(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
variables = list(strata = c("f1", "f2")),
conf_level = 0.90,
method = "cmh"
)
a_proportion_diff(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
conf_level = 0.90,
method = "ha"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.