Skip to contents

Fits a zero-inflated negative binomial regression for count responses: a binary excess-zero submodel \(P(\text{structural zero}_i) = \mathrm{logit}^{-1}(X_i^{h\top} \gamma^h)\) mixed with a (non-truncated) negative-binomial count submodel \(\log E[Y_i \mid \text{not structural zero}, w_i, x_i] = \beta_0 + \beta_T w_i + x_i^\top \gamma\), \(\mathrm{Var}(Y_i \mid \text{not structural zero}) = \mu_i + \mu_i^2 / \theta\). Unlike a hurdle model, zero counts can arise from either the structural-zero mechanism or from an ordinary negative-binomial draw of \(0\). The zero-inflation and count submodels may use different covariate formulas (model_formula/model_formula_zero). The reported treatment effect is the coefficient from the conditional count component, on the log-rate scale, conditional on the response coming from the count process, not the excess-zero-inflation mechanism: it is not the effect on the unconditional mean \(E[Y]\), which also depends on how treatment shifts the excess-zero probability. A marginal (unconditional-mean) estimand is not yet implemented for this class (see marginal_estimand_report.md). likelihood_tier = "full": Wald, gradient, score, and (bootstrap-calibrated) likelihood-ratio tests are all available for the count submodel's treatment coefficient, as for the Poisson variant. Jackknife inference is not supported: delete-one refits of this two-part mixture model with a jointly-estimated dispersion parameter are numerically unstable, so compute_jackknife_estimate() and related methods report explicit non-estimability rather than attempting delete-one refits.

Data with no zeros. A zero-inflated mixture needs zero counts: with none, the maximum-likelihood structural-zero probability is 0 (its logits diverge to \(-\infty\)) and the zero-inflation submodel is not identified. The constructor therefore stops with an error when the response has no zeros (as pscl::zeroinfl() does); use InferenceCountNegBin instead. Inside resampling – a nonparametric- or Bayesian-bootstrap replicate, or a parametric-bootstrap simulation, that happens to contain no zeros (common when the data have few) – the replicate is not dropped and does not error: it falls back to the non-inflated negative binomial fit of the count part (the zero-inflation coefficients are fixed so that the structural-zero probability is effectively 0). That is the boundary value of the zero-inflated MLE, so the treatment coefficient is the negative binomial regression's; dropping such replicates would bias the resampling distribution toward replicates that happen to contain zeros.

Many covariates in small samples. With few subjects per parameter the zero-inflated negative binomial fit is often degenerate: in the calibration study at n = 50 with 5 covariates (15 parameters), about half the fits had a separated zero-inflation logit (a coefficient beyond 10 in absolute value) and about a quarter had the dispersion at its Poisson boundary. The model-based tests are then oversized at a nominal 5% level: Wald and score reject a true null about 18-19% of the time, likelihood-ratio about 14% and gradient about 15%. On the non-degenerate fits the likelihood-ratio test is close to nominal (about 5%), but Wald and score stay high because the model-based standard error is about 35% too small. This is a small-sample property of the model, not a defect of the fit; it fades by n = 200. At small n, adjust for fewer covariates or prefer the likelihood-ratio test.

Fitting. The default Newton-Raphson fitter can stop at a fit that is not the maximum-likelihood fit: at the zero-inflation-off negative binomial fit, or on a ridge where the zero-inflation logit is separated. This happens most often on the permuted or resampled data of randomization and bootstrap draws. Every fit the class makes is therefore checked: a fit that did not converge, sits at the zero-inflation boundary, has a zero-inflation coefficient beyond 10 in absolute value, or has a gradient norm above \(10^{-5}\) is refit with L-BFGS from a cold start and from the warm start, and the fit with the highest likelihood is kept. The estimates then agree with pscl::zeroinfl(). The extra refits make small, sparse samples slower.

