h_proportions | R Documentation |
Functions to calculate different proportion confidence intervals for use in estimate_proportion()
.
prop_wilson(rsp, conf_level, correct = FALSE)
prop_strat_wilson(
rsp,
strata,
weights = NULL,
conf_level = 0.95,
max_iterations = NULL,
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)
rsp |
( |
conf_level |
( |
correct |
( |
strata |
( |
weights |
( |
max_iterations |
( |
Confidence interval of a proportion.
prop_wilson()
: Calculates the Wilson interval by calling stats::prop.test()
.
Also referred to as Wilson score interval.
prop_strat_wilson()
: Calculates the stratified Wilson confidence
interval for unequal proportions as described in \insertCiteYan2010-jt;textualtern
prop_clopper_pearson()
: Calculates the Clopper-Pearson interval by calling stats::binom.test()
.
Also referred to as the exact
method.
prop_wald()
: Calculates the Wald interval by following the usual textbook definition
for a single proportion confidence interval using the normal approximation.
prop_agresti_coull()
: Calculates the Agresti-Coull interval. Constructed (for 95% CI) by adding two successes
and two failures to the data and then using the Wald formula to construct a CI.
prop_jeffreys()
: Calculates the Jeffreys interval, an equal-tailed interval based on the
non-informative Jeffreys prior for a binomial proportion.
Yan2010-jttern
estimate_proportion, descriptive function d_proportion()
,
and helper functions strata_normal_quantile()
and update_weights_strat_wilson()
.
rsp <- c(
TRUE, TRUE, TRUE, TRUE, TRUE,
FALSE, FALSE, FALSE, FALSE, FALSE
)
prop_wilson(rsp, conf_level = 0.9)
# Stratified Wilson confidence interval with unequal probabilities
set.seed(1)
rsp <- sample(c(TRUE, FALSE), 100, TRUE)
strata_data <- data.frame(
"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
prop_strat_wilson(
rsp = rsp, strata = strata,
conf_level = 0.90
)
# Not automatic setting of weights
prop_strat_wilson(
rsp = rsp, strata = strata,
weights = rep(1 / n_strata, n_strata),
conf_level = 0.90
)
prop_clopper_pearson(rsp, conf_level = .95)
prop_wald(rsp, conf_level = 0.95)
prop_wald(rsp, conf_level = 0.95, correct = TRUE)
prop_agresti_coull(rsp, conf_level = 0.95)
prop_jeffreys(rsp, conf_level = 0.95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.