Skip to contents

Performs 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).

Value

A new InferenceIncidExactFisher object.

The treatment estimate.

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.

ProcedureRegimeError orderEffective nRegularityBasisReferences
exactfinite sampleexacteventsregulartheory[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


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

alpha

Significance level; the interval has level 1 - alpha.

pval_epsilon

Accepted for interface compatibility and ignored: the interval is taken from stats directly, with no test inversion by bisection, so any value gives the same interval.

type

Exact inference type; only "Fisher" (the default) is accepted.

args_for_type

Optional list keyed by type; list(Fisher = list()) is the only valid form and has no settings.

Returns

A length-2 numeric vector of lower and upper bounds (one bound can be infinite when the table is separated).


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

delta

Null log odds ratio. Default 0. A stratified design (blocks or matched pairs) supports only delta = 0; another value is an error.

type

Exact inference type; only "Fisher" (the default) is accepted.

args_for_type

Optional list keyed by type; list(Fisher = list()) is the only valid form and has no settings.

Returns

A two-sided p-value.


InferenceIncidExactFisher$new()

Usage

InferenceIncidExactFisher$new(
  des_obj,
  model_formula = NULL,
  verbose = FALSE,
  smart_cold_start_default = NULL
)

Arguments

des_obj

A completed design object.

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.

smart_cold_start_default

Whether to use smart cold start values by default.


InferenceIncidExactFisher$compute_estimate()

Usage

InferenceIncidExactFisher$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

Ignored for this estimator (the exact statistic is always cheap to compute; there is no separate variance step to skip).


InferenceIncidExactFisher$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidExactFisher$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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