prop_diff {tern} | R Documentation |
Proportion difference
Description
Usage
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"
)
Arguments
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 |
( |
Value
-
estimate_proportion_diff()
returns a layout object suitable for passing to further layouting functions, or tortables::build_table()
. Adding this function to anrtable
layout will add formatted rows containing the statistics froms_proportion_diff()
to the table layout.
-
s_proportion_diff()
returns a named list of elementsdiff
anddiff_ci
.
-
a_proportion_diff()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
-
estimate_proportion_diff()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
. -
s_proportion_diff()
: Statistics function estimating the difference in terms of responder proportion. -
a_proportion_diff()
: Formatted analysis function which is used asafun
inestimate_proportion_diff()
.
Note
When performing an unstratified analysis, methods "cmh"
, "strat_newcombe"
, and "strat_newcombecc"
are
not permitted.
See Also
Examples
## "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"
)