ci_p_mid_p: Mid-p confidence interval for Binomial proportion

View source: R/ci_p_xxx.R

ci_p_mid_pR Documentation

Mid-p confidence interval for Binomial proportion

Description

This function calculates the mid-p confidence interval for a Binomial proportion. It is vectorized, allowing the evaluation of single values or vectors.

Usage

ci_p_mid_p(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 is 0.95.

Details

The mid-p confidence interval adjusts the exact binomial interval by averaging the tail probabilities of the observed value. The limits are found by solving the following equations:

\sum_{j=0}^{x-1} P(X = j) + 0.5 \cdot P(X = x) = \alpha / 2

\sum_{j=x+1}^{n} P(X = j) + 0.5 \cdot P(X = x) = \alpha / 2

where P(X = j) is the binomial probability.

Value

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

Author(s)

Rusvelt Jose Meza San Martín, rmezas@unal.edu.co

References

Berry, G., & Armitage, P. (1995). Mid-P confidence intervals: a brief review. Journal of the Royal Statistical Society Series D: The Statistician, 44(4), 417-423.

See Also

ci_p.

Examples

# Example with a single value
ci_p_mid_p(x = 5, n = 20, conf.level = 0.95)

# Example with vectors
x_values <- c(5, 10, 15)
n_values <- c(20, 30, 40)
ci_p_mid_p(x = x_values, n = n_values, conf.level = 0.95)


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