ci_p_agresti_caffo: Agresti-Caffo confidence interval for Binomial proportion

View source: R/ci_p_xxx.R

ci_p_agresti_caffoR Documentation

Agresti-Caffo confidence interval for Binomial proportion

Description

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.

Usage

ci_p_agresti_caffo(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.

Details

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

Value

A vector with the lower and upper limits of the confidence interval.

Author(s)

David Esteban Cartagena Mejía, dcartagena@unal.edu.co

References

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.

See Also

ci_p.

Examples

# Example with a single value
ci_p_agresti_caffo(x = 15, n = 50, conf.level = 0.95)



fhernanb/stests documentation built on March 29, 2025, 10:36 a.m.