ci_p_LRT | R Documentation |
This function calculates the Likelihood Ratio (LRT) confidence interval for a Binomial proportion. It is vectorized, allowing the evaluation of single values or vectors.
ci_p_LRT(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. |
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.
A vector with the lower and upper limits.
David Esteban Cartagena Mejía, dcartagena@unal.edu.co
Somerville, M. C., & Brown, R. S. (2013). Exact likelihood ratio and score confidence intervals for the binomial proportion. Pharmaceutical statistics, 12(3), 120-128.
ci_p.
ci_p_LRT(x = 15, n = 50, conf.level = 0.95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.