Skip to contents

Computes Newcombe's "Method 10" hybrid confidence interval for the difference between two independent proportions \(p_1 - p_2\) (see InferenceIncidNewcombeRiskDiff for the class that consumes this function). Separate Wilson score intervals \([\ell_1, u_1]\) and \([\ell_2, u_2]\) are computed for each proportion individually (via wilson_score_interval_cpp), then combined as $$\left[\,(p_1-p_2) - \sqrt{(p_1-\ell_1)^2 + (u_2-p_2)^2},\ \ (p_1-p_2) + \sqrt{(u_1-p_1)^2 + (p_2-\ell_2)^2}\,\right],$$ clamped to \([-1, 1]\). This avoids the boundary/coverage problems of the naive normal-approximation (Wald) interval on a risk difference while remaining closed-form (no iterative score-test inversion). Returns c(NA, NA) if either sample size is non-positive.

Usage

newcombe_independent_ci_cpp(x1, n1, x2, n2, alpha)

Arguments

x1

Number of events in group 1.

n1

Number of subjects in group 1.

x2

Number of events in group 2.

n2

Number of subjects in group 2.

alpha

The confidence level is \(1-\alpha\).

Value

A length-2 numeric vector containing the lower and upper CI bounds for \(p_1 - p_2\).

References

Newcombe, R. G. (1998). "Interval Estimation for the Difference Between Independent Proportions: Comparison of Eleven Methods." Statistics in Medicine, 17(8), 873-890, doi:10.1002/(SICI)1097-0258(19980430)17:8<873::AID-SIM779>3.0.CO;2-I .

See also

newcombe_paired_ci_cpp for the matched-pair generalization of this same hybrid-score method.