
Export of C++ function newcombe_independent_ci_cpp
Source:R/helper_glm_fit.R, R/RcppExports.R
newcombe_independent_ci_cpp.RdComputes 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.
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.