Skip to contents

Fits a binomial regression with the log link for binary (incidence) responses: \(\log P(Y_i = 1) = \beta_0 + \beta_T W_i + X_i^\top \gamma\), where \(W_i\) is the treatment indicator and \(X_i\) are optional recorded covariates, by maximum likelihood (fast_log_binomial_regression_cpp/ fast_log_binomial_regression_weighted_cpp). \(\hat\beta_T\) is a log risk ratio: \(\exp(\hat\beta_T)\) is the estimated treatment risk ratio (relative risk) directly, unlike the log-odds-ratio from InferenceIncidLogRegr's logit link. likelihood_tier = "full": Wald, score, gradient, and likelihood-ratio tests are all available when the model converges, plus parametric-likelihood-bootstrap calibration of the likelihood-ratio test. Because the log link does not constrain fitted probabilities to \([0,1]\) (only to \([0,\infty)\)), fits are hardened by QR column-dropping and a coefficient-magnitude cap (max_abs_reasonable_coef) and rejected as nonestimable when the fit is implausible — the same practical limitation as the identity-link sibling InferenceIncidBinomialIdentityRiskDiff, here applying to the upper rather than both tails of the probability scale. When the full-data MLE is on that boundary (some fitted probability equal to 1), the object warns once (edi_binomial_mle_boundary_warning) that score standard errors and intervals may be unreliable. Validity requires the multiplicative log-linear risk model to be correctly specified over the covariate range observed.

Computes the randomization distribution of the treatment effect estimate under the sharp null.

Whether compute_rand_two_sided_pval() is actually usable on this instance right now – FALSE exactly when it would stop(): an incidence-response instance with no custom randomization statistic and a design not eligible for design-randomization-based incidence inference (see private$should_use_design_randomization_for_incidence()). TRUE for every other case, including every non-incidence response type. Public, self-contained (only reads already-set instance state, no side effects), so InferenceSuite can check this before attempting the sentinel instead of relying on the stop() being silently swallowed into a pval = NA "ok" row – the single source of truth for both this check and compute_rand_two_sided_pval()'s own guard, so the two can never drift apart.

Value

When debug = FALSE (default), a numeric vector of length r. When debug = TRUE, a list with: values, errors (list of character vectors, one per iteration), warnings (list of character vectors, one per iteration), num_errors, num_warnings, prop_iterations_with_errors, prop_iterations_with_warnings, and prop_illegal_values.

A single logical.

Details

