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_anscombe(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.

Value

A vector with the lower and upper limits of the confidence interval.

Details

The expression to obtain the confidence interval is given below:

\(\sin^2(\arcsin(\sqrt{\tilde{p}}) \mp \frac{z_{\alpha/2}}{2\sqrt{n}})\),

where \(\tilde{p} = \frac{x+3/8}{n+3/4}\). The value \(z_{\alpha/2}\) is the \(1-\alpha/2\) percentile of the standard normal distribution (e.g., \(z_{0.025}=1.96\) for a 95% confidence interval).

References

Anscombe, F. J. (1948). Transformations of Poisson, binomial and negative-binomial data. Biometrika, 35, 246–254.

See also

Author

David Esteban Cartagena Mejía, dcartagena@unal.edu.co

Examples

ci_p_arcsine_anscombe(x= 0, n=50, conf.level=0.95)
#>            [,1]
#> [1,] 0.00000000
#> [2,] 0.04962729
ci_p_arcsine_anscombe(x=15, n=50, conf.level=0.95)
#>           [,1]
#> [1,] 0.1847269
#> [2,] 0.4362265
ci_p_arcsine_anscombe(x=50, n=50, conf.level=0.95)
#>           [,1]
#> [1,] 0.9503727
#> [2,] 1.0000000