ci_prop_wilson_strata | R Documentation |
Calculates the stratified Wilson confidence interval for unequal proportions as described in Xin YA, Su XG. Stratified Wilson and Newcombe confidence intervals for multiple binomial proportions. Statistics in Biopharmaceutical Research. 2010;2(3).
ci_prop_wilson_strata(
x,
strata,
weights = NULL,
conf.level = 0.95,
max.iterations = 10L,
correct = FALSE,
data = NULL
)
x |
( |
strata |
( |
weights |
( |
conf.level |
( |
max.iterations |
(positive |
correct |
(scalar |
data |
( |
\frac{\hat{p}_j + \frac{z^2_{\alpha/2}}{2n_j} \pm
z_{\alpha/2} \sqrt{\frac{\hat{p}_j(1 - \hat{p}_j)}{n_j} +
\frac{z^2_{\alpha/2}}{4n_j^2}}}{1 + \frac{z^2_{\alpha/2}}{n_j}}
An object containing the following components:
n |
Number of responses |
N |
Total number |
estimate |
The point estimate of the proportion |
conf.low |
Lower bound of the confidence interval |
conf.high |
Upper bound of the confidence interval |
conf.level |
The confidence level used |
weights |
Weights of each strata, will be the same as the input unless unspecified, then it will be the dynamically calculated weights. |
method |
Type of method used |
# Stratified Wilson confidence interval with unequal probabilities
set.seed(1)
rsp <- sample(c(TRUE, FALSE), 100, TRUE)
strata_data <- data.frame(
x = sample(c(TRUE, FALSE), 100, TRUE),
"f1" = sample(c("a", "b"), 100, TRUE),
"f2" = sample(c("x", "y", "z"), 100, TRUE),
stringsAsFactors = TRUE
)
strata <- interaction(strata_data)
n_strata <- ncol(table(rsp, strata)) # Number of strata
ci_prop_wilson_strata(
x = rsp, strata = strata,
conf.level = 0.90
)
# Not automatic setting of weights
ci_prop_wilson_strata(
x = rsp, strata = strata,
weights = rep(1 / n_strata, n_strata),
conf.level = 0.90
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.