This function calculates the confidence interval for a proportion. It is vectorized, allowing users to evaluate it using either single values or vectors.

ci_p_agresti_coull(x, n, conf.level = 0.95)

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, it is 0.95.

Value

A vector with the lower and upper limits.

Details

The Agresti-Coull interval is an approximate confidence interval for the Binomial proportion \(p\). The limits are calculated based on an adjusted proportion \(\tilde{p}\) and its standard error. The mathematical definitions are as follows: Adjusted proportion: \(\tilde{p}=\frac{x + 2}{n + 4}\); Adjusted standard error: \(se=\sqrt{\frac{\tilde{p}(1 - \tilde{p})}{n + 4}}\); Confidence limits: \(\tilde{p} \pm z_{\alpha/2} \cdot se\),

where \(z_{\alpha/2}\) is the critical value of the standard normal distribution. The limits are truncated to the range \([0, 1]\).

References

Agresti, A., & Coull, B. A. (1998). Approximate is better than “exact” for interval estimation of binomial proportions. The American Statistician, 52(2), 119-126.

See also

Author

Omar David Mercado Turizo, omercado@unal.edu.co

Examples

ci_p_agresti_coull(x=15, n=50, conf.level=0.95)
#>           [,1]
#> [1,] 0.1909401
#> [2,] 0.4386896