ci_p_jeffreys: Bayesian confidence interval for Binomial proportion using...

View source: R/ci_p_xxx.R

ci_p_jeffreysR Documentation

Bayesian confidence interval for Binomial proportion using Jeffreys prior (non-informative prior).

Description

This function calculates the confidence interval for a proportion. It is vectorized, allowing users to evaluate it using either single values or vectors.

Usage

ci_p_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}(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.

Value

A vector with the lower and upper limits.

Author(s)

Rusvelt Jose Meza San Martin, rmezas@unal.edu.co

See Also

ci_p.

Examples

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


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