Skip to contents

Fits a binomial regression with the identity link for binary (incidence) responses: \(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_identity_binomial_regression_cpp/ fast_identity_binomial_regression_weighted_cpp). Because the link is the identity rather than the logit, \(\hat\beta_T\) is directly a risk difference on the probability scale, not a log-odds-ratio — the class name and estimand differ from InferenceIncidLogRegr for exactly this reason. likelihood_tier = "full": likelihood-ratio, score, gradient, and Wald tests are all available when the model converges, plus parametric-likelihood-bootstrap calibration of the likelihood-ratio test. Because the identity link does not constrain fitted probabilities to \([0,1]\), fits are hardened by QR column-dropping and rejected as nonestimable when the fitted linear predictor produces implausible coefficients (see private$is_identity_binomial_fit_reasonable()); this is a real practical limitation of the identity link relative to logit/probit, not a bug. When the full-data MLE is on the boundary (some fitted probability equal to 0 or 1), the object warns once (edi_binomial_mle_boundary_warning) that Wald and score standard errors and intervals may be unreliable. The Wald standard error is the inverse of the expected (Fisher) information \(X^\top W X\), \(W = \mathrm{diag}\{1 / (\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. Validity requires the additive risk-difference model to be correctly specified over the covariate range actually observed (an identity-link fit can be well-behaved in-sample yet imply out-of-range probabilities for other covariate values).

Estimand. Composes MarginalEstimand (set_estimand()/get_estimand()/get_supported_estimands()). estimand = "marginal_mean_diff" is supported for API consistency with the other GLM families, but it is algebraically identical to the default estimand = "conditional" for this class: the g-computation marginal risk difference is \(\frac{1}{n}\sum_i \{(\hat\beta_0 + \hat\beta_T + X_i^\top \hat\gamma) - (\hat\beta_0 + X_i^\top \hat\gamma)\}\), which simplifies to exactly \(\hat\beta_T\) for every subject (not merely on average) because the identity link is linear in \(W_i\) with no treatment-by-covariate interaction term — the per-subject treated-minus-control difference \(\hat\beta_T\) does not depend on \(X_i\) at all, so standardizing over the covariate distribution changes nothing. Contrast with InferenceCountPoisson's "marginal_ratio" (also a collapsing case, for the same no-interaction reason) and "marginal_mean_diff" (which does not collapse, since a difference does not distribute through the nonlinear log-link mean). This collapsing is a genuine property of the identity-link model, not a wiring bug — it is documented here so a user comparing estimands for this class is not surprised the two never differ. Standard errors are computed independently for each estimand (the marginal path uses the delta method against the model's coefficient covariance; the conditional path uses the model information matrix), so while the two point estimates coincide exactly, their standard errors may differ slightly by construction even though both are asymptotically valid.

Small samples. With unequal allocation (prob_T = 0.2, about 10 treated subjects at n = 50), the Wald test rejected a true null 14.4% of the time at a nominal 5% level with covariate adjustment (intervals covered 85.6%) and 9.4% treatment-only. The score, gradient and likelihood-ratio tests rejected 4.7% to 5.9% of the time in the same cells with covariate adjustment, so prefer them at this sample size. 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 or bootstrap 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.

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 identity-link risk-difference 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), InferenceIncidLogBinomial (log link, log-risk-ratio estimand) for alternative link/estimand choices on the same response type. Comparable Python API: statsmodels GLM (family=Binomial(link=identity())). See also: Generalized linear model (Wikipedia).

Super class

Inference -> InferenceIncidBinomialIdentityRiskDiff

Methods

+ inherited public methods from Inference


InferenceIncidBinomialIdentityRiskDiff$compute_estimate()

Fits the identity-link binomial regression model by maximum likelihood. Under the default estimand = "conditional", returns \(\hat\beta_T\), the risk difference coefficient. Under estimand = "marginal_mean_diff" (set via set_estimand()), returns the g-computation marginal risk difference — see the class-level @details for why this is algebraically identical to the conditional estimate for this family. The underlying model fit is identical either way (a pure post-fit transform of the same cached fit, no refit).

Usage

InferenceIncidBinomialIdentityRiskDiff$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip standard-error computation and cache only the point estimate; used by randomization and bootstrap resampling paths.


InferenceIncidBinomialIdentityRiskDiff$compute_asymp_confidence_interval()

Wald confidence interval, dispatched by testing_type for the conditional estimand; under a marginal estimand testing_type is always "wald" (the only value set_estimand() permits there). Calls self$compute_estimate() first (not private$shared() directly) so the estimand-aware cache is always current regardless of call order.

Usage

InferenceIncidBinomialIdentityRiskDiff$compute_asymp_confidence_interval(
  alpha = 0.05
)

Arguments

alpha

Two-sided miscoverage rate; the returned interval targets 1 - alpha coverage.


InferenceIncidBinomialIdentityRiskDiff$compute_asymp_two_sided_pval()

Wald two-sided p-value, dispatched by testing_type exactly as compute_asymp_confidence_interval(); see that method's description for the marginal-estimand always-Wald note.

Usage

InferenceIncidBinomialIdentityRiskDiff$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

Null treatment-effect value under the current estimand (both scales coincide for this family — see the class-level @details).


InferenceIncidBinomialIdentityRiskDiff$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidBinomialIdentityRiskDiff$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
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 = rbinom(1, 1, 0.5)))
}
# true risk 0.3 + 0.2 * w + 0.1 * x1 stays in [0.3, 0.6], well inside (0, 1),
# and a binary covariate keeps every fitted probability inside the four
# treatment-by-x1 cells, so the identity-link MLE stays off the boundary
w = seq_des$get_w()
x1 = seq_des$get_X()[, 1]
seq_des$add_all_subject_responses(rbinom(100, 1, 0.3 + 0.2 * w + 0.1 * x1))
inf = InferenceIncidBinomialIdentityRiskDiff$new(seq_des)
inf$compute_estimate()   # true risk difference 0.2
#> [1] 0.4019233
inf$compute_asymp_confidence_interval()
#>      2.5%     97.5% 
#> 0.2313125 0.5725340 
# }