ci_p_agresti_caffo | R Documentation |
This function calculates the Agresti-Caffo confidence interval for a Binomial proportion, which includes a Bayesian adjustment by adding 2 successes and 2 failures to stabilize the estimate. It is vectorized, allowing the evaluation of single values or vectors.
ci_p_agresti_caffo(x, n, conf.level = 0.95)
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. |
The Agresti-Caffo confidence interval incorporates a simple Bayesian adjustment by adding 2 successes and 2 failures to the data. The adjusted proportion is calculated as:
\hat{p} = \frac{x + 2}{n + 4}
The standard error for the adjusted proportion is given by:
\text{se} = \sqrt{\frac{\hat{p} (1 - \hat{p})}{n + 4}}.
The confidence interval is then constructed using the t
-distribution
with n - 1
degrees of freedom:
\text{CI} = \hat{p} \pm t_{n-1, \alpha/2} \cdot \text{se},
where t_{n-1, \alpha/2}
is the critical value of the
t
-distribution at a two-tailed significance level of
\alpha = 1 - \text{conf.level}
.
A vector with the lower and upper limits of the confidence interval.
David Esteban Cartagena Mejía, dcartagena@unal.edu.co
Agresti, Alan, and Brian Caffo. "Simple and effective confidence intervals for proportions and differences of proportions result from adding two successes and two failures." The American Statistician 54.4 (2000): 280-288.
ci_p.
# Example with a single value
ci_p_agresti_caffo(x = 15, n = 50, conf.level = 0.95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.