ci_p_jeffreys | R Documentation |
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_jeffreys(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. |
The Jeffreys prior is a non-informative prior (Beta(0.5, 0.5)
)
based on the Fisher information. The posterior distribution is Beta:
p | x \sim \text{Beta}(x+0.5, n-x+0.5)
The limits of the Bayesian confidence interval are derived from the quantiles of the posterior distribution:
\text{Lower Limit}=B_{1-\alpha/2, x+0.5, n-x+0.5}
\text{Upper Limit}=B_{\alpha/2, x+0.5, n-x+0.5}
where B_{\omega, a, b}
is the 100\%(1-\omega)
percentile of the Beta distribution with parameters
a
and b
.
A vector with the lower and upper limits.
Rusvelt Jose Meza San Martin, rmezas@unal.edu.co
ci_p.
# Example with a single value
ci_p_jeffreys(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_jeffreys(x=x_values, n=n_values, conf.level=0.95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.