ci_1pop_bern {statBasics} | R Documentation |
Confidence interval for a population proportion
Description
ci_1pop_bern
can be used for obtaining the confidence intervalo for a proportion for a group.
Usage
ci_1pop_bern(x, n = NULL, conf_level = 0.95, type = "two.sided", na.rm = F)
Arguments
x |
a vector of counts of sucesses. |
n |
a vector of counts of trials. |
conf_level |
confidence level of the returned confidence interval. Must be a single number between 0 and 1. |
type |
a character string specifying the type of confidence interval. Must be one of "two.sided" (default), "right" or "left". |
na.rm |
a logical value indicating whether |
Details
type
specifies the type of confidence interval. If type
is "two.sided", the returned confidence interval is (lower_ci, upper_ci)
. If type
is "left", the returned confidence interval is (lower_ci, 1)
. And, finally, if type
is "right", the returned confidence interval is (0, upper_ci))
.
Value
A 1 x 3 tibble with 'lower_ci', 'upper_ci', and 'conf_level' columns. Values correspond to the lower and upper bounds of the confidence interval, and to the confidence level, respectively.
Examples
heads <- rbinom(1, size = 100, prob = .5)
ci_1pop_bern(heads)