Learn R Programming

statBasics (version 0.2.3)

ci_1pop_bern: 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)

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.

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 NA values should be removed before the computation proceeds.

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)).

Examples

Run this code
heads <- rbinom(1, size = 100, prob = .5)
ci_1pop_bern(heads)

Run the code above in your browser using DataLab