
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, compute_estimate() returns NA
and marks the estimate non-estimable. The exact confidence interval and
p-value methods stop with an error when there are no matched pairs or no
discordant pairs.
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.
Small-sample behaviour
How fast the size (and coverage) error of each procedure is expected to vanish as the
effective sample size \(n_{eff}\) grows, from EDI's convergence-rate registry
(inference_convergence_expectation()). Exact procedures are valid at every
n by construction; the others are asymptotic, so a small-sample excess is expected, and
its constant is not given by an order. The table is the expectation for a balanced
complete-randomization design; it is not a measured size. Reference keys are explained
under References.
| Procedure | Regime | Error order | Effective n | Regularity | Basis | References |
exact | finite sample | exact | events | regular | theory | [LehmannRomano2005] |
References
[LehmannRomano2005] Lehmann, E. L., and Romano, J. P. (2005). Testing Statistical Hypotheses (3rd ed.). Springer.
Super class
Inference -> InferenceIncidExactBinomial
Methods
+ inherited public methods from Inference
Inference$capabilities()Inference$clear_randomization_cache()Inference$compute_asymp_confidence_interval()Inference$compute_asymp_two_sided_pval()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_estimand()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_procedure_validity()Inference$get_response()Inference$get_response_type()Inference$get_summary()Inference$get_supported_estimands()Inference$get_treatment()Inference$is_nonestimable()Inference$set_estimand()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceIncidExactBinomial$compute_exact_confidence_interval()
Exact confidence interval for the log odds ratio from the
discordant matched pairs: the Clopper-Pearson interval
(binom.test) for the share of discordant pairs in which
the treated member has the event, mapped to the log-odds scale with
qlogis().
Usage
InferenceIncidExactBinomial$compute_exact_confidence_interval(
alpha = 0.05,
pval_epsilon = 0.005,
type = NULL,
args_for_type = NULL
)Arguments
alphaSignificance level; the interval has level
1 - alpha.pval_epsilonAccepted for interface compatibility and ignored: the interval is closed form, so any value gives the same interval.
typeExact inference type; only
"Binomial"(the default) is accepted.args_for_typeOptional list keyed by type;
list(Binomial = list())is the only valid form and has no settings.
InferenceIncidExactBinomial$compute_exact_two_sided_pval_for_treatment_effect()
Exact equal-tail binomial p-value for \(H_0:\) log odds ratio
\(= \delta\), computed on the discordant matched pairs with success
probability plogis(delta); it is the test that
$compute_exact_confidence_interval() inverts.
Usage
InferenceIncidExactBinomial$compute_exact_two_sided_pval_for_treatment_effect(
delta = 0,
type = NULL,
args_for_type = NULL
)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.609438
# }