
Exact Fisher (Conditional Hypergeometric) Incidence Inference
Source:R/inference_indicidence_exact_fisher.R
InferenceIncidExactFisher.RdPerforms exact conditional inference for binary (incidence) outcomes via
Fisher's exact test on one or more 2x2 (treated/control by case/noncase)
tables. Only iBCRD (complete-randomization), blocking and KK matching
designs are accepted; other designs (e.g. DesignFixedBernoulli) are
refused at construction. For an iBCRD design, which has no stratification
structure, a single overall 2x2 table is built and
fisher.test is used directly, giving the conditional
MLE odds ratio and its exact confidence interval/p-value. When the design
has blocking structure (DesignFixedBlocking,
DesignSeqOneByOneSPBR, DesignSeqOneByOneRandomBlockSize), a
separate 2x2 table is built per block-defining covariate stratum. When the
design has matched-pair structure (KK matching-on-the-fly designs),
each matched pair becomes its own 2x2 table, with any reservoir (unmatched)
subjects pooled into one additional stratum table. In either stratified
case, mantelhaen.test (exact conditional test) is used
instead, giving the common odds ratio across strata; stratified inference
only supports testing/estimating against a null odds ratio of 1 (log odds
ratio 0) — a non-zero null shift is rejected with an error. Strata with no
treated or no control subjects are dropped before analysis; if no
informative strata remain, this errors rather than returning a degenerate
result.
Initialize exact Fisher inference for incidence outcomes. Requires an uncensored incidence response and an iBCRD, blocking, or KK matching design (other designs are refused); the design's structure (iBCRD, blocked, or matched) determines the stratification used at estimation time (see class documentation).
Computes the log of the (conditional MLE, or common-odds-ratio
if stratified) odds ratio from fisher.test or
mantelhaen.test (see class documentation for which
applies and why).
Details
When an arm has no events (or only events), or the stratified table is otherwise
separated, the conditional MLE of the odds ratio is infinite: compute_estimate()
then returns NA, is_nonestimable() is TRUE with reason
"exact_fisher_conditional_mle_infinite", and one warning of class
edi_procedure_na_warning names the cause. The exact confidence interval
(one-sided infinite) and p-value do not use the estimate and remain valid.
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
Fisher, R. A. (1935). "The Logic of Inductive Inference."
Journal of the Royal Statistical Society, 98(1), 39-82,
doi:10.2307/2342435
, for the exact conditional test underlying
fisher.test; Mantel, N., and Haenszel, W. (1959).
"Statistical Aspects of the Analysis of Data from Retrospective Studies
of Disease." Journal of the National Cancer Institute, 22(4),
719-748, for the stratified common-odds-ratio test used when the design
provides multiple strata.
[LehmannRomano2005] Lehmann, E. L., and Romano, J. P. (2005). Testing Statistical Hypotheses (3rd ed.). Springer.
Super class
Inference -> InferenceIncidExactFisher
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()
InferenceIncidExactFisher$compute_exact_confidence_interval()
Exact confidence interval for the log odds ratio: the log of the
exact conditional interval from fisher.test (one table) or
mantelhaen.test with exact = TRUE (several strata).
Usage
InferenceIncidExactFisher$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 taken from
statsdirectly, with no test inversion by bisection, so any value gives the same interval.typeExact inference type; only
"Fisher"(the default) is accepted.args_for_typeOptional list keyed by type;
list(Fisher = list())is the only valid form and has no settings.
InferenceIncidExactFisher$compute_exact_two_sided_pval_for_treatment_effect()
Exact two-sided Fisher (one table) or exact conditional Mantel-Haenszel (several strata) p-value for \(H_0:\) log odds ratio \(= \delta\).
Usage
InferenceIncidExactFisher$compute_exact_two_sided_pval_for_treatment_effect(
delta = 0,
type = NULL,
args_for_type = NULL
)Arguments
deltaNull log odds ratio. Default
0. A stratified design (blocks or matched pairs) supports onlydelta = 0; another value is an error.typeExact inference type; only
"Fisher"(the default) is accepted.args_for_typeOptional list keyed by type;
list(Fisher = list())is the only valid form and has no settings.
InferenceIncidExactFisher$new()
Usage
InferenceIncidExactFisher$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
des = DesignFixediBCRD$new(n = 20, response_type = 'incidence')
des$add_all_subjects_to_experiment(data.frame(x1 = rnorm(20)))
des$assign_w_to_all_subjects()
des$add_all_subject_responses(rbinom(20, 1, 0.5))
inf = InferenceIncidExactFisher$new(des)
inf$compute_estimate()
#> [1] -0.930951
inf$compute_exact_two_sided_pval_for_treatment_effect()
#> [1] 0.628483