ci_p_LRT: Likelihood Ratio confidence interval for Binomial proportion

View source: R/ci_p_xxx.R

ci_p_LRTR Documentation

Likelihood Ratio confidence interval for Binomial proportion

Description

This function calculates the Likelihood Ratio (LRT) confidence interval for a Binomial proportion. It is vectorized, allowing the evaluation of single values or vectors.

Usage

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

Details

This function computes the confidence interval for a Binomial proportion based on the Likelihood Ratio Test (LRT). The confidence interval is defined as the set of values for p that satisfy the following condition:

-2 \log \left(\frac{L(p)}{L(\hat{p}_{ML})}\right) \leq \chi^2_{\gamma}(1),

where L(p) is the likelihood function for the binomial model, \hat{p}_{ML} = x / n is the maximum likelihood estimator for p, and \chi^2_{\gamma}(1) is the 1-\gamma quantile of the chi-square distribution with 1 degree of freedom.

The confidence limits are calculated numerically using the uniroot function in R. Special care is taken to handle edge cases where x = 0 or x = n, setting the limits to 0 or 1, respectively.

Value

A vector with the lower and upper limits.

Author(s)

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

References

Somerville, M. C., & Brown, R. S. (2013). Exact likelihood ratio and score confidence intervals for the binomial proportion. Pharmaceutical statistics, 12(3), 120-128.

See Also

ci_p.

Examples

ci_p_LRT(x = 15, n = 50, conf.level = 0.95)


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