
G-Computation Mean-Difference Inference for Ordinal Responses
Source:R/inference_ordinal_gcomp.R
InferenceOrdinalGCompMeanDiff.RdFits 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 silently fall back to a nonparametric bootstrap interval/p-value instead
(with a warning), rather than returning NA.
Super class
Inference -> InferenceOrdinalGCompMeanDiff
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()
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_objA completed
DesignSeqOneByOneobject with an ordinal 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 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).
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.
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), or falls back (with a warning) to a
nonparametric bootstrap interval if that standard error is
unavailable. Identical to $compute_wald_confidence_interval().
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), or falls back (with a warning) to a
nonparametric bootstrap p-value if that standard error is
unavailable. Identical to $compute_wald_two_sided_pval().
InferenceOrdinalGCompMeanDiff$compute_wald_confidence_interval()
Identical to $compute_asymp_confidence_interval()
(both compute the same delta-method-based Wald interval, with the
same bootstrap fallback); provided as an explicit alias for callers
that want to name the Wald method directly rather than via the
generic "asymptotic" dispatch.
InferenceOrdinalGCompMeanDiff$compute_wald_two_sided_pval()
Identical to $compute_asymp_two_sided_pval() (both
compute the same delta-method-based Wald p-value, with the same
bootstrap fallback); provided as an explicit alias for callers that
want to name the Wald method directly rather than via the generic
"asymptotic" dispatch.
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] 0.5739362
# }