
Quasi-Poisson Regression Inference for Count Responses
Source:R/inference_count_quasipoisson.R
InferenceCountQuasiPoisson.RdFits a Poisson log-link mean model, \(\log E[Y_i \mid x_i] =
x_i^\top\beta\), for count responses using the treatment indicator and,
optionally, all recorded covariates as predictors, via
fast_quasipoisson_regression_with_var_cpp — see that page for
the full model and the Pearson-dispersion-scaled ("quasi-Poisson") variance
formula, \(\widehat{\mathrm{Var}}(\hat\beta_k) = \hat\phi\,[(X^\top
\hat{W}X)^{-1}]_{kk}\), which corrects standard errors for overdispersion
(\(\mathrm{Var}(Y_i) > E[Y_i]\)) relative to the strict Poisson assumption
without changing the point estimate \(\hat\beta\). This class has no
likelihood-ratio/score/gradient testing capability
(likelihood_tier = "quasi"): the dispersion-scaled quasi-likelihood is
not a normalized model likelihood, so only Wald inference is available.
Rank-deficient covariate columns are dropped automatically before fitting
(via private$fit_with_hardened_qr_column_dropping()).
Estimand. Composes
MarginalEstimand
(set_estimand()/get_estimand()/get_supported_estimands()).
Under the default estimand = "conditional", \(\hat\beta_T\) is the
treatment log-rate-ratio. Under "marginal_mean_diff" it is the
g-computed difference in the average fitted count under treatment vs. control,
\(\frac{1}{n}\sum_i \{\exp(x_{i1}^\top\hat\beta) -
\exp(x_{i0}^\top\hat\beta)\}\), with every subject plugged in at treatment 1
and 0. "marginal_ratio" is the log of the corresponding ratio, which for
this log-link family equals the conditional \(\hat\beta_T\) exactly (there is
no treatment-by-covariate term), so it is offered for estimand-API consistency;
its delta-method SE equals the conditional SE. Under a marginal estimand the
standard error is the delta-method SE against the dispersion-scaled coefficient
covariance \(\hat\phi (X^\top \hat W X)^{-1}\), i.e. the plain-Poisson
marginal SE inflated by \(\sqrt{\hat\phi}\), with a normal reference
(degrees of freedom Inf). Switching the estimand is a pure post-fit
transform of the cached fit, never a refit. The Bayesian-bootstrap weighted
refit is not estimand-aware: it always targets the conditional coefficient.
Super class
Inference -> InferenceCountQuasiPoisson
Methods
Public methods
+ inherited public methods from Inference
Inference$capabilities()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_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_response()Inference$get_response_type()Inference$get_treatment()Inference$is_nonestimable()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceCountQuasiPoisson$new()
Uses the shared randomization two-sided p-value contract; see
InferenceRand.
Initialize a quasi-Poisson regression inference object for a completed design with a count, uncensored response.
Usage
InferenceCountQuasiPoisson$new(
des_obj,
model_formula = NULL,
verbose = FALSE,
smart_cold_start_default = NULL,
harden = TRUE
)Arguments
des_objA completed
Designobject with a count response.model_formulaOptional 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.verboseWhether to print progress messages.
smart_cold_start_defaultWhether to use smart cold start values.
hardenWhether to apply robustness measures.
InferenceCountQuasiPoisson$compute_estimate()
Computes the quasi-Poisson point estimate via
fast_quasipoisson_regression_with_var_cpp (see class
documentation for the full model). Under the default
estimand = "conditional" this is the treatment coefficient
\(\hat\beta_T\); under "marginal_mean_diff" or
"marginal_ratio" (set via set_estimand()) it is the
g-computed marginal mean difference / log ratio, a pure post-fit
transform of the same cached fit (no refit). Rank-deficient covariate
columns are dropped before fitting.
InferenceCountQuasiPoisson$compute_estimate_with_bootstrap_weights()
Recomputes the Poisson-mean-model treatment estimate under
subject/block bootstrap weights (via
fast_poisson_regression_weighted_cpp), used by the
Bayesian bootstrap and related weighted-resampling machinery; see
InferenceBayesianBootstrap.
When estimate_only = FALSE, also computes a weighted
Pearson-dispersion-scaled standard error (fixed 2026-09-07 –
previously always NA regardless of estimate_only,
which starved the Bayesian-bootstrap studentized/BCa variants of a
per-replicate SE and left them NA on the large majority of calls).
The weighted refit always targets the conditional treatment
coefficient, whatever the active estimand (it is not estimand-aware).
InferenceCountQuasiPoisson$compute_asymp_confidence_interval()
Computes a \(1-\alpha\) level Wald confidence interval for the
active estimand. Under the default conditional estimand this is the
quasi-Poisson treatment coefficient \(\hat\beta_T\) with the
Pearson-dispersion-scaled standard error from
fast_quasipoisson_regression_with_var_cpp (see class
documentation); under a marginal estimand it is the g-computed functional
with its delta-method standard error. Both use a normal reference. See
InferenceAsymp for the shared
asymptotic confidence-interval contract this delegates to.
InferenceCountQuasiPoisson$compute_asymp_two_sided_pval()
Computes a two-sided Wald p-value testing \(H_0:
\beta_T = \code{delta}\) under the conditional estimand, or that the
active marginal functional equals delta under a marginal
estimand, from the same standard error used by
$compute_asymp_confidence_interval() (normal reference). See
InferenceAsymp for the shared
asymptotic two-sided p-value contract this delegates to.
Examples
# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'count')
for (i in 1:10) {
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
seq_des$add_all_subject_responses(rpois(10, 2))
inf = InferenceCountQuasiPoisson$new(seq_des)
inf$compute_estimate()
#> [1] -0.2672812
# }