Wald standard error. The Wald standard error is the inverse of the expected (Fisher) information \(X^\top W X\), \(W = \mathrm{diag}\{\hat\mu_i / (1 - \hat\mu_i)\}\), of the Fisher-scoring fit, as glm() reports for a non-canonical link; it is not the observed information, which the score test uses (a documented exception to the package's observed-information rule for Wald standard errors). The same standard error is used by every Wald interval and p-value (compute_asymp_*() and compute_wald_*()) and by InferenceSuite's se column.

Wald at a boundary MLE. When the full-data MLE has a subject at fitted probability \(\exp(X\hat\beta) = 1\) (a linear predictor within \(10^{-6}\) of 0), the Wald p-value and Wald confidence interval (compute_asymp_two_sided_pval() / compute_asymp_confidence_interval() with testing_type = "wald", and compute_wald_two_sided_pval() / compute_wald_confidence_interval()) are NA. There the weight of the boundary subject is unbounded and the inverse Fisher information treats that direction as known, so the Wald standard error is too small (null simulations with five covariates: Wald size about 0.17 in boundary fits and 0.05 in interior ones; glm(family = binomial(link = "log")) behaves the same). The object warns once (edi_wald_mle_boundary_unavailable, fields testing_type, substitute = "lik_ratio", reason, n_on_boundary) and points to the likelihood-ratio test and interval (set_testing_type("lik_ratio")). The estimate, its standard error and is_nonestimable() are unchanged, and the reason is recorded under "wald" in the object's procedure-failure reasons. Boundary MLEs are common with several covariates at small n (most ~ . fits with five covariates at n = 50). With ~ 1 the only boundary MLE is an arm in which every subject has the event, which is already non-estimable.

Small samples. With unequal allocation (prob_T = 0.2, about 10 treated subjects at n = 50) and covariate adjustment, the score test rejected a true null 14% of the time at a nominal 5% level (intervals covered 87.7%), the Wald test 7.5%, and the likelihood-ratio and gradient tests 5.8% and 5.5%; treatment-only, every test was at or below 6.8%. The excess is expected to shrink as n grows. With so few subjects in one arm, use a larger or more balanced sample, or a randomization test. Source: the first calibration campaign (2026-11-09-8c32d060; provisional, 1000 screening replicates per cell, Monte Carlo standard error about 0.007; measured at n = 50 only), https://github.com/kapelner/EDI/tree/calibration-results.

Dropped covariates. When the fit with all covariates fails or does not pass the fit checks and the hardened refit drops covariates to get a usable fit, the class raises one warning of class edi_covariate_dropped_warning per object (silent inside resampling) naming the dropped columns and the reason; the reported results are for the reduced model. Columns dropped only for linear dependence are not warned about.

Subsampling and m-out-of-n

(v1.0.6-TODO-230.) At the default size \(b = m = \lfloor n^{0.7} \rfloor\) a draw can be degenerate: a treatment arm with no events (such fits already fail and return NA). Its log risk ratio then sits where the fitter stopped (about \(\pm 20\)), not in the sampling law the pivot estimates, so the draw is NaN in approximate_subsampling_distribution_beta_hat_T() and approximate_m_out_of_n_bootstrap_distribution_beta_hat_T() (also with debug = TRUE) and is not used. If fewer than min_fraction_usable_samples (default 0.8, user-settable since v1.0.6-TODO-269) of the B draws are usable (degenerate and failed draws both count against it), the subsampling / m-out-of-n p-value or interval is NA with reason "subsampling_too_few_usable_draws_fraction" or "m_out_of_n_too_few_usable_draws_fraction" and one edi_procedure_na_warning. The p-value is symmetric: the share of usable pivot draws \(\sqrt{b}(\hat\theta^* - \hat\theta)\) (subsampling also divides by \(\sqrt{1 - b/n}\)) at least as large in absolute value as \(\sqrt{n}(\hat\theta - \delta)\), floored at \(1/B\), rather than the equal-tailed \(2\min\{\cdot\}\), because at small \(b\) the law of a log ratio is skewed toward the observed effect and the equal-tailed rule doubles the heavy tail. The interval is the basic (equal-tailed) one. Null size at \(n = 80\) (200 data sets, B = 199, nominal 0.05, before and after): Wald 0.043; subsampling 0.025 to 0.020, m-out-of-n 0.015 to 0.020. The ordinary bootstrap is the better resampling method for this estimand.

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
randfinite sampleexacteventsregulartheory[Fisher1935], [LehmannRomano2005]
waldasymptoticunknowneventsboundaryunknown[SelfLiang1987]
jackknifeasymptoticunknowneventsboundaryunknown[SelfLiang1987]
scoreasymptoticunknowneventsboundaryunknown[SelfLiang1987]
lik_ratioasymptoticunknowneventsboundaryunknown[SelfLiang1987]
gradientasymptoticunknowneventsboundaryunknown[SelfLiang1987]
lik_ratio_bartlett_approxasymptoticunknowneventsboundaryunknown[SelfLiang1987]
lik_ratio_bartlett_exactasymptoticunknowneventsboundaryunknown[SelfLiang1987]
param_bootasymptoticunknowneventsboundaryunknown[SelfLiang1987]
param_boot_directasymptoticunknowneventsboundaryunknown[SelfLiang1987]
bootstrapasymptoticunknowneventsboundaryunknown[SelfLiang1987]
bayes_bootasymptoticunknowneventsboundaryunknown[SelfLiang1987]
rand_bootstrapasymptoticunknowneventsboundaryunknown[SelfLiang1987]

The point estimate's bias is of order \(O(n_{eff}^{-1})\) (assumed default: [CoxSnell1968]).

Rows with order unknown: no rate is known for this class and procedure, so none is claimed; the cited works describe the non-standard limit, not a rate. Expect a small-sample excess of unquantified size.

Regularity boundary: the maximum-likelihood estimate can sit on the boundary of the parameter space, where the usual chi-square and normal limits fail.

The procedure list is by declared capability; an object can still report a procedure (for example a Bartlett correction) as unavailable through get_supported_testing_types().

Blocking designs

On a blocking design (DesignFixedBlocking and relatives) the regression-type inference classes do not add block fixed effects (or block-by-treatment interactions) automatically: the model uses only the covariate matrix. Whether the blocks enter the regression therefore depends on how they were supplied: not at all with m=; as dummies when the blocking column is a factor/character (or few-level integer) covariate; as a single linear term when it is numeric. Randomization, bootstrap and jackknife inference are block-aware regardless; only the model-based (asymptotic, likelihood) path ignores the blocks.

When the proportion treated is the same in every block, the pooled treatment estimate of a linear model is unbiased and its model-based SE is conservative (it is inflated by the block variation it fails to remove), at a cost in power. If the proportion treated differs across blocks (for example equal_block_sizes = FALSE with very small blocks and an extreme prob_T, where per-block rounding changes the allocation, or a user-supplied m), the pooled treated-vs-control comparison is confounded by block (Simpson's paradox) and can be biased; then include the blocking covariate(s) explicitly as factor covariates. For non-linear models (GLM, ordinal, survival) omitting blocks changes the estimand to a block-marginal effect. See DesignFixedBlocking.

References

McCullagh, P., and Nelder, J. A. (1989). Generalized Linear Models (2nd ed.). Chapman and Hall/CRC, for the binomial GLM family and log-link relative-risk parameterization.

[Fisher1935] Fisher, R. A. (1935). The Design of Experiments. Oliver and Boyd.

[LehmannRomano2005] Lehmann, E. L., and Romano, J. P. (2005). Testing Statistical Hypotheses (3rd ed.). Springer.

[SelfLiang1987] Self, S. G., and Liang, K.-Y. (1987). "Asymptotic Properties of Maximum Likelihood Estimators and Likelihood Ratio Tests under Nonstandard Conditions." Journal of the American Statistical Association, 82(398), 605-610.

[CoxSnell1968] Cox, D. R., and Snell, E. J. (1968). "A General Definition of Residuals." Journal of the Royal Statistical Society: Series B, 30(2), 248-265 (discussion 265-275).

See also

InferenceIncidLogRegr (logit link, log-odds-ratio estimand), InferenceIncidBinomialIdentityRiskDiff (identity link, risk-difference estimand) for alternative link/estimand choices on the same response type. Comparable Python API: statsmodels GLM (family=Binomial(link=log())). See also: Generalized linear model (Wikipedia).

Super class

Inference -> InferenceIncidLogBinomial

Methods

+ inherited public methods from Inference


InferenceIncidLogBinomial$approximate_randomization_distribution_beta_hat_T()

Usage

InferenceIncidLogBinomial$approximate_randomization_distribution_beta_hat_T(
  r = 501,
  delta = 0,
  transform_responses = "none",
  show_progress = TRUE,
  permutations = NULL,
  debug = FALSE,
  zero_one_logit_clamp = .Machine$double.eps
)

Arguments

r

Number of randomization vectors. Default 501.

delta

The null difference. Default 0.

transform_responses

Type of transformation. Default "none".

show_progress

Show progress bar. Default TRUE.

permutations

Pre-computed permutations. Default NULL.

debug

If TRUE, return a list with the distribution values and per-iteration diagnostics including error messages, warning messages, counts of each, and summary proportions for iterations with errors, warnings, and illegal (non-finite) values. Runs serially. Default FALSE.

zero_one_logit_clamp

The clamping amount for exact 0 and 1 values when logging


InferenceIncidLogBinomial$supports_rand_pval_for_incidence()

Usage

InferenceIncidLogBinomial$supports_rand_pval_for_incidence()


InferenceIncidLogBinomial$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidLogBinomial$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
# a low event rate and n = 100 keep the log-binomial fit off the
# exp(Xb) = 1 boundary
set.seed(1)
seq_des = DesignSeqOneByOneBernoulli$new(n = 100, response_type = 'incidence')
for (i in 1:100) {
  seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
seq_des$add_all_subject_responses(rbinom(100, 1, 0.2))
inf = InferenceIncidLogBinomial$new(seq_des)
inf$compute_estimate()
#> [1] 0.6435932
# }