ci_p_wald_recentered | R Documentation |
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.
ci_p_wald_recentered(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 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}
.
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(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.