This function obtains the confidence interval for a proportion.

ci_p(x, n, conf.level = 0.95, intervalType = "wald")

Arguments

x

a number or a vector with the number of successes.

n

a number or a vector with the number of trials.

conf.level

confidence level for the returned confidence interval. By default is 0.95.

intervalType

type of confidence interval, possible choices are: "wald".

Value

A dataframe with the input information and the confidence interval.

Author

Freddy Hernandez, fhernanb@unal.edu.co

Examples

# Examples for single values
ci_p(x=5, n=15, intervalType="wald", conf.level=0.90)
#>   x  n proportion     lower     upper conf.level
#> 1 5 15  0.3333333 0.1331281 0.5335385        0.9
ci_p(x=7, n=17, intervalType="wald", conf.level=0.95)
#>   x  n proportion     lower     upper conf.level
#> 1 7 17  0.4117647 0.1778143 0.6457151       0.95
ci_p(x=9, n=19, intervalType="wald", conf.level=0.97)
#>   x  n proportion     lower     upper conf.level
#> 1 9 19  0.4736842 0.2251028 0.7222656       0.97

# Examples for multiple values
ci_p(x=c(5, 7, 9),
     n=c(15, 17, 19),
     intervalType="wald",
     conf.level=c(0.90, 0.95, 0.97))
#>   x  n proportion     lower     upper conf.level
#> 1 5 15  0.3333333 0.1331281 0.5335385       0.90
#> 2 7 17  0.4117647 0.1778143 0.6457151       0.95
#> 3 9 19  0.4736842 0.2251028 0.7222656       0.97