Aliased count-part covariates. The count-part coefficients are learned from the subjects with a positive count: the zero counts inform them only through the mixture with the excess-zero part, which leaves a direction those subjects do not identify essentially flat (the fit used to wander along it, with no usable standard error). A count-part covariate can be aliased on those subjects (constant among them, or a linear combination of the intercept, the treatment and the covariates before it) even when it varies over the whole sample. Such a covariate has no identified count-part coefficient, so it is dropped from the count part before fitting, with one warning of class edi_covariate_dropped_warning naming it (silent inside resampling; every randomization, bootstrap and Bayesian-bootstrap refit applies the same rule to its own data). This is the same as what glm does: with its default singular.ok = TRUE, glm fits a singular design by leaving the aliased columns out of its pivoted QR decomposition and reports their coefficients as NA (with singular.ok = FALSE a singular fit is an error); the dropped count-part coefficients are likewise NA in this class's coefficient vector. As in glm, columns are checked in design order (intercept, treatment, then the covariates), and a column is dropped when it adds nothing given the columns kept before it. The treatment is never dropped: when it is itself aliased on those subjects (for example, all of them are in one arm), its count-part coefficient is not identified and the estimate is NA.

Separated zero-inflation part. The zero-inflation logit often has no finite maximum: some fitted zero-inflation probabilities run off to 0 or 1 (for example no excess zeros in one arm). The class then reports the zero-inflation coefficients as NA when a fitted zero-inflation probability is numerically 0 or 1, the fit stopped on such a ridge, or it is the zero-inflation-off boundary fit, and says why once per object: a message of class edi_no_zero_inflation_message ("no evidence of zero inflation") when the ridge points only toward no inflation (the boundary fit, or every subject driven to probability 0 with no fitted zero-inflation probability above 5%), otherwise a warning of class edi_zero_part_separation_warning (a subclass of edi_logistic_separation_warning). The count-part treatment estimate is kept. It never warm-starts a randomization, bootstrap or parametric-bootstrap refit from a full-data fit whose zero part is on the ridge (a fitted zero-inflation logit of 10 or more in absolute value): such a refit could not move its zero part, so it is cold-started like a fresh fit (v1.0.6-TODO-30, v1.0.6-TODO-152).

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 sampleexactsubjectsregulartheory[Fisher1935], [LehmannRomano2005]
waldasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
jackknifeasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
scoreasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
lik_ratioasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
gradientasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
lik_ratio_bartlett_approxasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
lik_ratio_bartlett_exactasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
param_bootasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
param_boot_directasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
bootstrapasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
bayes_bootasymptoticunknownsubjectsmixtureunknown[SelfLiang1987]
rand_bootstrapasymptoticunknownsubjectsmixtureunknown[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 mixture: the mixing probability can sit on the boundary and the information can be singular.

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

Design-specific differences from the table:

  • On any design with unequal allocation (prob_T not 0.5), for wald, jackknife, score, lik_ratio, gradient, lik_ratio_bartlett_approx, lik_ratio_bartlett_exact, param_boot, param_boot_direct, bootstrap, bayes_boot, rand_bootstrap: the effective n is the size of the smaller arm.

  • On DesignFixedBlockedCluster, DesignFixedCluster, for wald, jackknife, score, lik_ratio, gradient, lik_ratio_bartlett_approx, lik_ratio_bartlett_exact, param_boot, param_boot_direct, bootstrap, bayes_boot, rand_bootstrap: the effective n is the number of clusters.

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

Lambert, D. (1992). "Zero-Inflated Poisson Regression, with an Application to Defects in Manufacturing." Technometrics, 34(1), 1-14, doi:10.2307/1269547 , for the zero-inflated count-model framework.

[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

InferenceCountNegBin for the single-part negative binomial model this class's count submodel generalizes; InferenceCountZeroInflatedPoisson for the Poisson (equidispersed) variant.

Super classes

Inference -> InferenceCountZeroAugmentedPoissonAbstract -> InferenceCountZeroInflatedNegBin

Methods

+ inherited public methods from InferenceCountZeroAugmentedPoissonAbstract
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_bayesian_bootstrap_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_bootstrap_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_jackknife_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_m_out_of_n_bootstrap_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_rand_bootstrap_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_randomization_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$approximate_subsampling_distribution_beta_hat_T()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_asymp_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_asymp_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_bayesian_bootstrap_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_bayesian_bootstrap_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_bootstrap_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_bootstrap_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_estimate_with_bootstrap_weights()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_gradient_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_gradient_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_jackknife_bias_estimate()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_jackknife_estimate()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_jackknife_std_error()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_jackknife_wald_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_jackknife_wald_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bartlett_approx_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bartlett_approx_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bartlett_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bartlett_exact_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bartlett_exact_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bartlett_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bootstrap_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_bootstrap_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_lik_ratio_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_m_out_of_n_bootstrap_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_m_out_of_n_bootstrap_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_param_bootstrap_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_param_bootstrap_estimate()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_param_bootstrap_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_rand_bootstrap_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_rand_bootstrap_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_rand_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_rand_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_score_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_score_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_subsampling_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_subsampling_sensitivity()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_subsampling_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_wald_confidence_interval()
  • InferenceCountZeroAugmentedPoissonAbstract$compute_wald_two_sided_pval()
  • InferenceCountZeroAugmentedPoissonAbstract$get_information_preference()
  • InferenceCountZeroAugmentedPoissonAbstract$get_information_source_used()
  • InferenceCountZeroAugmentedPoissonAbstract$get_last_param_bootstrap_diagnostics()
  • InferenceCountZeroAugmentedPoissonAbstract$get_last_param_bootstrap_estimate_diagnostics()
  • InferenceCountZeroAugmentedPoissonAbstract$get_mod()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_bayesian_bootstrap_ci_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_bayesian_bootstrap_pval_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_bootstrap_ci_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_bootstrap_pval_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_information_preferences()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_rand_bootstrap_ci_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_rand_bootstrap_pval_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_supported_testing_types()
  • InferenceCountZeroAugmentedPoissonAbstract$get_testing_type()
  • InferenceCountZeroAugmentedPoissonAbstract$select_optimal_b_subsampling()
  • InferenceCountZeroAugmentedPoissonAbstract$select_optimal_m_out_of_n_bootstrap()
  • InferenceCountZeroAugmentedPoissonAbstract$set_information_preference()
  • InferenceCountZeroAugmentedPoissonAbstract$set_testing_type()
  • InferenceCountZeroAugmentedPoissonAbstract$supports_rand_pval_for_incidence()
+ inherited public methods from Inference


InferenceCountZeroInflatedNegBin$new()

Initialize inference for the zero-inflated negative binomial model (binary excess-zero submodel mixed with a negative-binomial count submodel); see InferenceCountZeroInflatedNegBin for the model form. Does not fit the model; the fit is deferred to the first call to compute_estimate() or a method that requires it.

Usage

InferenceCountZeroInflatedNegBin$new(
  des_obj,
  model_formula = NULL,
  model_formula_zero = NULL,
  use_rcpp = TRUE,
  verbose = FALSE,
  smart_cold_start_default = NULL,
  optimization_alg = NULL
)

Arguments

des_obj

A completed Design object with a count response.

model_formula

Optional formula for covariate adjustment.

model_formula_zero

Formula for the zero-inflation submodel. If NULL (default), it uses the same formula as model_formula. The treatment is always included, so ~ 1 fits the zero-inflation probability on the treatment only.

use_rcpp

Logical. If TRUE (default), use our internal Rcpp implementation. If FALSE, use glmmTMB.

verbose

Whether to print progress messages.

smart_cold_start_default

Whether to use smart cold start values.

optimization_alg

Optimization algorithm. Default is dispatched via policy.


InferenceCountZeroInflatedNegBin$compute_estimate()

Fits the zero-inflated negative binomial model and returns \(\hat\beta_T\), the treatment log-rate coefficient from the conditional count submodel. This class supports only the "conditional" estimand; a marginal (unconditional-mean) estimand is not yet implemented.

Usage

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


InferenceCountZeroInflatedNegBin$clone()

The objects of this class are cloneable with this method.

Usage

InferenceCountZeroInflatedNegBin$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

seq_des = DesignSeqOneByOneBernoulli$new(n = 40, response_type = 'count')
for (i in 1:40) {
  seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
# overdispersed counts with about 30% structural zeros in both arms
y = rnbinom(40, mu = 5, size = 2)
y[rbinom(40, 1, 0.3) == 1] = 0L
y[1:2] = 0L # a zero-inflated model needs zero counts
seq_des$add_all_subject_responses(y)
# \donttest{
inf = InferenceCountZeroInflatedNegBin$new(seq_des, model_formula = ~ x1, model_formula_zero = ~ 1)
inf$compute_estimate()
#> [1] -0.4714129
# }