ci_p_hpd_jeffreys: Highest Posterior Density (HPD) interval for Binomial...

View source: R/ci_p_xxx.R

ci_p_hpd_jeffreysR Documentation

Highest Posterior Density (HPD) interval for Binomial proportion using Jeffreys prior

Description

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.

Usage

ci_p_hpd_jeffreys(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

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.

Value

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

Author(s)

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

See Also

ci_p.

Examples

# 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)


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