R/ci_p_xxx.R
ci_p_arcsine_ac.Rd
This function calculates the confidence interval for a proportion. It is vectorized, allowing users to evaluate it using either single values or vectors.
ci_p_arcsine_ac(x, n, conf.level = 0.95)
A vector with the lower and upper limits of the confidence interval.
The Arcsine Wald confidence interval with continuity correction anscombe adjusts the classical Wald interval by transforming the proportion \(\pi\) to the arcsine scale. The parameter \(\pi\) represents the true proportion of successes in a Binomial experiment, defined as:
$$\pi=\frac{0.3875+x \pm 0.5}{n+0.75},$$
where \(x\) is the number of successes and \(n\) is the number of trials.
On the arcsine scale, the transformed parameter is given by:
$$\phi=\arcsin(\sqrt{\pi}).$$
The standard error on the arcsine scale is constant:
$$\text{se}(\phi)=\frac{1}{2\sqrt{n+0.5}},$$
where \(n\) is the number of trials. The confidence interval on the arcsine scale is:
$$\text{Lower}(\phi)=\max\left(0, \phi - z \cdot (\phi)\right),$$ $$\text{Upper}(\phi)=\min\left(\frac{\pi}{2}, \phi + z \cdot (\phi)\right),$$
where \(z\) is the critical value from the standard normal distribution at the specified confidence level.
Back-transforming the limits to the original scale gives:
$$\text{Lower}(\pi)=\sin^2(\text{Lower}(\phi)),$$ $$\text{Upper}(\pi)=\sin^2(\text{Upper}(\phi)).$$
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.
Anscombe, F.J. (1948). Transformations of Poisson, binomial and negative-binomial data. Biometrika, 35, 246–254
ci_p.
ci_p_arcsine_ac(x= 0, n=50, conf.level=0.95)
#> [,1]
#> [1,] 0.0000000
#> [2,] 0.9288783
ci_p_arcsine_ac(x=15, n=50, conf.level=0.95)
#> [,1]
#> [1,] 0.1769659
#> [2,] 0.4461410
ci_p_arcsine_ac(x=50, n=50, conf.level=0.95)
#> [,1]
#> [1,] 0.07112174
#> [2,] 1.00000000