bayesplain.core.gamma_poisson.log_bayes_factor_equal_rates

bayesplain.core.gamma_poisson.log_bayes_factor_equal_rates(events1, exposure1, events2, exposure2, a=0.5, b=0.0)[source]

Log Bayes factor for “the two rates differ” against “they are equal”.

Parameters:
events1 : int

Events in each group.

events2 : int

Events in each group.

exposure1 : float

Exposure in each group.

exposure2 : float

Exposure in each group.

a : float, default 0.5

Prior shape on each rate.

b : float, default 0.0

Prior rate parameter. When positive, both models use proper Gamma(a, b) priors and the result is a ratio of Gamma functions. When zero, the comparison conditions on the total count – the second group’s share of events is binomial – and the alternative puts BetaPrime(a, a) on the rate ratio.

Returns:

log(BF10).

Return type:

float

Examples

With equal exposures and b = 0, the conditional share has a Beta(a, a) prior, so this reproduces the Beta-binomial point-null Bayes factor at one half:

>>> from bayesplain.core import beta_binomial
>>> a = log_bayes_factor_equal_rates(18, 3.0, 35, 3.0, a=1.0)
>>> b = beta_binomial.log_bayes_factor_point_null(35, 53, 0.5, 1.0, 1.0)
>>> bool(abs(a - b) < 1e-6)
True