Skip to contents

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

Computes an exact confidence interval for the log odds ratio by bisection-inverting the combined matched-pairs + Fisher-exact p-value (see class documentation for the full combination methodology).

Value

A new InferenceIncidExactZhang object.

The treatment estimate.

A confidence interval.

Super class

Inference -> InferenceIncidExactZhang

Methods

+ inherited public methods from Inference


InferenceIncidExactZhang$new()

Usage

InferenceIncidExactZhang$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.


InferenceIncidExactZhang$compute_estimate()

Usage

InferenceIncidExactZhang$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).


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

alpha

Significance level.

pval_epsilon

Bisection tolerance for the inversion routine.

type

Exact inference type; only "Zhang" (the default) is supported.

args_for_type

Optional arguments keyed by exact type; recognizes combination_method ("Fisher" (default), "Stouffer", or "min_p") inside the "Zhang" entry.


InferenceIncidExactZhang$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidExactZhang$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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.1082136
inf$compute_exact_two_sided_pval_for_treatment_effect()
#> [1] 0.8465736