Skip to contents

Fits a proportional-odds working model for an ordinal outcome using treatment and, optionally, all recorded covariates (fast_ordinal_regression_with_var_cpp), then estimates the marginal difference in expected ordinal category score by G-computation — see gcomp_ordinal_proportional_odds_post_fit_cpp for the exact standardization formula (mean1 - mean0). Standard errors are obtained by the delta method: a central finite-difference gradient of the mean-difference functional with respect to the fitted \([\alpha, \beta]\) parameters, propagated through the model's fitted variance-covariance matrix, \(\widehat{\mathrm{Var}}(\widehat{\mathrm{md}}) = \nabla^\top \widehat{\mathrm{Var}}(\hat\theta) \nabla\). If that delta-method standard error is unavailable or non-finite, the Wald-style methods ($compute_asymp_confidence_interval(), $compute_asymp_two_sided_pval(), $compute_wald_confidence_interval(), $compute_wald_two_sided_pval()) all return NA, with the reason recorded and an edi_wald_unavailable_warning; no bootstrap interval or p-value is substituted (they fell back to the bootstrap before EDI 1.0.6, v1.0.6-TODO-380). Call $compute_bootstrap_confidence_interval() for a bootstrap interval.

Small samples. With unequal allocation (prob_T = 0.2, about 10 treated subjects at n = 50), the delta-method Wald test rejected a true null 10.2% of the time at a nominal 5% level with covariate adjustment (intervals covered 89.8%) and 8.6% treatment-only. 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.

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]
waldasymptotic\(O(n_{eff}^{-1})\)subjectsregularassumed default[Hall1992]
jackknifeasymptotic\(O(n_{eff}^{-1})\)subjectsregularassumed default[ShaoTu1995]
bootstrapasymptotic\(O(n_{eff}^{-1})\)subjectsregularassumed default[Hall1992]
bayes_bootasymptotic\(O(n_{eff}^{-1})\)subjectsregularassumed default[Rubin1981], [Lo1987]
rand_bootstrapasymptotic\(O(n_{eff}^{-1})\)subjectsregularassumed default[Hall1992], [Kallus2018]

The point estimate's bias is of order \(O(n_{eff}^{-1})\) (assumed default: [CoxSnell1968]).

Rows with basis assumed default: the order shown is the procedure's rate in a regular parametric model, and the cited works establish it for that case only. EDI has not derived it for this class.

Design-specific differences from the table:

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

  • On DesignFixedBlockedCluster, DesignFixedCluster, for wald, jackknife, 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

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

[Hall1992] Hall, P. (1992). The Bootstrap and Edgeworth Expansion. Springer.

[ShaoTu1995] Shao, J., and Tu, D. (1995). The Jackknife and Bootstrap. Springer.

[Rubin1981] Rubin, D. B. (1981). "The Bayesian Bootstrap." The Annals of Statistics, 9(1), 130-134.

[Lo1987] Lo, A. Y. (1987). "A Large Sample Study of the Bayesian Bootstrap." The Annals of Statistics, 15(1), 360-375.

[Kallus2018] Kallus, N. (2018). "Optimal a priori balance in the design of controlled experiments." Journal of the Royal Statistical Society: Series B, 80(1), 85-112. Section 5 ("Algorithms for inference"), Algorithm 4.

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

Super class

Inference -> InferenceOrdinalGCompMeanDiff

Methods

+ inherited public methods from Inference


InferenceOrdinalGCompMeanDiff$new()

Uses the shared randomization two-sided p-value contract; see InferenceRand.

Initialize the ordinal g-computation (G-Comp) inference object for a completed design with an ordinal, uncensored response.

Usage

InferenceOrdinalGCompMeanDiff$new(
  des_obj,
  model_formula = NULL,
  verbose = FALSE,
  smart_cold_start_default = NULL
)

Arguments

des_obj

A completed DesignSeqOneByOne object with an ordinal response.

model_formula

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

verbose

Whether to print progress messages.

smart_cold_start_default

Whether to use smart cold start values by default.


InferenceOrdinalGCompMeanDiff$compute_estimate()

Computes the G-computation standardized mean-difference treatment-effect estimate (see class documentation for the full proportional-odds-based standardization).

Usage

InferenceOrdinalGCompMeanDiff$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance component calculations.


InferenceOrdinalGCompMeanDiff$compute_estimate_with_bootstrap_weights()

Recomputes the G-computation mean-difference estimate under subject/block bootstrap weights (via fast_ordinal_regression_weighted_cpp plus gcomp_ordinal_proportional_odds_post_fit_cpp), used by the Bayesian bootstrap and related weighted-resampling machinery; see InferenceNonParamBootstrap. Runs side-effect free: the ordinary (unweighted) cached fit, warm-start state, and rank-reduced column selection are saved before the weighted refit and restored afterward (on.exit), so a weighted bootstrap replicate cannot corrupt the class's own point estimate or subsequent fits.

Usage

InferenceOrdinalGCompMeanDiff$compute_estimate_with_bootstrap_weights(
  subject_or_block_weights,
  estimate_only = FALSE
)

Arguments

subject_or_block_weights

Row weights for the bootstrap sample.

estimate_only

If TRUE, skip variance calculations.


InferenceOrdinalGCompMeanDiff$compute_asymp_confidence_interval()

Computes a \(1-\alpha\) confidence interval for the G-Comp mean difference using the delta-method standard error (see class documentation); NA with an edi_wald_unavailable_warning if that standard error is unavailable (v1.0.6-TODO-380). Identical to $compute_wald_confidence_interval().

Usage

InferenceOrdinalGCompMeanDiff$compute_asymp_confidence_interval(alpha = 0.05)

Arguments

alpha

The significance level (default 0.05).


InferenceOrdinalGCompMeanDiff$compute_asymp_two_sided_pval()

Computes a two-sided Wald p-value testing \(H_0: \mathrm{md} = \code{delta}\) using the delta-method standard error (see class documentation); NA with an edi_wald_unavailable_warning if that standard error is unavailable (v1.0.6-TODO-380). Identical to $compute_wald_two_sided_pval().

Usage

InferenceOrdinalGCompMeanDiff$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

The null treatment effect (default 0).


InferenceOrdinalGCompMeanDiff$compute_wald_confidence_interval()

Identical to $compute_asymp_confidence_interval() (both compute the same delta-method-based Wald interval, NA when its standard error is unavailable); provided as an explicit alias for callers that want to name the Wald method directly rather than via the generic "asymptotic" dispatch.

Usage

InferenceOrdinalGCompMeanDiff$compute_wald_confidence_interval(alpha = 0.05)

Arguments

alpha

The significance level (default 0.05).


InferenceOrdinalGCompMeanDiff$compute_wald_two_sided_pval()

Identical to $compute_asymp_two_sided_pval() (both compute the same delta-method-based Wald p-value, NA when its standard error is unavailable); provided as an explicit alias for callers that want to name the Wald method directly rather than via the generic "asymptotic" dispatch.

Usage

InferenceOrdinalGCompMeanDiff$compute_wald_two_sided_pval(delta = 0)

Arguments

delta

The null treatment effect (default 0).


InferenceOrdinalGCompMeanDiff$clone()

The objects of this class are cloneable with this method.

Usage

InferenceOrdinalGCompMeanDiff$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'ordinal')
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(sample(1:4, 10, replace = TRUE))
inf = InferenceOrdinalGCompMeanDiff$new(seq_des)
inf$compute_estimate()
#> [1] 1.041885
# }