
Exact Binomial (McNemar-Type) Incidence Inference for Matched-Pair Designs
Source:R/inference_incidence_exact_binomial.R
InferenceIncidExactBinomial.RdPerforms exact matched-pair inference for binary (incidence) outcomes using
only discordant matched pairs — pairs where the treated and control
member's outcomes differ — the same reduction classical McNemar's test makes.
Writing \(d_+\) for the count of discordant pairs where the treated
subject had the event and the control did not, and \(d_-\) for the reverse,
the point estimate is the Haldane-Anscombe continuity-corrected log odds
ratio \(\log\left((d_+ + 0.5)/(d_- + 0.5)\right)\); the confidence interval
inverts the exact (Clopper-Pearson) binomial confidence interval for
\(d_+ / (d_+ + d_-)\) against \(1/2\) (via stats::binom.test) onto
the log-odds scale. Its two-sided p-value uses the corresponding equal-tail
(central) exact binomial rule against a null log odds ratio, so the interval
and test invert one another for every null value. This class is available for
DesignFixedBinaryMatch and KK matching-on-the-fly designs. For KK
designs, only the matched-pair data are used and the reservoir is ignored.
If there are no matched pairs, or no discordant pairs, the relevant
quantities are reported as non-estimable rather than as NaN/Inf.
Initialize exact matched-pair binomial inference for
incidence outcomes. Requires des_obj to be
DesignFixedBinaryMatch or a KK matching-on-the-fly-capable
design; errors otherwise. Requires an uncensored incidence response.
Computes the Haldane-Anscombe continuity-corrected
matched-pair log odds ratio \(\log\left((d_+ + 0.5)/(d_- + 0.5)\right)\)
from the discordant matched-pair counts (see class documentation for
the full model). NA if there are no matched pairs.
Super class
Inference -> InferenceIncidExactBinomial
Methods
+ inherited public methods from Inference
Inference$capabilities()Inference$compute_asymp_confidence_interval()Inference$compute_asymp_two_sided_pval()Inference$compute_exact_confidence_interval()Inference$compute_exact_two_sided_pval_for_treatment_effect()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_response()Inference$get_response_type()Inference$get_treatment()Inference$is_nonestimable()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceIncidExactBinomial$new()
Usage
InferenceIncidExactBinomial$new(
des_obj,
model_formula = NULL,
verbose = FALSE,
smart_cold_start_default = NULL
)Arguments
des_objA completed design object.
model_formulaOptional 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.verboseWhether to print progress messages.
smart_cold_start_defaultWhether to use smart cold start values by default.
Examples
# \donttest{
seq_des = DesignSeqOneByOneKK14$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), x2 = rnorm(1)))
}
seq_des$add_all_subject_responses(rbinom(10, 1, 0.5))
inf = InferenceIncidExactBinomial$new(seq_des)
inf$compute_estimate()
#> [1] 1.098612
# }