
Exact Zhang Combined-Test Incidence Inference
Source:R/inference_incidence_exact_zhang.R
InferenceIncidExactZhang.RdPerforms exact inference for a binary (incidence) outcome that
combines two exact component tests when the design has both
matched-pair and reservoir (unmatched) subjects — an internal-to-this-package
method (not drawn from external literature) analogous in spirit to
InferenceIncidExactBinomial
(matched pairs) and InferenceIncidExactFisher
(unmatched 2x2 table), fused into one combined exact test rather than a
Wald-style variance combination. The point estimate is always the
Haldane-Anscombe continuity-corrected log odds ratio \(\log\left((n_{11} +
0.5)(n_{00} + 0.5) / \left((n_{10}+0.5)(n_{01}+0.5)\right)\right)\) from the
pooled \(2\times2\) table across all subjects (matched and reservoir
together). For p-values and confidence intervals, the two
subsets are tested separately (an exact matched-pairs binomial test, as in
InferenceIncidExactBinomial, on discordant pairs; an exact Fisher test
on the reservoir \(2\times2\) table, as in InferenceIncidExactFisher),
and their p-values are combined via combination_method: "Fisher"
(default; \(-2(\log p_M + \log p_R) \sim \chi^2_4\) under independence),
"Stouffer" (averaged z-scores), or "min_p" (Šidák-style
\(1-(1-\min(p_M,p_R))^2\)). If only one of the two subsets is informative
(e.g. a pure-Bernoulli design with no matching, or no discordant pairs), the
combined p-value degenerates to that one component's p-value. Confidence
intervals are obtained by numerically inverting (bisection) the combined
p-value as a function of the hypothesized log odds ratio, starting from a
normal-approximation (Haldane-Anscombe MLE) interval as the search bracket.
Requires a Bernoulli-capable or matching-capable design.
Initialize exact Zhang combined-test incidence inference.
Requires des_obj to be Bernoulli-capable or
matching-capable, with an uncensored incidence response.
Computes the Haldane-Anscombe continuity-corrected log odds ratio \(\log\left((n_{11}+0.5)(n_{00}+0.5) / \left((n_{10}+0.5)(n_{01}+0.5)\right)\right)\) from the pooled \(2\times2\) table across all subjects (matched and reservoir combined) — see class documentation for the full combined-test model. On a matching design this estimate is not the quantity the exact confidence interval inverts (that uses only the discordant pairs and the reservoir), so it is not guaranteed to lie inside that interval.
Computes an exact confidence interval for the log odds
ratio by inverting the combined matched-pairs + Fisher-exact p-value
(see class documentation for the full combination methodology). The
combined p-value is not monotone in the log odds ratio, so the set it
accepts can have gaps; the interval returned is the convex hull of that
set, the smallest interval containing every log odds ratio the test does
not reject (Blaker 2000; Fay 2010). On a matching design the interval is
not guaranteed to contain compute_estimate(), which uses the
pooled table over all subjects.
Value
A new InferenceIncidExactZhang object.
The treatment estimate.
A confidence interval. When the matched pairs and the reservoir
point to incompatible effects, the combined test can reject every log
odds ratio at level alpha; the confidence set is then empty and
both bounds are NA, with the reason
"exact_ci_empty_acceptance_set" recorded and an
edi_procedure_na_warning.
Details
Both component p-values are two-sided "minimum likelihood" exact p-values
(as in stats::binom.test and stats::fisher.test), which jump
wherever another outcome ties the observed one in probability, so the
combined p-value is not monotone in the log odds ratio and the set of values
the test accepts can have gaps. The confidence interval is the convex hull
of that set: the smallest interval containing every log odds ratio whose
combined p-value is at least alpha. This is the usual convention for
inverting such tests (Blaker 2000; Fay 2010); it can be slightly
conservative, and it keeps the interval consistent with the test (a value
the test accepts is never outside the interval). An endpoint that falls on
one of these jumps is reported at the jump itself, where the test accepts.
On a matching design the point estimate and the exact confidence interval are different quantities: the estimate is the log odds ratio of the pooled table over all subjects, while the interval inverts the combined test, which uses only the discordant matched pairs and the reservoir table. The estimate therefore is not guaranteed to lie inside the exact confidence interval, although it usually does.
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
Blaker, H. (2000). Confidence curves and improved exact confidence intervals for discrete distributions. Canadian Journal of Statistics, 28(4), 783–798. doi:10.2307/3315916
Fay, M. P. (2010). Two-sided exact tests and matching confidence intervals for discrete data. The R Journal, 2(1), 53–58. doi:10.32614/RJ-2010-008
[LehmannRomano2005] Lehmann, E. L., and Romano, J. P. (2005). Testing Statistical Hypotheses (3rd ed.). Springer.
Super class
Inference -> InferenceIncidExactZhang
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()
InferenceIncidExactZhang$compute_exact_two_sided_pval_for_treatment_effect()
Exact combined two-sided p-value for \(H_0:\) log odds ratio \(= \delta\), combining the matched-pairs and reservoir exact tests as described in the class documentation.
Usage
InferenceIncidExactZhang$compute_exact_two_sided_pval_for_treatment_effect(
delta = 0,
type = NULL,
args_for_type = NULL
)InferenceIncidExactZhang$new()
Usage
InferenceIncidExactZhang$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.
InferenceIncidExactZhang$compute_exact_confidence_interval()
Usage
InferenceIncidExactZhang$compute_exact_confidence_interval(
alpha = 0.05,
pval_epsilon = 1e-06,
type = NULL,
args_for_type = NULL
)Arguments
alphaSignificance level.
pval_epsilonBisection tolerance for the inversion routine, on the log odds ratio scale (capped at
1e-6).typeExact inference type; only
"Zhang"(the default) is supported.args_for_typeOptional arguments keyed by exact type; recognizes
combination_method("Fisher"(default),"Stouffer", or"min_p") inside the"Zhang"entry.
Examples
seq_des = DesignSeqOneByOneKK14$new(n = 20, response_type = 'incidence')
for (i in 1:20) {
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1), x2 = rnorm(1)))
}
seq_des$add_all_subject_responses(rbinom(20, 1, 0.5))
inf = InferenceIncidExactZhang$new(seq_des)
inf$compute_estimate()
#> [1] -0.9315582
inf$compute_exact_two_sided_pval_for_treatment_effect()
#> [1] 0.5965736