ci_p_wald_recentered: Recentered Wald Interval for Binomial Proportion

View source: R/ci_p_xxx.R

ci_p_wald_recenteredR Documentation

Recentered Wald Interval for Binomial Proportion

Description

This function calculates the recentered Wald confidence interval for a Binomial proportion. It adjusts the classical Wald interval to improve accuracy near the boundaries of the parameter space. The method is vectorized, allowing for evaluation of single values or vectors.

Usage

ci_p_wald_recentered(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 modifies the classical Wald interval by incorporating a recentering term and applying bounds to ensure that the interval remains within the parameter space [0, 1].

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} - z \sqrt{\frac{x}{n^2} \left(1 - \frac{x}{n}\right)}, 0\right),

\text{Upper} = \min\left(\frac{x + z^2 / 2}{n + z^2} + z \sqrt{\frac{x}{n^2} \left(1 - \frac{x}{n}\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}.

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(x =  0, n = 50, conf.level = 0.95)
ci_p_wald_recentered(x = 22, n = 50, conf.level = 0.95)
ci_p_wald_recentered(x = 50, n = 50, conf.level = 0.95)


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