
Zero-Inflated Poisson Regression Inference for Count Responses
Source:R/inference_count_zero_inflated.R
InferenceCountZeroInflatedPoisson.RdFits a zero-inflated Poisson 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)
Poisson 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\). Unlike a hurdle
model, zero counts can arise from either the structural-zero mechanism or
from an ordinary Poisson draw of \(0\), so the two mixture components are
not identified by disjoint support. 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, under the
default estimand = "conditional". likelihood_tier = "full":
Wald, score, gradient, and (bootstrap-calibrated) likelihood-ratio tests
are available for the count submodel's treatment coefficient under that
estimand. Jackknife inference
is not supported: delete-one refits of this two-part mixture model 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
InferenceCountPoisson 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 Poisson 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 Poisson
regression's; dropping such replicates would bias the resampling
distribution toward replicates that happen to contain zeros.
Marginal (unconditional-mean) estimand. Via
set_estimand(), this class
also supports estimand = "marginal_mean_diff" and
"marginal_ratio": the g-computation average, over the empirical
covariate distribution, of the model-implied unconditional mean
\(E[Y_i \mid w_i, x_i] = (1 - \pi(x_i)) \lambda(x_i)\) (the untruncated
Poisson mean weighted by the non-structural-zero probability) at
\(w_i = 1\) vs. \(w_i = 0\) — a mean difference or, on the log scale,
a mean ratio. This is a pure post-fit transform of the same maximum-
likelihood fit (no refit), with a delta-method standard error computed
against the sandwich-robust covariance matrix already used for this
class's conditional Wald inference. Only "wald"-type inference is
available under a marginal estimand (no likelihood-ratio/score/gradient
test, since the marginal quantity is a functional of the fitted
parameters, not itself a likelihood).
Omitted covariates. When covariates that drive the outcome are
left out of the formula (for example ~ 1), the Poisson count part is
overdispersed (in the calibration study's design, variance about twice the
mean), so the model-based standard error is too small. The score, gradient
and likelihood-ratio tests then reject a true null about 16-17% of the time
at a nominal 5% level, at n = 50, 200 and 1000 alike. This is model
misspecification, so it does not go away with more data. The Wald test,
which uses a sandwich covariance, stays calibrated in this setting: prefer
it, adjust for the prognostic covariates, or use
InferenceCountZeroInflatedNegBin,
which models the overdispersion.
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), and the likelihood keeps rising
along a flat ridge. The class then (i) also fits from
pscl::zeroinfl()'s default start (a Poisson GLM for the count part, a
logistic GLM of \(1(y = 0)\) for the zero part) with L-BFGS, and again
from that start with its zero part multiplied by 10, and keeps the fit with
the lowest negative log-likelihood, which also escapes an interior local
maximum of the default start (see "Small samples" below for the limit of
this); (ii) reports the zero-inflation coefficients as NA when a
fitted zero-inflation probability is numerically 0 or 1, or the fit stopped on such a ridge, and says why once per
object: when the ridge points only toward no inflation (every subject it
drives to the boundary goes to probability 0, and no fitted zero-inflation
probability exceeds 5%; typical of data without excess zeros), with a
message of class edi_no_zero_inflation_message ("no evidence of zero
inflation"); otherwise (some subject pushed to a structural zero, or sizeable
inflation next to subjects pushed to 0) with a warning of class
edi_zero_part_separation_warning (a subclass of
edi_logistic_separation_warning); in both cases the count-part
treatment estimate is kept, since the count part is identified in the ridge
limit; and (iii) 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 and stopped below the maximum, so it is
cold-started like a fresh fit (v1.0.6-TODO-30, v1.0.6-TODO-152).
Small samples with covariates in the zero-inflation formula. At
small \(n\) with continuous covariates in model_formula_zero (the
default, which copies model_formula), the ZIP maximum-likelihood
estimate often does not exist: the likelihood is highest on a separated
zero-part ridge, where the zero-inflation part sorts some zeros away from
every positive count, and it can also have several interior local maxima.
EDI tries several starts and warns
(edi_zero_part_separation_warning) when the fit reaches the ridge, but
some fits can still stop at a lower interior local maximum without any
warning: about 41 of 602 unflagged fits in a 1,197-dataset simulation sweep
(\(n\) = 24 to 400). pscl::zeroinfl() stops at the same kind of
point, so agreement with pscl does not rule this out. On a ridge the
count-part treatment estimate is only weakly defined: different ridges give
different limits. In this setting use a treatment-only zero-inflation
formula, model_formula_zero = ~ 1 (the zero part always includes the
treatment, so this fits an intercept and the treatment), and keep the
covariates in the count part (v1.0.6-TODO-232).
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.
| Procedure | Regime | Error order | Effective n | Regularity | Basis | References |
rand | finite sample | exact | subjects | regular | theory | [Fisher1935], [LehmannRomano2005] |
wald | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
jackknife | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
score | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
lik_ratio | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
gradient | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
lik_ratio_bartlett_approx | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
lik_ratio_bartlett_exact | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
param_boot | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
param_boot_direct | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
bootstrap | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
bayes_boot | asymptotic | unknown | subjects | mixture | unknown | [SelfLiang1987] |
rand_bootstrap | asymptotic | unknown | subjects | mixture | unknown | [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_Tnot 0.5), forwald,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, forwald,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
InferenceCountPoisson for
the single-part Poisson model this class's count submodel generalizes;
InferenceCountHurdlePoisson
for the related hurdle (disjoint-support) variant;
InferenceCountZeroInflatedNegBin
for the overdispersion-robust negative-binomial variant (does not
support a marginal estimand — the mean-function derivation here is
Poisson-specific).
Super classes
Inference -> InferenceCountZeroAugmentedPoissonAbstract -> InferenceCountZeroInflatedPoisson
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_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
Inference$capabilities()Inference$clear_randomization_cache()Inference$compute_exact_confidence_interval()Inference$compute_exact_two_sided_pval_for_treatment_effect()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_estimand()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_procedure_validity()Inference$get_response()Inference$get_response_type()Inference$get_summary()Inference$get_supported_estimands()Inference$get_treatment()Inference$is_nonestimable()Inference$set_estimand()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceCountZeroInflatedPoisson$new()
Initialize inference for the zero-inflated Poisson model
(binary excess-zero submodel mixed with a Poisson count submodel); see
InferenceCountZeroInflatedPoisson
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
InferenceCountZeroInflatedPoisson$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_objA completed
Designobject with a count response.model_formulaOptional formula for the count submodel.
model_formula_zeroFormula for the zero-inflation submodel. If
NULL(default), it uses the same formula asmodel_formula. The treatment is always included. At small \(n\) with continuous covariates here the maximum-likelihood estimate often does not exist, and a fit can stop at an interior local maximum without a warning; prefer~ 1(treatment only) there (see "Small samples with covariates in the zero-inflation formula" in the class Details).use_rcppLogical. If
TRUE(default), use our internal Rcpp implementation. IfFALSE, use glmmTMB.verboseWhether to print progress messages.
smart_cold_start_defaultWhether to use smart cold start values.
optimization_algOptimization algorithm. Default is dispatched via policy.
InferenceCountZeroInflatedPoisson$compute_estimate()
Fits the zero-inflated Poisson model. Under the default
estimand = "conditional", returns \(\hat\beta_T\), the
treatment log-rate coefficient from the conditional count submodel
(see the class-level caveat that this is conditional on the response
coming from the count process, not an unconditional-mean effect).
Under estimand = "marginal_mean_diff" or
"marginal_ratio" (set via set_estimand()), returns the
g-computation marginal mean difference or log-scale marginal ratio
of the unconditional mean \(E[Y \mid w, x] = (1-\pi(x))\lambda(x)\)
instead — a pure post-fit transform of the same cached fit, no refit.
InferenceCountZeroInflatedPoisson$compute_asymp_confidence_interval()
Asymptotic confidence interval. Under the conditional
estimand, the interval of the test chosen with set_testing_type():
score, gradient, likelihood-ratio and Bartlett-corrected
likelihood-ratio give the same interval as the matching
compute_<type>_confidence_interval() (before 1.0.6 every type
returned Wald, v1.0.6-TODO-413); the default Wald interval is NA,
with the reason recorded and an edi_wald_unavailable_warning, when
the model standard error is unavailable (no bootstrap is substituted,
v1.0.6-TODO-380). Under a marginal estimand (Wald only), the
delta-method interval computed by compute_estimate(). Calls
self$compute_estimate() first (not private$shared()
directly) so the estimand-aware cache is always current regardless
of call order.
InferenceCountZeroInflatedPoisson$compute_asymp_two_sided_pval()
Asymptotic two-sided p-value, dispatched exactly as
compute_asymp_confidence_interval(); see that method's
description for the marginal-estimand path.
Examples
seq_des = DesignSeqOneByOneBernoulli$new(n = 30, response_type = 'count')
for (i in 1:30) {
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
# about 30% structural zeros in both arms, so the zero part is identified
y = rpois(30, 3)
y[rbinom(30, 1, 0.3) == 1] = 0L
y[1:2] = 0L # a zero-inflated model needs zero counts
seq_des$add_all_subject_responses(y)
inf = InferenceCountZeroInflatedPoisson$new(seq_des, model_formula_zero = ~ 1)
inf$compute_estimate()
#> [1] -0.3004845