Skip to contents

Fits a Poisson GLMM for count responses under a KK matching-on-the-fly design. The random intercept per matched pair is integrated out via Gauss-Hermite quadrature.

When use_rcpp = TRUE (default) the likelihood is maximised by an internal Rcpp routine. Set use_rcpp = FALSE to fall back to glmmTMB.

Model. \(Y_{ij} \mid b_i \sim \mathrm{Poisson}(\mu_{ij})\) with \(\log \mu_{ij} = X_{ij}'\beta + \beta_T \cdot W_{ij} + b_i\), where \(i\) indexes matched pairs, \(j \in \{1, 2\}\) the two subjects within a pair, \(W_{ij}\) is the treatment indicator, and \(b_i \sim \mathcal{N}(0, \sigma_b^2)\) is a pair-level random intercept absorbing within-pair correlation induced by matching. \(\beta_T\) is a log-rate (log relative risk) treatment effect: \(\exp(\hat\beta_T)\) is the estimated rate ratio. The random effect is integrated out of the marginal likelihood by (non-adaptive) Gauss-Hermite quadrature with 60 fixed nodes rather than a Laplace approximation.

Likelihood tier. likelihood_tier = "full": both Wald (see Wald standard error below) and likelihood-ratio testing types are available. The likelihood-ratio, score and gradient CIs/p-values are the GLMM's own model-based tests, as in the other KK GLMM classes; they are not widened against the Wald result (before 1.0.5 each reported the larger p-value / wider interval of the model test and the Wald test).

Wald standard error. The model standard error is from the inverse of the observed information (the negative Hessian of the quadrature marginal log-likelihood in \((\beta, \log\sigma_b)\) at the MLE; with use_rcpp = FALSE, glmmTMB's). Outside resampling it is then replaced by the delete-one jackknife standard error (automatic unit) when that is larger, so the Wald standard error is the larger of the two (on three simulated n = 60 KK14 fits 9% to 26% above the model value). The same standard error is used by every Wald interval and p-value (compute_asymp_*() and compute_wald_*()) and by InferenceSuite's se column.

Assumptions. Count response modeled as conditionally Poisson given the random intercept (equidispersion conditional on \(b_i\)); pair-level random effects independent across pairs; a KK matching-on-the-fly design.

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 sampleexactpairs + reservoirregulartheory[Fisher1935], [LehmannRomano2005]
waldasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
jackknifeasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
scoreasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
lik_ratioasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
gradientasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
lik_ratio_bartlett_approxasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
lik_ratio_bartlett_exactasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
param_bootasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
param_boot_directasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
bootstrapasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
bayes_bootasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]
rand_bootstrapasymptoticunknownpairs + reservoirvariance componentunknown[SelfLiang1987], [StramLee1994]

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 variance component: a random-effect variance near zero is a non-standard limit that affects the standard tests.

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

References

Kapelner, A. and Krieger, A. M. (2014). Matching on-the-fly: Sequential allocation with higher power and efficiency. Biometrics, 70(2), 378-388. doi:10.1111/biom.12148 . (KK14 in REFERENCES.md.)

[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.

[StramLee1994] Stram, D. O., and Lee, J. W. (1994). "Variance Components Testing in the Longitudinal Mixed Effects Model." Biometrics, 50(4), 1171-1177.

[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

Analogous Python API for Poisson/count GLMs: statsmodels discrete models. Generalized linear model and Gauss-Hermite quadrature (orientation).

Super class

Inference -> InferenceCountKKGLMM

Methods

+ inherited public methods from Inference


InferenceCountKKGLMM$new()

Initialize a KK Poisson-GLMM inference object for a matched-pair KK design with a count response and prepare the matched-pair random-intercept likelihood machinery; see the class topic for the model.

Usage

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

Arguments

des_obj

A completed KK matching-on-the-fly Design object (DesignSeqOneByOneKK14 or subclass) with a count response.

model_formula

Optional formula for covariate adjustment. If NULL (default), the formula from the design object is used.

use_rcpp

Logical. If TRUE (default), maximize the Gauss-Hermite-quadrature marginal likelihood with the internal Rcpp Poisson-GLMM routine; if FALSE, fall back to glmmTMB.

optimization_alg

Optimization algorithm passed to the likelihood maximizer. If NULL (default), an algorithm is dispatched via the package's optimizer policy.

verbose

Whether to print progress messages.

smart_cold_start_default

Whether to use smart starting values for the optimizer.


InferenceCountKKGLMM$compute_estimate()

Point estimate of the treatment log-rate coefficient \(\beta_T\) from a Poisson GLMM with a matched-pair random intercept, fit by maximizing the Gauss-Hermite-quadrature-integrated marginal likelihood (internal Rcpp routine when use_rcpp = TRUE, else glmmTMB). See the class topic for the model form.

Usage

InferenceCountKKGLMM$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance-component calculations.

Returns

Numeric scalar: the treatment coefficient on the log-rate (link) scale, i.e. \(\exp(\hat\beta_T)\) is a rate ratio.


InferenceCountKKGLMM$compute_estimate_with_bootstrap_weights()

Recomputes the KK Poisson-GLMM treatment estimate under nonparametric/ Bayesian-bootstrap subject-or-block weights, refitting the weighted GLMM (compute_weighted_glmm_bootstrap_estimate()). Standard error, degrees of freedom, and the cached summary table are cleared/set to NA/Inf/ NULL since only the point estimate is meaningful under resampling weights. Falls back to the unweighted point estimate when the weights are effectively constant.

Usage

InferenceCountKKGLMM$compute_estimate_with_bootstrap_weights(
  subject_or_block_weights,
  estimate_only = FALSE
)

Arguments

subject_or_block_weights

Numeric vector of nonnegative bootstrap replicate weights, one per subject or per matched block (KK match structure).

estimate_only

If TRUE, compute only the weighted point estimate (this method never computes a weighted standard error regardless of this argument).

Returns

Numeric scalar treatment-effect estimate (log-rate scale) under the given weights.


InferenceCountKKGLMM$compute_wald_confidence_interval()

Wald confidence interval for the treatment log-rate coefficient: \(\hat\beta_T \pm t_{1-\alpha/2,\,df}\cdot \hat{se}(\hat\beta_T)\), using the Wald standard error described in the class details (the larger of the model-based and delete-one jackknife standard errors). See InferenceAsymp for the shared contract.

Usage

InferenceCountKKGLMM$compute_wald_confidence_interval(alpha = 0.05)

Arguments

alpha

The confidence level in the computed confidence interval is 1 - alpha. The default is 0.05.

Returns

A length-2 numeric vector c(lower, upper) on the log-rate scale.


InferenceCountKKGLMM$compute_wald_two_sided_pval()

Two-sided Wald p-value for \(H_0: \beta_T = \code{delta}\) vs. \(H_1: \beta_T \neq \code{delta}\), using the Wald standard error described in the class details (the larger of the model-based and delete-one jackknife standard errors).

Usage

InferenceCountKKGLMM$compute_wald_two_sided_pval(delta = 0)

Arguments

delta

The null value of \(\beta_T\) to test against; 0 (the default) tests for any treatment effect at all.

Returns

Numeric scalar p-value in \([0, 1]\).


InferenceCountKKGLMM$compute_lik_ratio_confidence_interval()

Likelihood-ratio confidence interval for the treatment log-rate coefficient, inverting the GLMM's profile likelihood-ratio test against \(\chi^2_1\).

Usage

InferenceCountKKGLMM$compute_lik_ratio_confidence_interval(alpha = 0.05)

Arguments

alpha

The confidence level in the computed confidence interval is 1 - alpha. The default is 0.05.

Returns

A length-2 numeric vector c(lower, upper) on the log-rate scale.


InferenceCountKKGLMM$compute_lik_ratio_two_sided_pval()

Two-sided likelihood-ratio p-value for \(H_0: \beta_T = \code{delta}\), from the GLMM's profile likelihood-ratio test referred to \(\chi^2_1\).

Usage

InferenceCountKKGLMM$compute_lik_ratio_two_sided_pval(delta = 0)

Arguments

delta

The null value of \(\beta_T\) to test against; 0 (the default) tests for any treatment effect at all.

Returns

Numeric scalar p-value in \([0, 1]\).


InferenceCountKKGLMM$compute_asymp_confidence_interval()

Asymptotic confidence interval, dispatching on self$get_testing_type() to compute_wald_confidence_interval(), compute_lik_ratio_confidence_interval(), or the score or gradient test inversion; any other testing type is an error. See InferenceAsymp for the shared testing-type dispatch contract.

Usage

InferenceCountKKGLMM$compute_asymp_confidence_interval(alpha = 0.05)

Arguments

alpha

The confidence level in the computed confidence interval is 1 - alpha. The default is 0.05.

Returns

A length-2 numeric vector c(lower, upper) on the log-rate scale.


InferenceCountKKGLMM$compute_asymp_two_sided_pval()

Asymptotic two-sided p-value, dispatching on self$get_testing_type() to compute_wald_two_sided_pval(), compute_lik_ratio_two_sided_pval(), or the score or gradient test; any other testing type is an error. See InferenceAsymp for the shared testing-type dispatch contract.

Usage

InferenceCountKKGLMM$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

The null value of \(\beta_T\) to test against; 0 (the default) tests for any treatment effect at all.

Returns

Numeric scalar p-value in \([0, 1]\).


InferenceCountKKGLMM$clone()

The objects of this class are cloneable with this method.

Usage

InferenceCountKKGLMM$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
seq_des = DesignSeqOneByOneKK14$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), x2 = rnorm(1)))
}
seq_des$add_all_subject_responses(rpois(10, 2))
inf = InferenceCountKKGLMM$new(seq_des)
inf$compute_estimate()
#> [1] 0.1933671
# }