binom_ci | R Documentation |
A wrapper around DescTools::BinomCI
to calculate confidence intervals for binomial proportions.
This function formats the output into a tibble and optionally formats percentages.
binom_ci(
x,
n,
conf_level = 0.95,
sides = c("two.sided", "left", "right"),
method = c("wilson", "wald", "waldcc", "agresti-coull", "jeffreys", "modified wilson",
"wilsoncc", "modified jeffreys", "clopper-pearson", "arcsine", "logit", "witting",
"pratt", "midp", "lik", "blaker"),
rand = 123,
tol = 1e-05,
std_est = TRUE,
formatted = FALSE,
accuracy = 0.1
)
x |
Numeric. The number of successes. |
n |
Numeric. The number of trials. |
conf_level |
Numeric. Confidence level for the interval, defaults to 0.95. |
sides |
Character. Specifies the side of the confidence interval. Must be one of
|
method |
Character. The method used to compute the confidence interval. This can be one of
|
rand |
Numeric. Seed for the random number generator. Used for certain methods. |
tol |
Numeric. Tolerance for the |
std_est |
Logical. If |
formatted |
Logical. If |
accuracy |
Numeric. The rounding accuracy for formatted percentages. Defaults to 0.1. |
A tibble with the following columns:
percentage
: The point estimate of the proportion.
lower_ci
: The lower bound of the confidence interval.
upper_ci
: The upper bound of the confidence interval.
If formatted = TRUE
, these values are formatted as percentages.
# Compute a Wilson confidence interval
binom_ci(x = 25, n = 100, method = "wilson")
# Compute a Clopper-Pearson confidence interval, formatted as percentages
binom_ci(x = 25, n = 100, method = "clopper-pearson", formatted = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.