ci_p_hpd_jeffreys | R Documentation |
This function calculates the Highest Posterior Density (HPD) interval for a Binomial proportion using Jeffreys prior. It is vectorized, allowing the evaluation of single values or vectors.
ci_p_hpd_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}(0.5 + x, 0.5 + n - x)
The HPD interval is calculated using the posterior samples from the Beta distribution:
\text{HPD Interval}=[L, U]
where L
and U
are the bounds of the smallest interval
containing 1 - \alpha
posterior probability.
A vector with the lower and upper limits of the HPD interval.
Rusvelt Jose Meza San MartÃn, rmezas@unal.edu.co
ci_p.
# Example with a single value
ci_p_hpd_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_hpd_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.