ci_p_wald_recentered_cc | R Documentation |
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.
ci_p_wald_recentered_cc(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 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.
A vector with the lower and upper limits of the confidence interval.
David Esteban Cartagena Mejía, dcartagena@unal.edu.co
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.
ci_p.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.