ci_p_wald_recentered_cc: Recentered Wald Interval with Continuity Correction for...

View source: R/ci_p_xxx.R

ci_p_wald_recentered_ccR Documentation

Recentered Wald Interval with Continuity Correction for Binomial Proportion

Description

This function calculates the recentered Wald confidence interval with continuity correction for a Binomial proportion. It adjusts the classical Wald interval by introducing a recentering term and a continuity correction, improving accuracy for small sample sizes and boundary cases. The method is vectorized, allowing for evaluation of single values or vectors.

Usage

ci_p_wald_recentered_cc(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 recentered Wald interval with continuity correction adjusts the classical Wald interval by incorporating a recentering term and a continuity correction to account for the discreteness of the binomial distribution.

The critical value z is obtained from the standard normal distribution for the specified confidence level:

z = \Phi^{-1}(1 - \alpha / 2),

where \alpha = 1 - \text{conf.level}.

The confidence limits are calculated as:

\text{Lower} = \max\left(\frac{x + z^2 / 2}{n + z^2} - \left[z \sqrt{\frac{x}{n^2} \left(1 - \frac{x}{n}\right)} + \frac{1}{2n}\right], 0\right),

\text{Upper} = \min\left(\frac{x + z^2 / 2}{n + z^2} + \left[z \sqrt{\frac{x}{n^2} \left(1 - \frac{x}{n}\right)} + \frac{1}{2n}\right], 1\right).

Special cases are handled explicitly:

- If x = 0, the lower limit is 0, and the upper limit is calculated as (\alpha / 2)^{1/n}.

- If x = n, the upper limit is 1, and the lower limit is calculated as 1 - (\alpha / 2)^{1/n}.

These adjustments ensure that the confidence interval is valid and well-behaved, even at the boundaries of the parameter space.

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

Pires, Ana M., and Conceiçao Amado. "Interval estimators for a binomial proportion: Comparison of twenty methods". REVSTAT-Statistical Journal 6.2 (2008): 165-197.

See Also

ci_p.

Examples

ci_p_wald_recentered_cc(x =  0, n = 50, conf.level = 0.95)
ci_p_wald_recentered_cc(x = 25, n = 50, conf.level = 0.95)
ci_p_wald_recentered_cc(x = 50, n = 50, conf.level = 0.95)


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