Usage
prop_wilson(rsp, conf_level, correct = FALSE)
prop_clopper_pearson(rsp, conf_level)
prop_wald(rsp, conf_level, correct = FALSE)
prop_agresti_coull(rsp, conf_level)
prop_jeffreys(rsp, conf_level)
s_proportion(
x,
conf_level = 0.95,
method = c("waldcc", "wald", "clopper-pearson", "wilson", "wilsonc", "agresti-coull",
"jeffreys"),
long = FALSE
)
estimate_proportion(
lyt,
vars,
...,
show_labels = "hidden",
table_names = vars,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
a_proportion(
x,
conf_level = 0.95,
method = c("waldcc", "wald", "clopper-pearson", "wilson", "wilsonc", "agresti-coull",
"jeffreys"),
long = FALSE
)
Arguments
- rsp
(
logical
)
whether each subject is a responder or not.- conf_level
(
proportion
)
confidence level of the interval.- correct
(
flag
)
apply continuity correction.- x
(
logical
)
whether each subject is a responder or not.TRUE
represents a successful outcome.- method
(
string
)
the method used to construct the confidence interval for proportion of successful outcomes; one ofwaldcc
,wald
,clopper-pearson
,wilson
,agresti-coull
orjeffreys
.- long
(
flag
)
a long description is required.- lyt
(
layout
)
input layout where analyses will be added to.- vars
(
character
)
variable names for the primary analysis variable to be iterated over.- ...
other arguments are ultimately conveyed to
s_proportion()
.- show_labels
label visibility: one of "default", "visible" and "hidden".
- table_names
(
character
)
this can be customized in case that the samevars
are analyzed multiple times, to avoid warnings fromrtables
.- .stats
(
character
)
statistics to select for the table.- .formats
(named
character
orlist
)
formats for the statistics.- .labels
(named
character
)
labels for the statistics (without indent).- .indent_mods
(named
integer
)
indent modifiers for the labels.
Functions
prop_wilson()
: the Wilson interval callsstats::prop.test()
. Also referred to as Wilson score interval.prop_clopper_pearson()
: the Clopper-Pearson interval callsstats::binom.test()
. Also referred to as theexact
method.prop_wald()
: the Wald interval follows the usual textbook definition for a single proportion confidence interval using the normal approximation.prop_agresti_coull()
: the Agresti-Coull interval was created by Alan Agresti and Brent Coull and can be understood (for 95% CI) as adding two successes and two failures to the data, and then using the Wald formula to construct a CI.prop_jeffreys()
: the Jeffreys interval is an equal-tailed interval based on the non-informative Jeffreys prior for a binomial proportion.s_proportion()
: statistics function estimating a proportion along with its confidence interval.estimate_proportion()
: used in artables
pipeline.a_proportion()
: Formatted Analysis function which can be further customized by callingrtables::make_afun()
on it. It is used asafun
inrtables::analyze()
.
Examples
rsp <- c(
TRUE, TRUE, TRUE, TRUE, TRUE,
FALSE, FALSE, FALSE, FALSE, FALSE
)
prop_wilson(rsp, conf_level = 0.9)
#> [1] 0.2692718 0.7307282
prop_clopper_pearson(rsp, conf_level = .95)
#> [1] 0.187086 0.812914
prop_wald(rsp, conf_level = 0.95)
#> [1] 0.1901025 0.8098975
prop_wald(rsp, conf_level = 0.95, correct = TRUE)
#> [1] 0.1401025 0.8598975
prop_agresti_coull(rsp, conf_level = 0.95)
#> [1] 0.2365931 0.7634069
prop_jeffreys(rsp, conf_level = 0.95)
#> [1] 0.2235287 0.7764713
s_proportion(c(1, 0, 1, 0))
#> $n_prop
#> [1] 2.0 0.5
#> attr(,"label")
#> [1] "Responders"
#>
#> $prop_ci
#> [1] 0 100
#> attr(,"label")
#> [1] "95% CI (Wald, with correction)"
#>
dta_test <- data.frame(
USUBJID = paste0("S", 1:12),
ARM = rep(LETTERS[1:3], each = 4),
AVAL = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0))
)
basic_table() %>%
split_cols_by("ARM") %>%
estimate_proportion(vars = "AVAL") %>%
build_table(df = dta_test)
#> A B C
#> ———————————————————————————————————————————————————————————————————————————
#> Responders 4 (100.0%) 2 (50.0%) 0 (0.0%)
#> 95% CI (Wald, with correction) (87.5, 100.0) (0.0, 100.0) (0.0, 12.5)
a_proportion(c(1, 0, 1, 0))
#> RowsVerticalSection (in_rows) object print method:
#> ----------------------------
#> row_name formatted_cell indent_mod row_label
#> 1 n_prop 2 (50.0%) 0 Responders
#> 2 prop_ci (0.0, 100.0) 0 95% CI (Wald, with correction)