bayesplain.frequentist.two_proportions

bayesplain.frequentist.two_proportions(successes, n, level=0.95, estimand='difference')[source]

Two-proportion chi-square test, with an interval on the chosen estimand.

The chi-square statistic here is computed without a continuity correction, so it equals the square of the two-proportion z statistic and the p-values agree exactly – worth saying out loud, since students meet the same test under both names.

The interval is the plain Wald interval on the difference, because that is the one reproduced in textbooks and in the reports students will read. It is known to under-cover for small samples or rates near 0 and 1, which makes for a useful comparison against the credible interval in exactly those cases.

Parameters:
successes : array_like

Two success counts, [x1, x2].

n : array_like

Two trial counts, [n1, n2].

level : float, default 0.95

Confidence level for the interval.

estimand : {'difference', 'risk_ratio', 'odds_ratio'}, default 'difference'

What the interval is on. Ratios get the conventional log-scale intervals (Katz for the risk ratio, Woolf for the odds ratio), with half a case added to every cell when one of them is empty. The test itself does not depend on this choice.

Returns:

The conventional result, oriented as group 2 relative to group 1.

Return type:

FrequentistTwin