Skip to contents

Fits the Newcombe hybrid score method (Method 10) for the risk difference in a two-arm binary trial. This method constructs a confidence interval for the difference between two independent proportions by combining Wilson score intervals for each group.

This class is unadjusted and assumes independent samples (e.g. from a Bernoulli design). It ignores any matched-pair structure if present; for matched data, use InferenceIncidKKNewcombeRiskDiff. The point estimate is the plain risk difference \(\hat p_T - \hat p_C\). The confidence interval (newcombe_independent_ci_cpp) is Newcombe's "Method 10" hybrid score interval: separate Wilson score intervals \([\ell_T, u_T]\) and \([\ell_C, u_C]\) are computed for each arm's proportion individually, then combined into a difference interval via \([\hat p_T - \hat p_C - \sqrt{(\hat p_T - \ell_T)^2 + (u_C - \hat p_C)^2},\ \hat p_T - \hat p_C + \sqrt{(u_T - \hat p_T)^2 + (\hat p_C - \ell_C)^2}]\) — this avoids the boundary/coverage problems of the naive Wald interval on a risk difference while remaining closed-form (no iterative score-test inversion, unlike the Miettinen-Nurminen method in InferenceIncidMiettinenNurminenRiskDiff). The two-sided p-value has no closed form here: it is obtained by numerically inverting the confidence interval (bisection via stats::uniroot) to find the significance level at which delta falls exactly on the interval boundary.

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 , for "Method 10", the hybrid Wilson-score interval used here.

Super class

Inference -> InferenceIncidNewcombeRiskDiff

Methods

+ inherited public methods from Inference


InferenceIncidNewcombeRiskDiff$new()

Uses the shared randomization two-sided p-value contract; see InferenceRand.

Initialize a Newcombe risk-difference inference object for a completed design with an uncensored incidence response.

Usage

InferenceIncidNewcombeRiskDiff$new(
  des_obj,
  model_formula = NULL,
  verbose = FALSE
)

Arguments

des_obj

A completed DesignSeqOneByOne object with an incidence response.

model_formula

Optional formula for covariate adjustment. If NULL (default), the formula from the design object is used and its pre-computed design matrix is reused. If a formula is provided, a new design matrix is constructed from the design's imputed covariates.

verbose

Whether to print progress messages.


InferenceIncidNewcombeRiskDiff$compute_estimate()

Computes the observed (unadjusted) risk-difference estimate \(\hat p_T - \hat p_C\) (see class documentation for the full Newcombe interval method).

Usage

InferenceIncidNewcombeRiskDiff$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance component calculations.


InferenceIncidNewcombeRiskDiff$compute_estimate_with_bootstrap_weights()

Recomputes the risk-difference estimate under subject/block bootstrap weights: the weighted event proportions \(\hat p_T^w = \sum_i r_i y_i \mathbb{1}[w_i=1] / \sum_i r_i \mathbb{1}[w_i=1]\) (and analogously for control), differenced. Used by the Bayesian bootstrap and related weighted-resampling machinery; see InferenceBayesianBootstrap. Always leaves the standard error and degrees of freedom unavailable (NA) regardless of estimate_only — the Newcombe interval method has no separate variance quantity to compute on this path.

Usage

InferenceIncidNewcombeRiskDiff$compute_estimate_with_bootstrap_weights(
  subject_or_block_weights,
  estimate_only = FALSE
)

Arguments

subject_or_block_weights

Bootstrap weights at the subject or block level.

estimate_only

Present for interface parity; this method never computes variance components regardless of its value.


InferenceIncidNewcombeRiskDiff$compute_asymp_confidence_interval()

Computes a \(1-\alpha\) Newcombe hybrid Wilson-score confidence interval for the risk difference (see class documentation for the full formula), via newcombe_independent_ci_cpp.

Usage

InferenceIncidNewcombeRiskDiff$compute_asymp_confidence_interval(alpha = 0.05)

Arguments

alpha

The significance level.


InferenceIncidNewcombeRiskDiff$compute_asymp_two_sided_pval()

Computes a two-sided p-value testing \(H_0: p_T - p_C = \code{delta}\) by numerically finding (stats::uniroot) the significance level \(\alpha\) at which delta falls exactly on the boundary of the Newcombe confidence interval (see class documentation) — there is no closed-form p-value for this method. Returns \(1\) if no root is found in \((10^{-10}, 1-10^{-10})\) (interpreted as delta being far inside the interval at every plausible \(\alpha\)).

Usage

InferenceIncidNewcombeRiskDiff$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

The null risk difference.


InferenceIncidNewcombeRiskDiff$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidNewcombeRiskDiff$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'incidence')
for (i in 1:10) {
  seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
seq_des$add_all_subject_responses(rbinom(10, 1, 0.5))
inf = InferenceIncidNewcombeRiskDiff$new(seq_des)
inf$compute_estimate()
#> [1] 0.8
# }